Amar K
Amar K

Reputation: 43

Error communicating with the remote browser It may have died

I know this question has been asked many times and i have checked those but could not find solution .Above error is not frequent only sometimes i get it , so i am not able figure out why it is occurring .After executing below lines of code

 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)

i get this error

Message: Error communicating with the remote browser. It may have died. Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58' System info: host: '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 info: driver.version: RemoteWebDriver Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=35.0, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID: d7ac8e9e-2c20-48c6-82fd-ce8eaec93b46 Stacktrace: ('Unexpected error:', )

Selenium Server log for above execuion

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])

Any help is appreciated.

Upvotes: 0

Views: 1876

Answers (1)

Hassan Mehmood
Hassan Mehmood

Reputation: 1402

Because the below line will close your browser if it has only one tab open.

# remove that line and run your code. You will not see this error again.
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 'w')

Upvotes: 1

Related Questions