Firefox driver not navigating to new tab - selenium-webdriver

I am facing a problem when I run selenium tests on firefox driver. the issue is that the driver is not navigating to new tab. it open the tab, however the flow is not shifting. these are the dependencies I used in the pom :
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>2.2.0</version>
</dependency>
and this is the instance of firefox driver i am creating-
FirefoxDriverManager.getInstance().setup();
driver = new FirefoxDriver();
this is the import-
import io.github.bonigarcia.wdm.FirefoxDriverManager;
this is the piece of code I used to navigate to the new window.
public void switchToNewWindow() {
parentWindow = driver.getWindowHandle();
Set<String> handles = driver.getWindowHandles();
for (String windowHandle : handles) {
if (!windowHandle.equals(parentWindow)) {
driver.switchTo().window(windowHandle);
driver.manage().window().maximize();
}
}
}
the tests runs fine on chrome browser with out any issues.
this is the version of the firefox browser-
Version 61.0.2 (64-bit)
this is the error message. the locator it failed to detect is in the new tab, which the driver failed to switch to-
Testing started at 16:03 ...
"C:\Program Files\Java\jdk1.8.0_161\bin\java" -Dorg.jetbrains.run.directory=C:\Users\rajeshg\IdeaProjects\nxtier\src\test\Resources\com\unionstreet\NxTier\smokePack "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4\lib\idea_rt.jar=52489:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_161\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\rt.jar;C:\Users\rajeshg\IdeaProjects\nxtier\target\test-classes;C:\Users\rajeshg\IdeaProjects\nxtier\target\classes;C:\Users\rajeshg\.m2\repository\com\google\guava\guava\23.0\guava-23.0.jar;C:\Users\rajeshg\.m2\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;C:\Users\rajeshg\.m2\repository\com\google\errorprone\error_prone_annotations\2.0.18\error_prone_annotations-2.0.18.jar;C:\Users\rajeshg\.m2\repository\com\google\j2objc\j2objc-annotations\1.1\j2objc-annotations-1.1.jar;C:\Users\rajeshg\.m2\repository\org\codehaus\mojo\animal-sniffer-annotations\1.14\animal-sniffer-annotations-1.14.jar;C:\Users\rajeshg\.m2\repository\com\jayway\restassured\rest-assured\2.9.0\rest-assured-2.9.0.jar;C:\Users\rajeshg\.m2\repository\org\codehaus\groovy\groovy\2.4.4\groovy-2.4.4.jar;C:\Users\rajeshg\.m2\repository\org\codehaus\groovy\groovy-xml\2.4.4\groovy-xml-2.4.4.jar;C:\Users\rajeshg\.m2\repository\org\apache\httpcomponents\httpclient\4.5.1\httpclient-4.5.1.jar;C:\Users\rajeshg\.m2\repository\org\apache\httpcomponents\httpmime\4.5.1\httpmime-4.5.1.jar;C:\Users\rajeshg\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\rajeshg\.m2\repository\org\hamcrest\hamcrest-library\1.3\hamcrest-library-1.3.jar;C:\Users\rajeshg\.m2\repository\org\ccil\cowan\tagsoup\tagsoup\1.2.1\tagsoup-1.2.1.jar;C:\Users\rajeshg\.m2\repository\com\jayway\restassured\json-path\2.9.0\json-path-2.9.0.jar;C:\Users\rajeshg\.m2\repository\org\codehaus\groovy\groovy-json\2.4.4\groovy-json-2.4.4.jar;C:\Users\rajeshg\.m2\repository\com\jayway\restassured\rest-assured-common\2.9.0\rest-assured-common-2.9.0.jar;C:\Users\rajeshg\.m2\repository\com\jayway\restassured\xml-path\2.9.0\xml-path-2.9.0.jar;C:\Users\rajeshg\.m2\repository\com\jayway\jsonpath\json-path\2.4.0\json-path-2.4.0.jar;C:\Users\rajeshg\.m2\repository\net\minidev\json-smart\2.3\json-smart-2.3.jar;C:\Users\rajeshg\.m2\repository\net\minidev\accessors-smart\1.2\accessors-smart-1.2.jar;C:\Users\rajeshg\.m2\repository\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;C:\Users\rajeshg\.m2\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;C:\Users\rajeshg\.m2\repository\org\hamcrest\hamcrest-all\1.3\hamcrest-all-1.3.jar;C:\Users\rajeshg\.m2\repository\com\googlecode\json-simple\json-simple\1.1.1\json-simple-1.1.1.jar;C:\Users\rajeshg\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\rajeshg\.m2\repository\io\github\bonigarcia\webdrivermanager\2.2.0\webdrivermanager-2.2.0.jar;C:\Users\rajeshg\.m2\repository\commons-io\commons-io\2.5\commons-io-2.5.jar;C:\Users\rajeshg\.m2\repository\com\google\code\gson\gson\2.8.0\gson-2.8.0.jar;C:\Users\rajeshg\.m2\repository\org\rauschig\jarchivelib\0.7.1\jarchivelib-0.7.1.jar;C:\Users\rajeshg\.m2\repository\org\apache\commons\commons-compress\1.9\commons-compress-1.9.jar;C:\Users\rajeshg\.m2\repository\org\jsoup\jsoup\1.10.2\jsoup-1.10.2.jar;C:\Users\rajeshg\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\rajeshg\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\rajeshg\.m2\repository\com\vimalselvam\cucumber-extentsreport\1.0.0\cucumber-extentsreport-1.0.0.jar;C:\Users\rajeshg\.m2\repository\info\cukes\cucumber-java\1.2.3\cucumber-java-1.2.3.jar;C:\Users\rajeshg\.m2\repository\com\relevantcodes\extentreports\2.40.2\extentreports-2.40.2.jar;C:\Users\rajeshg\.m2\repository\org\xerial\sqlite-jdbc\3.8.11.1\sqlite-jdbc-3.8.11.1.jar;C:\Users\rajeshg\.m2\repository\org\freemarker\freemarker\2.3.23\freemarker-2.3.23.jar;C:\Users\rajeshg\.m2\repository\org\apache\directory\studio\org.apache.commons.codec\1.8\org.apache.commons.codec-1.8.jar;C:\Users\rajeshg\.m2\repository\org\seleniumhq\selenium\selenium-java\3.14.0\selenium-java-3.14.0.jar;C:\Users\rajeshg\.m2\repository\org\seleniumhq\selenium\selenium-chrome-driver\3.14.0\selenium-chrome-driver-3.14.0.jar;C:\Users\rajeshg\.m2\repository\org\seleniumhq\selenium\selenium-edge-driver\3.14.0\selenium-edge-driver-3.14.0.jar;C:\Users\rajeshg\.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\3.14.0\selenium-firefox-driver-3.14.0.jar;C:\Users\rajeshg\.m2\repository\org\seleniumhq\selenium\selenium-ie-driver\3.14.0\selenium-ie-driver-3.14.0.jar;C:\Users\rajeshg\.m2\repository\org\seleniumhq\selenium\selenium-opera-driver\3.14.0\selenium-opera-driver-3.14.0.jar;C:\Users\rajeshg\.m2\repository\org\seleniumhq\selenium\selenium-remote-driver\3.14.0\selenium-remote-driver-3.14.0.jar;C:\Users\rajeshg\.m2\repository\org\seleniumhq\selenium\selenium-safari-driver\3.14.0\selenium-safari-driver-3.14.0.jar;C:\Users\rajeshg\.m2\repository\org\seleniumhq\selenium\selenium-support\3.14.0\selenium-support-3.14.0.jar;C:\Users\rajeshg\.m2\repository\net\bytebuddy\byte-buddy\1.8.15\byte-buddy-1.8.15.jar;C:\Users\rajeshg\.m2\repository\org\apache\commons\commons-exec\1.3\commons-exec-1.3.jar;C:\Users\rajeshg\.m2\repository\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;C:\Users\rajeshg\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\rajeshg\.m2\repository\org\apache\httpcomponents\httpcore\4.4.9\httpcore-4.4.9.jar;C:\Users\rajeshg\.m2\repository\com\squareup\okhttp3\okhttp\3.10.0\okhttp-3.10.0.jar;C:\Users\rajeshg\.m2\repository\com\squareup\okio\okio\1.14.1\okio-1.14.1.jar;C:\Users\rajeshg\.m2\repository\org\apache\commons\commons-lang3\3.4\commons-lang3-3.4.jar;C:\Users\rajeshg\.m2\repository\net\sourceforge\htmlunit\htmlunit\2.18\htmlunit-2.18.jar;C:\Users\rajeshg\.m2\repository\xalan\xalan\2.7.2\xalan-2.7.2.jar;C:\Users\rajeshg\.m2\repository\xalan\serializer\2.7.2\serializer-2.7.2.jar;C:\Users\rajeshg\.m2\repository\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar;C:\Users\rajeshg\.m2\repository\net\sourceforge\htmlunit\htmlunit-core-js\2.17\htmlunit-core-js-2.17.jar;C:\Users\rajeshg\.m2\repository\xerces\xercesImpl\2.11.0\xercesImpl-2.11.0.jar;C:\Users\rajeshg\.m2\repository\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar;C:\Users\rajeshg\.m2\repository\net\sourceforge\nekohtml\nekohtml\1.9.22\nekohtml-1.9.22.jar;C:\Users\rajeshg\.m2\repository\net\sourceforge\cssparser\cssparser\0.9.16\cssparser-0.9.16.jar;C:\Users\rajeshg\.m2\repository\org\w3c\css\sac\1.3\sac-1.3.jar;C:\Users\rajeshg\.m2\repository\org\eclipse\jetty\websocket\websocket-client\9.2.12.v20150709\websocket-client-9.2.12.v20150709.jar;C:\Users\rajeshg\.m2\repository\org\eclipse\jetty\jetty-util\9.2.12.v20150709\jetty-util-9.2.12.v20150709.jar;C:\Users\rajeshg\.m2\repository\org\eclipse\jetty\jetty-io\9.2.12.v20150709\jetty-io-9.2.12.v20150709.jar;C:\Users\rajeshg\.m2\repository\org\eclipse\jetty\websocket\websocket-common\9.2.12.v20150709\websocket-common-9.2.12.v20150709.jar;C:\Users\rajeshg\.m2\repository\org\eclipse\jetty\websocket\websocket-api\9.2.12.v20150709\websocket-api-9.2.12.v20150709.jar;C:\Users\rajeshg\.m2\repository\net\sourceforge\jtds\jtds\1.3.1\jtds-1.3.1.jar;C:\Users\rajeshg\.m2\repository\xmlunit\xmlunit\1.6\xmlunit-1.6.jar;C:\Users\rajeshg\.m2\repository\com\microsoft\sqlserver\mssql-jdbc\6.1.0.jre8\mssql-jdbc-6.1.0.jre8.jar;C:\Users\rajeshg\.m2\repository\com\microsoft\azure\azure-keyvault\0.9.3\azure-keyvault-0.9.3.jar;C:\Users\rajeshg\.m2\repository\com\microsoft\azure\azure-core\0.9.3\azure-core-0.9.3.jar;C:\Users\rajeshg\.m2\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;C:\Users\rajeshg\.m2\repository\javax\mail\mail\1.4.5\mail-1.4.5.jar;C:\Users\rajeshg\.m2\repository\javax\activation\activation\1.1\activation-1.1.jar;C:\Users\rajeshg\.m2\repository\com\sun\jersey\jersey-client\1.13\jersey-client-1.13.jar;C:\Users\rajeshg\.m2\repository\com\sun\jersey\jersey-core\1.13\jersey-core-1.13.jar;C:\Users\rajeshg\.m2\repository\com\sun\jersey\jersey-json\1.13\jersey-json-1.13.jar;C:\Users\rajeshg\.m2\repository\org\codehaus\jettison\jettison\1.1\jettison-1.1.jar;C:\Users\rajeshg\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.3-1\jaxb-impl-2.2.3-1.jar;C:\Users\rajeshg\.m2\repository\javax\xml\bind\jaxb-api\2.2.2\jaxb-api-2.2.2.jar;C:\Users\rajeshg\.m2\repository\javax\xml\stream\stax-api\1.0-2\stax-api-1.0-2.jar;C:\Users\rajeshg\.m2\repository\org\codehaus\jackson\jackson-core-asl\1.9.2\jackson-core-asl-1.9.2.jar;C:\Users\rajeshg\.m2\repository\org\codehaus\jackson\jackson-mapper-asl\1.9.2\jackson-mapper-asl-1.9.2.jar;C:\Users\rajeshg\.m2\repository\org\codehaus\jackson\jackson-jaxrs\1.9.2\jackson-jaxrs-1.9.2.jar;C:\Users\rajeshg\.m2\repository\org\codehaus\jackson\jackson-xc\1.9.2\jackson-xc-1.9.2.jar;C:\Users\rajeshg\.m2\repository\javax\inject\javax.inject\1\javax.inject-1.jar;C:\Users\rajeshg\.m2\repository\com\microsoft\azure\adal4j\1.0.0\adal4j-1.0.0.jar;C:\Users\rajeshg\.m2\repository\com\nimbusds\oauth2-oidc-sdk\4.5\oauth2-oidc-sdk-4.5.jar;C:\Users\rajeshg\.m2\repository\net\jcip\jcip-annotations\1.0\jcip-annotations-1.0.jar;C:\Users\rajeshg\.m2\repository\com\nimbusds\lang-tag\1.4\lang-tag-1.4.jar;C:\Users\rajeshg\.m2\repository\com\nimbusds\nimbus-jose-jwt\3.1.2\nimbus-jose-jwt-3.1.2.jar;C:\Users\rajeshg\.m2\repository\org\bouncycastle\bcprov-jdk15on\1.51\bcprov-jdk15on-1.51.jar;C:\Users\rajeshg\.m2\repository\info\cukes\cucumber-junit\1.2.5\cucumber-junit-1.2.5.jar;C:\Users\rajeshg\.m2\repository\info\cukes\cucumber-core\1.2.5\cucumber-core-1.2.5.jar;C:\Users\rajeshg\.m2\repository\info\cukes\cucumber-html\0.2.3\cucumber-html-0.2.3.jar;C:\Users\rajeshg\.m2\repository\info\cukes\cucumber-jvm-deps\1.0.5\cucumber-jvm-deps-1.0.5.jar;C:\Users\rajeshg\.m2\repository\info\cukes\gherkin\2.12.2\gherkin-2.12.2.jar;C:\Users\rajeshg\.m2\repository\org\apache\pdfbox\pdfbox\2.0.0\pdfbox-2.0.0.jar;C:\Users\rajeshg\.m2\repository\org\apache\pdfbox\fontbox\2.0.0\fontbox-2.0.0.jar;C:\Users\rajeshg\.m2\repository\mysql\mysql-connector-java\6.0.4\mysql-connector-java-6.0.4.jar;C:\Users\rajeshg\.m2\repository\de\redsix\pdfcompare\1.1.25\pdfcompare-1.1.25.jar;C:\Users\rajeshg\.m2\repository\com\typesafe\config\1.3.1\config-1.3.1.jar;C:\Users\rajeshg\.m2\repository\org\dbunit\dbunit\2.5.4\dbunit-2.5.4.jar;C:\Users\rajeshg\.m2\repository\org\apache\poi\poi-ooxml\3.14\poi-ooxml-3.14.jar;C:\Users\rajeshg\.m2\repository\org\apache\poi\poi\3.14\poi-3.14.jar;C:\Users\rajeshg\.m2\repository\org\apache\poi\poi-ooxml-schemas\3.14\poi-ooxml-schemas-3.14.jar;C:\Users\rajeshg\.m2\repository\org\apache\xmlbeans\xmlbeans\2.6.0\xmlbeans-2.6.0.jar;C:\Users\rajeshg\.m2\repository\stax\stax-api\1.0.1\stax-api-1.0.1.jar;C:\Users\rajeshg\.m2\repository\com\github\virtuald\curvesapi\1.03\curvesapi-1.03.jar;C:\Users\rajeshg\.m2\repository\com\opencsv\opencsv\4.0\opencsv-4.0.jar;C:\Users\rajeshg\.m2\repository\org\apache\commons\commons-text\1.1\commons-text-1.1.jar;C:\Users\rajeshg\.m2\repository\commons-beanutils\commons-beanutils\1.9.3\commons-beanutils-1.9.3.jar;C:\Users\rajeshg\.m2\repository\org\seleniumhq\selenium\selenium-api\3.14.0\selenium-api-3.14.0.jar;C:\Users\rajeshg\.m2\repository\io\netty\netty\3.5.7.Final\netty-3.5.7.Final.jar;C:\Users\rajeshg\.IdeaIC2017.3\config\plugins\cucumber-java\lib\cucumber-jvm-formatter.jar" cucumber.api.cli.Main --plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvmSMFormatter --monochrome --name "^Adding pricing details to a newly created customer$" --glue com.unionstreet.support --glue com.unionstreet.NxTier.stepDefs.smokePack C:/Users/rajeshg/IdeaProjects/nxtier/src/test/Resources/com/unionstreet/NxTier/smokePack/NxTier_smokePack.feature
16:03:51.767 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Reading https://api.github.com/repos/mozilla/geckodriver/releases to seek wires, geckodriver
16:03:52.126 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Latest version of wires, geckodriver is 0.21.0
16:03:52.157 [main] INFO io.github.bonigarcia.wdm.Downloader - Using binary driver previously downloaded C:\Users\rajeshg\.m2\repository\webdriver\geckodriver\win64\0.21.0\geckodriver.exe
16:03:52.157 [main] DEBUG io.github.bonigarcia.wdm.Downloader - Target folder content: geckodriver.exe
16:03:52.157 [main] INFO io.github.bonigarcia.wdm.Downloader - Using binary driver previously downloaded C:\Users\rajeshg\.m2\repository\webdriver\geckodriver\win64\0.21.0\geckodriver.exe
16:03:52.157 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Exporting webdriver.gecko.driver as C:\Users\rajeshg\.m2\repository\webdriver\geckodriver\win64\0.21.0\geckodriver.exe
1533827032298 geckodriver INFO geckodriver 0.21.0
1533827032314 geckodriver INFO Listening on 127.0.0.1:27819
1533827032954 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\rajeshg\\AppData\\Local\\Temp\\rust_mozprofile.DpjbO1o8RyAk"
Unable to read VR Path Registry from C:\Users\rajeshg\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\rajeshg\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\rajeshg\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\rajeshg\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\rajeshg\AppData\Local\openvr\openvrpaths.vrpath
1533827034578 Marionette INFO Listening on port 52497
1533827034618 Marionette WARN TLS certificate errors will be ignored for this session
Aug 09, 2018 4:03:54 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: By.id: DCompany_name (tried for 20 second(s) with 500 milliseconds interval)
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:113)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:283)
at com.unionstreet.support.ElementUtils.sendText(ElementUtils.java:70)
at com.unionstreet.com.unionstreet.NxTier.pages.NewBusinessCustomerPage.addCompanyInfoForNewBusinessCustomerCreatedWithDefaultContactTypes(NewBusinessCustomerPage.java:65)
at com.unionstreet.NxTier.stepDefs.smokePack.NxTier_smokePack_stepDefs.iHaveAddedANewBusinessCustomer(NxTier_smokePack_stepDefs.java:79)
at ✽.And I have added a new business customer(C:/Users/rajeshg/IdeaProjects/nxtier/src/test/Resources/com/unionstreet/NxTier/smokePack/NxTier_smokePack.feature:45)
Caused by: org.openqa.selenium.NoSuchElementException: Cannot locate an element using By.id: DCompany_name
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'TESTING001', ip: '10.1.8.93', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_161'
Driver info: driver.version: unknown
any help would be much appreciated!
thank you!

