[英]Selenium code not executing after driver.get
我正在尝试自动化一个网站。我使用driver,get()访问该页面并执行了一些操作。接下来,我不得不导航到该网站中的某个页面,并使用driver.get()来访问该页面。 在脚本执行到该部分之前,将其发布,然后将其停止并不会执行任何打印声明。最后,我收到了超时异常。我无法弄清楚它在哪里失败。
```code to automate which works well until here```
guid="48bc1201-3929-42af-85cf-50e89b53a800"
#guid=guid
url=baseurl+"#/loan/{"+ str(guid) + "}/summary"
print("qqw" + url)
driver.get(url)
#print functionality also does not happen.Basically the code freezes
print("next execution")
PS: 代码中要自动化的部分一直有效,直到这里表明我在这里使用了所有功能并且它们一直在起作用。此外,在最后一个driver.get()中,用户导航到了所需的页面。暂停。
我遇到了同样的问题。 在我的设置中, driver.get(URL)
有时会随机失败。
为了检测成功的页面加载或强制对driver.get(URL)
超时,我采用了以下解决方案,它适用于我:
driver.set_page_timeout(n)
driver.set_script_timeout(n)
loading_finished = 0 # URL not loaded
loading_attempts = 0 # Count loading attempts
while loading_finished = 0: # Enter loop
try:
if loading_attempts > 5: # Threshold for loading attempts
print "URL loading failed"
break # Too many loading attempts - exit loop
else:
website = driver.get(URL) # Try to load URL
loading_finished = 1 # URL loaded successfully - exit loop
print "URL loading worked"
except:
loading_attempts += 1 # Loading failed - count failed attempt and retry
else:
process_URL(driver, URL) # Do your magic
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.