我试图阻止此警报,
Traceback (most recent call last):
File "app.py", line 171, in <module>
main()
File "app.py", line 109, in main
clipper = driver.find_elements_by_css_selector("div.btn")
File "/home/blaster/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 605, in find_elements_by_css_selector
return self.find_elements(by=By.CSS_SELECTOR, value=css_selector)
File "/home/blaster/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 983, in find_elements
'value': value})['value'] or []
File "/home/blaster/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "/home/blaster/.local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 241, in check_response
raise exception_class(message, screen, stacktrace, alert_text)
selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: None
Message: unexpected alert open: {Alert text : }
(Session info: headless chrome=65.0.3325.181)
(Driver info: chromedriver=2.35.528139 (47ead77cb35ab2a9a23218b282151362a66cd662),platform=Linux 4.4.0-116-generic x86_64)
我尝试过使用(来自this answer):
driver.execute_script("window.alert = function() {};")
但它不起作用,谢谢!
答案 0 :(得分:0)
错误说明了一切:
selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: None
Message: unexpected alert open: {Alert text : }
(Session info: headless chrome=65.0.3325.181)
(Driver info: chromedriver=2.35.528139 (47ead77cb35ab2a9a23218b282151362a66cd662),platform=Linux 4.4.0-116-generic x86_64)
您的主要问题是您使用的二进制文件之间的版本兼容性,如下所示:
支持 Chrome v62-64
支持 Chrome v64-66
因此 ChromeDriver 版本( v2.35 )与 Chrome浏览器版本( v65)之间存在明显的不匹配。 0 )
@Test
。答案 1 :(得分:0)
我认为您的页面上仍然有adam = tf.train.AdamOptimizer(0.001)
train = adam.minimize(cost)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for _ in range(5):
sess.run(train)
grad,variable = sess.run(opt.compute_gradients(cost))[0]
print(grad,variable)
#[-9.998 -1.998] [0.001 0.001]
#[-9.996 -1.996] [0.00199999 0.00199997]
#[-9.994 -1.9940002] [0.00299997 0.00299989]
#[-9.992001 -1.9920005] [0.00399994 0.00399976]
#[-9.99 -1.990001] [0.0049999 0.00499955]
处理程序,可防止驱动程序导航到另一个页面。
我看到了this answer,但这对我也不起作用。我很高兴发生这种情况,因为用jQuery设置的beforeunload
也应该用jQuery清除:
beforeunload