This is my Selenium browser test class (a derived one, but should not be hard to understand what it is doing). When I run the test case, all interactions occur as expected. But in the end the result of test case shows a failure.
package dmswebui.CR;
import org.infineta.webui.selenium4j.MainTestCase;
public class TestLogin extends MainTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
startSeleniumSession("ChromeDriver", "http://192.168.8.207/");
}
public void testMethod() throws Exception {
session().open("/");
session().type("name=user","admin");
session().type("name=password","infineta123");
session().click("id=btnLogin-button"); session().waitForPageToLoad("30000");
session().click("id=btnUserLogout-button");
session().click("id=yui-gen0-button"); session().waitForPageToLoad("30000");
}
public void tearDown() throws Exception {
super.tearDown();
closeSeleniumSession();
}
}
The error I get is:
Testcase: testMethod took 13.939 sec
Caused an ERROR
Error communicating with the remote browser. It may have died.
This usually happens when you are trying to close the same webdriver instance multiple times. Do you know what happens in
super.teardown()? When I checked the selenium4j source, it extends junit Testcase. Yoursuper.tearDownwill be calling jUnitTeardown and would be killing the browser instance beforecloseSeleniumSession()is called.You can put that
closeSeleniumSession()beforesuper.tearDown().