I'm trying integrate selenium with spring. The code below works perfect if no spring dependencies added in pom.xml. but if I add spring boot dependency like below(I didn't add cucumber spring here and I removed all springcontext xml, cusumber xml from eclipse workspace) and run same test without modifying anything, It opens a IE test window http://localhost:36359/ then error out in console like below "org.openqa.selenium.remote.SessionNotFoundException: session null does not exist (WARNING: The server did not provide any stacktrace information)".
I even tried adding all spring annotation replacing @Before method by initizing webdriver in springcontext; but still the same behavior. can someone help me to fix this issue. I'm using selenium 3.4.0 version
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>1.4.3.RELEASE</version>
<relativePath />
</parent>
public class ScenarioOutlineStepDef {
WebDriver driver;
@Before()
public void setUp() {
System.setProperty("webdriver.ie.driver", "C:/IEDriverServer-64.exe");
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, false);
dc.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
dc.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
dc.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);
dc.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
dc.setJavascriptEnabled(true);
dc.setBrowserName("internet explorer");
driver = new InternetExplorerDriver(dc);
}
@Given("^user navigates to Pricing Portal$")
public void goToPricingPortal() {
driver.navigate().to(
"xyz.com;
}
@When("^I enter Username as \"([^\"]*)\" and Password as \"([^\"]*)\"$")
public void I_enter_Username_as_and_Password_as(String arg1, String arg2) {
driver.findElement(By.id("txtUserDefault")).sendKeys(arg1);
driver.findElement(By.id("txtPassDefault")).sendKeys(arg2);
driver.findElement(By.cssSelector("input[type=\"submit\"]")).click();
}
@Then("^login should be unsuccessful$")
public void validateRelogin() {
if (driver.getCurrentUrl().equalsIgnoreCase(
"xyz.com")) {
System.out.println("Test Pass");
} else {
System.out.println("Test Failed");
}
// driver.close();
}
Do it manually
Set same Security level for all zones. Try this steps
OR use
DesiredCapabilities
like this