1) First you need to retrieve opened tabs
List<String> tabs = new ArrayList<>(driver.getWindowHandles());
2) open new tab
((JavascriptExecutor)driver).executeScript("window.open('/')");
3) navigate to the tab
driver.switchTo.window(tabs.get(index))

100% working solution:
// open new tab
WebDriver driver = DriverFactory.getWebDriver();
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.open()");
Thread.sleep(100); // wait to winHandles value increases. Without it will result in random nullPointerException at this point.
// go to tab with index i
WebDriver driver = DriverFactory.getWebDriver();
ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles());
driver.switchTo().window(tabs.get(i));
Thread.sleep(100);
// close tab
WebDriver driver = DriverFactory.getWebDriver();
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.close()");
Thread.sleep(100);

Related

Unable to create new remote session while testing an Android application with Appium

I'm trying to run an Example of test scripts coded with java in Eclipse with Appium. I run Appium by npm (i'm using Appium 1.6.3, i'm not new to Appium i run it before on Mac and on windows without any problem but this time in Ubuntu it looks a bit different while it's not with the appium application but with console)
appium --address 127.0.0.1
I'm using
java-client-4.1.2.jar
selenium-java-3.0.1.jar
selenium-server-standalone-3.0.1.jar
testng-6.9.10.jar
And my java class is :
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class FirstTest {
AndroidDriver<AndroidElement> driver;
File path = new File("/home/emna/Téléchargements/AutomationFiles/app-release.apk");
#BeforeClass
public void setUp() throws MalformedURLException {
System.out.println("app Dir.--->" + path);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "SM-G360H");
capabilities.setCapability("version", "4.4.4");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "platform");
capabilities.setCapability("udid", "***************");
capabilities.setCapability("app", path.getAbsolutePath());
capabilities.setCapability("appPackage", "com.bulldozer.gaa");
capabilities.setCapability("appActivity",
"com.bulldozer.gaa.activities.MainActivity");
driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"),
capabilities);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
}
#Test
public void Test1() throws InterruptedException {
// driver.wait(10000);
System.out.println("GAA");
driver.findElement(By.id("acceptCheckbox")).click();
driver.findElement(By.id("continueBtn")).click();
}
#AfterClass
public void tearDown() {
driver.quit();
}
}
But the problem is that :
[TestNG] Running:
/tmp/testng-eclipse--2049046107/testng-customsuite.xml
app Dir.--->/home/emna/Téléchargements/AutomationFiles/app-release.apk
Jan 24, 2017 1:14:44 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Jan 24, 2017 1:14:59 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Jan 24, 2017 1:15:10 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection
FAILED CONFIGURATION: #BeforeClass setUp
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{app=/home/emna/Téléchargements/AutomationFiles/app-release.apk, appPackage=com.bulldozer.gaa, appActivity=com.bulldozer.gaa.activities.MainActivity, platformVersion=platform, platformName=Android, udid=*************, deviceName=SM-G360H, version=4.4.4}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'tarek-Vostro-3902', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-59-generic', java.version: '1.8.0_91'
Driver info: driver.version: AndroidDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:69)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
Here the Appium log file :
[debug] [ADB] Running '/home/emna/Android/Sdk/platform-tools/adb' with args: ["-P",5037,"-s","***************","shell","am","force-stop","io.appium.unlock"]
[debug] [Logcat] Stopping logcat capture
[debug] [AndroidDriver] Not cleaning generated files. Add `clearSystemFiles` capability if wanted.
[MJSONWP] Encountered internal error running command: Error: Error occured while starting App. Original error: Permission to start activity denied.
at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)
at ADB.callee$0$0$ (../../../lib/tools/apk-utils.js:80:9)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at process._tickCallback (internal/process/next_tick.js:103:7)
[HTTP] <-- POST /wd/hub/session 500 11015 ms - 223
[HTTP] --> POST /wd/hub/session {"capabilities":{"desiredCapabilities":{"app":"/home/emna/Téléchargements/AutomationFiles/app-release.apk","appPackage":"com.bulldozer.gaa","appActivity":"com.bulldozer.gaa.activities.MainActivity","platformVersion":"platform","platformName":"Android","udid":"************","deviceName":"SM-G360H","version":"4.4.4"},"requiredCapabilities":{}}}
[debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCapabilities","capabilities","sessionId","id","sessionId","id","sessionId","id"]} and you sent ["capabilities"]
[HTTP] <-- POST /wd/hub/session 400 5 ms - 205
You forgot the most important capability, which is the path to the .apk:
capabilities.setCapability("app", "appPath");
Also, i would recommend on changing from RemoteWebDriver to Android driver, since you will have some more functionality:
driver = new AndroidDriver(....)
ps: you can update your java-client to 4.1.2 and testng to 6.9.10
The reason is because your Appium is running already the app using GUI settings.
Simultaneously you are trying to run it again from your code.
What should help : In Appium UI go to Android settings (basic)
Application panel: do not define / launch the app and its activities.
Capabilities panel: define and select {Platform Name, Automation Name, Platform Version}
The problem is with the apk file itself, I used an other .apk file with the same configuration i have used and it works fine !
This could be an issue, since as I understood you are running Appium on the same machine where your client scripts reside, try using "http://127.0.1.1:4723/wd/hub" instead. this Solution works for me
AndroidDriver<AndroidElement> driver = null;
driver = new AndroidDriver<>(new URL("http://127.0.1.1:4723/wd/hub"), capabilities);

How to read the maven dependecy of chrome browser which is a .jar file into my java file

I'm trying to run my simple Selenium code to open http://google.com on my Chrome browser. I am using Selenium 3.0.
I have a maven dependency in my POM.xml for chromedriver which is as follows:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.44.0</version>
</dependency>
Now after giving that dependency I'm able to see selenium-chrome-driver-2.44.0.jar file under my Maven Maven Dependencies folder. However I don't know how to use this jar file to access the chrome browser.
I've tried this:
System.setProperty("webdriver.chrome.driver","C:\\Users\\vikas.kumar5\\.m2\\repository\\org\\seleniumhq\\selenium\\selenium-chrome-driver\\2.44.0\\selenium-chrome-driver-2.44.0.jar");
WebDriver driver=new ChromeDriver();
I am getting the following exception.
SEVERE: org.apache.commons.exec.ExecuteException: Execution failed
(Exit value: -559038737. Caused by java.io.IOException: Cannot run
program
"C:\Users\vikas.kumar5.m2\repository\org\seleniumhq\selenium\selenium-chrome-driver\2.44.0\selenium-chrome-driver-2.44.0.jar"
(in directory "."): CreateProcess error=193, %1 is not a valid Win32
application) Exception in thread "main"
org.openqa.selenium.WebDriverException: Timed out waiting for driver
server to start. Build info: version: '3.0.1', revision: '1969d75',
time: '2016-10-18 09:49:13 -0700' System info: host: 'HOME', ip:
'192.168.56.1', os.name: 'Windows 8', os.arch: 'x86', os.version:
'6.2', java.version: '1.8.0_60' Driver info: driver.version:
ChromeDriver at
org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:178)
Can anyone tell me how can I run my selenium code on Chrome browser (without using the chromedriver.exe file) ?
I want to know how we can run selenium code on chrome using dependencies ?
You should remove the Chrome dependency from the pom.xml file and instead initialize the webdriver using below code :
System.setProperty("webdriver.chrome.driver","C:\\Users\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
You can download ther latest Chrome driver from http://www.seleniumhq.org/download .

Getting error while running selenium grid

When using my code:
DesiredCapabilities caps = new DesiredCapabilities(); DesiredCapabilities.chrome();
caps.setCapability(CapabilityType.BROWSER_NAME, "Firefox"); caps.setPlatform(Platform.WINDOWS);
caps.setCapability(FirefoxDriver.MARIONETTE, value);
WebDriver driver = new RemoteWebDriver(new URL("localhost:4444/wd/hub"), caps);
driver.get("google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("BrowserStack");
element.submit();
System.out.println(driver.getTitle());
driver.quit();
I am getting the following error:
Unable to create new remote session. desired capabilities = Capabilities [{platform=WINDOWS}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
In selenium console window, and in command prompt I got this error :
Unable to create new instances on this machine. 18:01:04.489 INFO - Driver class not found: com.opera.core.systems.OperaDriver 18:01:04.490 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
18:01:04.499 INFO - Driver provider org.openqa.selenium.safari.SafariDriver
registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=,
platform=MAC}] does not match the current platform VISTA
2017-01-06:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
... 1 more
18:01:11.703 WARN - Exception: The best matching driver provider
org.openqa.selenium.edge.EdgeDriver can't create a new driver instance for
Capabilities [{platform=WINDOWS}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19
-0700'
Could you please tell me where is the problem in my code?
You are setting chrome capabilities DesiredCapabilities.chrome(); and in next lines Firefox capabilites caps.setCapability(CapabilityType.BROWSER_NAME, "Firefox"); caps.setCapability(FirefoxDriver.MARIONETTE, value);
What driver do you even want to create?

Unable to create new remote session

How to resolve this issue. Earlier my code was working, but IE settings were reseted by someone. Now I am getting this exception.
Started InternetExplorerDriver server (32-bit)
2.53.1.0
Listening on port 16183
Only local connections are allowed
Oct 21, 2016 10:14:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Oct 21, 2016 10:14:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection
Oct 21, 2016 10:14:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}], required capabilities = null
Build info: version: 'unknown', revision: '3169782', time: '2016-09-29 10:24:50 -0700'
System info: host: 'BWT12654001', ip: '10.52.132.157', os.name: 'Windows Server 2008 R2', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_101'
Driver info: driver.version: InternetExplorerDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:80)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:602)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:228)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:180)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:172)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:144)
at mypackage.TestIEBrowser.main(TestIEBrowser.java:33)
This can work out of the box without the desired capability settings. Go to internet options>>Security, click on:'Reset all zones to default level and after that, ensure that the 'Enable protected mode' checkbox is ticked for all the four zones.
First, check your default zoom level in Internet Explorer. If it's not 100% then do the following steps:
Open Internet Explorer.
Press Alt + X and then click on Internet Options.
Click on the Advanced tab.
Place a check mark on "Reset Zoom level for new Windows and tab"
Press Apply and ok.
Close and open Internet Explorer window and check if the Default Zoom
is set to 100 %.
Once you have done with above steps, add following lines in your code:
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
Now run your program and it should work.
Hope it will help!!
The issue is discussed on Selenium project on Github
Here is the quote of the most relevant/informative part which helped me to solve the issue:
The good news is that it looks like the IE driver mostly works with IE11, provided
that (a) all security zones are set to the same Protected Mode setting and (b) Enhanced
Protected Mode is turned off. Note that the standard registry checks that the IE driver
uses to test for Protected Mode settings in IE7-10 are broken for IE11, and we've never
made any attempt to check for Enhanced Protected Mode, so there's no warning (yet)
if you don't have these settings properly set.
The bad news is that cookie manipulation is broken. Badly. If you attempt to set or
retrieve cookies, there's a chance that you'll end up with the "Unable to get browser"
error encountered before. At the moment, there is no workaround for that.
I had the same issue (in my case Firefox):
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=null}, version=, platform=ANY}], required capabilities = Capabilities [{moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=null}}]
Using Selenium driver 3.3.1:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.3.1</version>
</dependency>
And solved it via another version like 3.4+.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>

