我正在获取输入网址,并尝试将其加载到浏览器中(Firefox-更新版本)。该脚本已在所有网址中使用。除非少数网址返回此错误
“当前没有打开任何模式对话框”
我尝试添加driver.switch_to_alert().accept()
,但没有帮助。我通常会关闭浏览器,然后重新启动。
请找到代码:
capabilities = DesiredCapabilities.FIREFOX.copy()
capabilities['marionette'] = True
capabilities['acceptSslCerts'] = True
driver = webdriver.Firefox(capabilities=capabilities)
driver.implicitly_wait(3)
print ("Number of rows to be processed is:" + str(ws1.max_row))
for row in range(2,ws1.max_row+1):
try:
region = ws1["E"+str(row)].value
# Reading Row 'row'
print("Reading row #"+str(row))
url = ws1["C"+str(row)].value
regex = df[df['Country'] == region]['Regex'].values[0]
#Load mainpage or input URL
i = 0
while i < 3:
try:
driver.get("http://"+url)
driver.switch_to_alert().accept()
time.sleep(5)
break
except (TimeoutException,WebDriverException,NoSuchElementException) as e:
print(e,'Retrying...',i+1)
i += 1
示例网址:
afilias.info
www.nuwavenow.com
www.IntoTomorrow.com
www.picobrew.com