3

I am running a set of 400 selenium2 scripts (webdriver backed) in java.

When I am running the scripts on a node registered with the grid, sometimes I get the Error communicating with the remote browser. It may have died error. After the script with this error has closed and other scripts start running, then around 10-20 scripts are skipped due to caused by null error.

Also there is only one browser instance running at a time. I am using chrome browser.

When ever I get the Error communicating with the remote browser error the caused by null error occurs.

I tried to get rid of the first error provided by this solution. But still I am getting both the errors.

Any help?

Edit Also when I run the scripts one at a time all the scripts work fine.

Community
  • 1
  • 1
me_digvijay
  • 5,374
  • 9
  • 46
  • 83
  • What version of Selenium? What version of Chrome? What version of the Chrome driver? – Arran Apr 10 '13 at 09:43
  • @Arran: I am using the selenium-server-standalone-2.31.0.jar chrome 26.0.1410.43 m and chromedriver_win_26.0.1383.0. – me_digvijay Apr 10 '13 at 10:59

1 Answers1

0

This generally happens when Webdriver instance is still alive and browser is closed unexpectedly.

Please provide more details like,

  1. Do you run your scripts sequentially or parallel.
  2. Do you invoke Webdriver instance before every test method and close after every method.
  3. Which test framework are you using.
  4. Is there any dependency between the test methods.

As per your solution from How to close a ChromeDriver when running on Grid? doesn't sounds good because, you are closing webdriver instance in @Aftersuite after all test methods are finished executing. If any of the reason the browser is closed at particular test method unexpectedly then rest of your methods will also fail due to browser is not alive. That's why you get null exception.

My suggestion is to invoke and close webdriver instance before and after every test method. like,

@BeforeMethod
public void setUp(){
 WebDriver driver =  new ChromeDriver();
}

and close it in,

@AfterMethod
public void tearDown(){
 driver.quit();
}

This way if any of the reason browser is closed unexpectedly only that particular test will fail not rest of all.

Community
  • 1
  • 1
user2087450
  • 339
  • 1
  • 11
  • I am running scripts sequentially. I also invoke a new webdriver instance and close after every test. I am using the testNG framework. First the setup() method is called, then the test() method and then finally tearDown() method is called. I am following the same method that you have described above. – me_digvijay Apr 10 '13 at 11:44