I am using Selenium to automate some tests. The WebDriver api getWindowHandle()
always returns 2147483649
. It should actually return a alpha numeric string like {9e10f4f4-2da6-ef43-b463-1b0d576e7dae}
that usually changes with every test run. But I always get 2147483649
. I'm using Selenium 3.5.1 and Firefox 55.0.2.
Code to reproduce the issue-
Java
public class SeleniumExample {
public static void main(String args[]){
System.setProperty("webdriver.gecko.driver","/Users/raghavendr.kolisetty/Downloads/geckodriver");
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);
driver.get("http://www.google.com");
System.out.println("printing test handles "+driver.getWindowHandle());
}
}
POM
<properties>
<selenium.java.version>3.5.1</selenium.java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>${selenium.java.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.java.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Output - printing test handles 2147483649
Can anyone explain what am I doing wrong. Thanks
Use this code.Hopefully it will works