org.openqa.selenium.WebDriverException: Unable to bind to locking port 7054 within 45000 ms

I am facing issue while executing the selenium scripts in firefox browser.
Console Error:
org.openqa.selenium.WebDriverException: Unable to bind to locking port 7054 within 45000 ms
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'usnywqa01', ip: '10.3.3.20', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_17'
Driver info: driver.version: FirefoxDriver
Build info: version: '2.39.0', revision: '14fa800511cc5d66d426e08b0b2ab926c7ed7398', time: '2013-12-16 13:18:38'
System info: host: abc-PV-5', ip: 'XX.X.XX.XX', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_07'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.internal.SocketLock.lock(SocketLock.java:98)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:84)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:110)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:197)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:190)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:108)
at sun.reflect.GeneratedConstructorAccessor51.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:62)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:56)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:216)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:170)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I tried by changing selenium server to 2.35 or 2.39 and I upgraded ff to 26. But it doesnt work
When I degrade my ff version to 24, my scripts are working fine.
I would like to know why it is happened and root causes
I would like to know what is permanent solution for above 24 version of ff.
Please help me on this.
Seems like an issue with webdriver version. Can you try once with latest bindings i.e 2.40.0. To get more info on webdriver version and supported firefox version please go throgh webdriver release notes :http://selenium.googlecode.com/git/java/CHANGELOG
I had the same message before and I actually found out that the problem was the hosts file in my Mac (/private/etc/hosts). I don't know the reason but somehow it was pointing to an invalid IP in my network. Replacing the line for localhost pointing to 127.0.0.1 solved the problem for me. In resume, I was trying to access the Firefox in some other machine (odd!)
I had the same problem with the same output, i.e:
org.openqa.selenium.WebDriverException: Unable to bind to locking port 7054 within 45000 ms
I was using Selenium and Java in my project in Eclipse IDE and when I tried to run tests, firefox window opened, but nothing happened later (i.e. it was blank and couldn't catch the URL from my test).
Solution: I changed the version of the driver in my POM.xml file from 2.42.x to 2.43.1. I rebuilt my project and now it works fine.
Now my POM.xml file looks as follows:
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.43.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
Just try out the newest version of selenium driver or try to downgrade firefox (when you download firefox, it automatically downloads its latest version; some people claim that downgrading to older version may help).
Issue seems to be with Firefox latest version does not support web driver.
Was facing similar issue, used chrome driver instaed of Firefox and it worked.
When we download web driver and extract it to a folder, changelog file will be there, open it with notepad, supported Firefox version is mentioned. So we can successfully execute script on mentioned firefox version.

Resources