![]() |
|
[Python] Page Refresh if Xpath Not Found - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Page Refresh if Xpath Not Found (/showthread.php?tid=5825495) |
Page Refresh if Xpath Not Found - Clockism - Apr 15, 2018 So I recently made a bot for supreme just for fun and to use myself, it is completed the only thing I need to fix is the refresh. Right now I have an if statement that refreshes the page if item not found. But it only refreshes once. I need help getting it to refresh until it finds the item. This is the code I have right now for the refresh. items = driver.find_elements_by_xpath("//article[.//a[contains(.,'MLK')]][.//a[.='Rainbow']]//a") if items: items[0].click() else: driver.get("http://www.supremenewyork.com/shop/all/sweatshirts") If anyone knows the syntax for it that would be great, pretty sure I need a while loop but not sure how to set it up. RE: Page Refresh if Xpath Not Found - Vanagander - Apr 15, 2018 Like this? Code while true:or? Code while items[0] != true:RE: Page Refresh if Xpath Not Found - michalmonday - Apr 16, 2018 http://selenium-python.readthedocs.io/waits.html you could implement these: Code from selenium.webdriver.support.ui import WebDriverWaitRE: Page Refresh if Xpath Not Found - Clockism - Apr 16, 2018 Thanks for all the answers. Helped me out a lot. |