admin管理员组文章数量:1391989
I have a webscrapping script using selenium that goes into a website, do some things, and then clicks on multiple download links. Browser being used is Edge.
Uppon clicking on the download link another blank window opens just to download a file to the C:/Download dir. I do time.sleep(5), switch to that new window, close it, go back to the main window and click the next download link, repeat. Like this:
def download_page(driver):
download_buttons = driver.find_elements(By.XPATH, "//span[@id='btnDownload']/a")
for button in download_buttons:
print(button)
# Move para o botão e clica
ActionChains(driver).move_to_element(button).click(button).perform()
driver.switch_to.window(driver.window_handles[-1])
time.sleep(5)
driver.close()
driver.switch_to.window(driver.window_handles[0])
This script ran pretty fast for weeks until yesterday. Now, when I run the line driver.window_handles, it takes more than 10 minutes to get the results.
This only happens after the download link is clicked and the new blank window is opened. If I run the driver.window_handles command while only having the main window open, it works fine.
I don't get any errors; it just takes forever to run. Any ideas on what could cause this behavior?
I'm also open to workaround suggestions. I'm considering using a mouse automation script to solve it quickly, but that is not ideal since it would require that no one uses the computer while the script runs, which is possible but annoying.
Thanks for your attention!
本文标签: pythonSelenium driverwindowhandles suddenly taking too long to runStack Overflow
版权声明:本文标题:python - Selenium driver.window_handles suddenly taking too long to run - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744687544a2619794.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论