0

Hey im new to python selenium developing, and i kinda need some help if any one have some extra time:)

Im using this site: https://www.youlikehits.com/retweets.php Im trying to click on confirm button the green one. But for some reson i cant figure out how to click it. Every try it says that it cant locate it.

Do you guys have any ide?

Screen: https://i.sstatic.net/Z31In.png Screen of html code: https://i.sstatic.net/herDB.png

Code:

driver.find_element_by_link_text('Confirm').click()


try:
        print("Trying")
        print("Making points Click")
        time.sleep(5)
except NoSuchAttributeException:
        print("Element not found!")
        continue
except:
        print("Something els is wrong!")

driver.quit()

Best Regards Felix

3
  • where the green button is ?? Commented Apr 12, 2021 at 19:31
  • Post your code what you have tried so far and also html in text format. Commented Apr 12, 2021 at 19:37
  • The green button is highlighted in the picture, the secound one far down. Stack arent alowing me to add the html code for some reson. Commented Apr 12, 2021 at 20:15

1 Answer 1

1

The Confirm link is inside an iframe and you need to switch to iframe first inorder to access the element.

Use WebDriverWait() wait for frame_to_be_available_and_switch_to_it() and follwoing css selector Use WebDriverWait() wait for element_to_be_clickable() and follwoing xpath

driver.get("url")
wait=WebDriverWait(driver,10)
wait.until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, "iframe[src^='retweetrender.php']")))
wait.until(EC.element_to_be_clickable((By.XPATH,"//a[contains(.,'Confirm')]"))).click()

OR

driver.get("url")
wait=WebDriverWait(driver,10)
wait.until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, "iframe[src^='retweetrender.php']")))
wait.until(EC.element_to_be_clickable((By.LINK_TEXT,"Confirm"))).click()

You need following imports.

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks alot for help!, its now all working.
Do you have any tips on where to studdy more on python selenium? :)
You can learn ExplicitWait selenium-python.readthedocs.io/waits.html here

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.