【发布时间】:2016-12-15 04:38:07
【问题描述】:
我知道这个问题已经被问过很多次了,我已经检查过这些问题但找不到解决方案。上述错误并不常见,只是有时我得到它,所以我无法弄清楚它为什么会发生。执行以下行后代码
driver.get(first_url)
#here i open forst url the perform some operation
main_window =driver.current_window_handle
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + "t")
#above line opens a new tab
# Put focus on current window which will, in fact, put focus on the current visible tab
main_window_new =driver.current_window_handle
driver.switch_to_window(main_window_new )
time.sleep(1)
driver.get(second_url)
#opening new tab in the existing browser
time.sleep(2)
json_str=driver.find_element_by_tag_name('body').text
time.sleep(1)
print json
# Close current tab
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 'w')
# Put focus on current window which will be the window opener
driver.switch_to_window(main_window)
我收到这个错误
消息:与远程浏览器通信时出错。它可能有 死了。构建信息:版本:'2.53.0',修订:'35ae25b',时间: '2016-03-15 17:00:58' 系统信息:主机:'BLR-CSM-1',ip: '172.17.1.34', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_101' 驱动程序信息: driver.version: RemoteWebDriver 功能 [{applicationCacheEnabled=true, 可旋转=false,handlesAlerts=true,databaseEnabled=true, 版本=35.0,平台=WINDOWS,nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, 需要Screenshot=true,javascriptEnabled=true, cssSelectorsEnabled=true}] 会话 ID: d7ac8e9e-2c20-48c6-82fd-ce8eaec93b46 堆栈跟踪:('意外错误:', )
上述执行的 Selenium 服务器日志
13:21:08.048 INFO - Executing: [get current window handle])
13:21:08.058 INFO - Done: [get current window handle]
13:21:08.060 INFO - Executing: [find element: By.tagName: body])
13:21:08.068 INFO - Done: [find element: By.tagName: body]
13:21:08.071 INFO - Executing: [send keys: 603 [[FirefoxDriver: firefox on WINDO
WS (d52fe7cd-ee42-41f7-b065-ec1e853e1011)] -> tag name: body], [?, t]])
13:21:08.097 INFO - Done: [send keys: 603 [[FirefoxDriver: firefox on WINDOWS (d
52fe7cd-ee42-41f7-b065-ec1e853e1011)] -> tag name: body], [?, t]]
13:21:10.107 INFO - Executing: [get current window handle])
13:21:10.118 INFO - Done: [get current window handle]
13:21:10.122 INFO - Executing: [switch to window: {1d2e0152-8716-466e-bb62-d0a96
073fb3b}])
13:21:10.130 INFO - Done: [switch to window: {1d2e0152-8716-466e-bb62-d0a96073fb
3b}]
13:21:11.133 INFO - Executing: [get:https://myar.axyza.com/monitor/getStatsData?
graphTypeId=0])
13:21:12.173 INFO - Done: [get: https://myar.axyza.com/monitor/getStatsData?
graphTypeId=0])]
13:21:14.176 INFO - Executing: [find element: By.tagName: body])
13:21:14.185 INFO - Done: [find element: By.tagName: body]
13:21:14.188 INFO - Executing: [get text: 853 [[FirefoxDriver: firefox on WINDOW
S (d52fe7cd-ee42-41f7-b065-ec1e853e1011)] -> tag name: body]])
13:21:14.215 INFO - Done: [get text: 853 [[FirefoxDriver: firefox on WINDOWS (d5
2fe7cd-ee42-41f7-b065-ec1e853e1011)] -> tag name: body]]
13:21:15.221 INFO - Executing: [find element: By.tagName: body])
13:21:15.233 INFO - Done: [find element: By.tagName: body]
13:21:15.237 INFO - Executing: [send keys: 853 [[FirefoxDriver: firefox on WINDO
WS (d52fe7cd-ee42-41f7-b065-ec1e853e1011)] -> tag name: body], [?, w]])
13:21:15.367 INFO - Done: [send keys: 853 [[FirefoxDriver: firefox on WINDOWS (d
52fe7cd-ee42-41f7-b065-ec1e853e1011)] -> tag name: body], [?, w]]
13:21:17.371 INFO - Executing: [switch to window: {1d2e0152-8716-466e-bb62-d0a96
073fb3b}])
13:21:18.417 INFO - Executing: [close window])
感谢任何帮助。
【问题讨论】:
-
对不起,错误在哪里?我只看到 INFO 日志
-
@Rudziankoŭ 请在上面找到
-
您是否使用一些远程服务,例如
soucelabs或browserstack?测试运行多长时间? -
总是失败到同一行/代码?如果不是,您应该尝试其他 selenium 服务器版本,看看会发生什么,可能不是编码问题。
-
@Rudziankoŭ 没有远程服务,但我使用远程 webdriver。取决于输入。所以它可能长达一个小时
标签: python selenium selenium-webdriver