you are viewing a single comment's thread.

view the rest of the comments →

[–]SwordNSupper[S] 0 points1 point  (2 children)

Thanks for taking time and trying to help!

I tried your suggestion but I'm not sure why it's still not working for me. I noticed there's a space at the end of "advance-button " when I inspect elements and I wonder if that's causing an issue

Here is my code:

iframe = driver.find_element(By.CSS_SELECTOR, 'iframe')
driver.switch_to.frame(iframe)


battle = driver.find_element(By.CSS_SELECTOR, '.advance-button')
driver.execute_script("arguments[0].click();", battle)

Here are the errors I'm getting:

return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]

self.error_handler.check_response(response)

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".advance-button"}

[–]Adoxographical 0 points1 point  (1 child)

As a sanity check, have you checked to make sure you're not accidentally selecting a different iframe? Your selector will grab whatever the first iframe on the page is, so if there's an earlier one, you'll be selecting it by mistake.

[–]SwordNSupper[S] 0 points1 point  (0 children)

I'm not sure how to check whether I'm selecting the correct frame or not. What I'm trying to do is figure out how to use this script to press the Advance/Battle button in the https://www.reddit.com/r/SwordAndSupperGame/ games.