I want to execute test in several computers or VM's but the execution gives me the SessionNotCreatedExeption, I'm thinking that's because of the node couldn't find the driver
according to documentation from selenium grid I just created my nodes with the following command
java -jar selenium-server-4.8.0.jar node --hub http://<hostIP>:4444
Currently I wanted to run test with Firefox
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
public class ParallelTest {
private WebDriver driver;
#BeforeMethod
public void setUp() throws MalformedURLException {
if(driver == null) {
String cloudUrl = "http://localhost:4444/wd/hub";
System.setProperty("webdriver.firefox.marionette", "C:\\SeleniumHub4\\geckodriver.exe");
FirefoxOptions browserOptions = new FirefoxOptions();
driver = new RemoteWebDriver(new URL(cloudUrl), browserOptions);
}
}
#Test
public void test1() {
driver.get("https://www.google.com");
Date fecha = new Date();
System.out.println(fecha + " Test 1 executed on: " + ((RemoteWebDriver) driver).getCapabilities().getBrowserName());
}
#Test
public void test2() {
driver.get("https://www.facebook.com");
Date fecha = new Date();
System.out.println(fecha + " Test 2 executed on: " + ((RemoteWebDriver) driver).getCapabilities().getBrowserName());
}
#AfterSuite
public void tearDown() {
driver.quit();
driver = null;
}
}
And this is the output of my console
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: Could not start a new session. Could not start a new session. Error while creating session with the driver service. Stopping driver service: Timed out waiting for driver process to start.
Build info: version: '4.8.0', revision: '267030adea'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_361'
Driver info: driver.version: unknown
Host info: host: 'hostName', ip: 'hostIP'
Build info: version: '4.8.0', revision: '267030adea'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_361'
Driver info: driver.version: unknown
Build info: version: '4.8.0', revision: '267030adea'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.16'
Driver info: driver.version: unknown
Build info: version: '4.8.0', revision: '267030adea'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.13'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [null, newSession {capabilities=[Capabilities {acceptInsecureCerts: true, browserName: firefox, moz:debuggerAddress: true, moz:firefoxOptions: {}}], desiredCapabilities=Capabilities {acceptInsecureCerts: true, browserName: firefox, moz:debuggerAddress: true, moz:firefoxOptions: {}}}]
Capabilities {} at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:148)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:106)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:229)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at ParallelTest.setUp(ParallelTest.java:28)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:69)
at org.testng.internal.invokers.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:361)
at org.testng.internal.invokers.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:296)
at org.testng.internal.invokers.TestInvoker.runConfigMethods(TestInvoker.java:823)
at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:590)
at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:221)
at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:969)
at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)
at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: Could not start a new session. Could not start a new session. Error while creating session with the driver service. Stopping driver service: Timed out waiting for driver process to start.
Build info: version: '4.8.0', revision: '267030adea'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_361'
Driver info: driver.version: unknown
Host info: host: 'hostName', ip: 'hostIP'
Build info: version: '4.8.0', revision: '267030adea'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_361'
Driver info: driver.version: unknown
Build info: version: '4.8.0', revision: '267030adea'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.16'
Driver info: driver.version: unknown
Build info: version: '4.8.0', revision: '267030adea'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.13'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [null, newSession {capabilities=[Capabilities {acceptInsecureCerts: true, browserName: firefox, moz:debuggerAddress: true, moz:firefoxOptions: {}}], desiredCapabilities=Capabilities {acceptInsecureCerts: true, browserName: firefox, moz:debuggerAddress: true, moz:firefoxOptions: {}}}]
Capabilities {} at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:148)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:106)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:229)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at ParallelTest.setUp(ParallelTest.java:28)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:69)
at org.testng.internal.invokers.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:361)
at org.testng.internal.invokers.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:296)
at org.testng.internal.invokers.TestInvoker.runConfigMethods(TestInvoker.java:823)
at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:590)
at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:221)
at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:969)
at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)
at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829) Feb 16, 2023 11:16:46 AM org.openqa.selenium.remote.tracing.opentelemetry.OpenTelemetryTracer createTracer
INFO: Using OpenTelemetry for tracing Test ignored. Test ignored. ===============================================
Parallel test suite
Total tests run: 2, Passes: 0, Failures: 0, Skips: 2
Configuration Failures: 2, Skips: 1
===============================================
Process finished with exit code 0
The thing was that I was using the incorrect driver, the thing was that I was using version 0.32.2 but unfortunately for this version there is no geckodriver for win64 so I downloaded win-aarch64 driver
So at the end only had to downgrade to the 0.32.1 version and that was my solution
Lesson be sure you're getting the right driver before posting here in Stack Overflow.
Related
I am trying to launch chrome using selenium standalone by using below command
java -Dwebdriver.chrome.driver=chromedriver-new.exe -jar selenium-server.jar standalone --host 127.0.0.1 --port 4444
However when I am triggering my webdriverio test for chrome, it momentarily opens chrome and the it crashes with below error
{"traceId": "faca75a3db657eed4b96bdac93977746","eventTime": 1637343152240678600,"eventName": "exception","attributes": {"driver.url": "http:\u002f\u002flocalhost:57786","exception.message": "Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: session not created\nfrom tab crashed\n (Session info: chrome=96.0.4664.45)\nBuild info: version: '4.0.0', revision: '3a21814679'\nSystem info: host: '', ip: '192.168.0.11', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_311'\nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created\nfrom tab crashed\n (Session info: chrome=96.0.4664.45)\nBuild info: version: '4.0.0', revision: '3a21814679'\nSystem info: host: '', ip: '192.168.0.11', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_311'\nDriver info: driver.version: unknown\r\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)\r\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:84)\r\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:62)\r\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:131)\r\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:65)\r\n\tat org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:143)\r\n\tat org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:315)\r\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession(LocalDistributor.java:513)\r\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:440)\r\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest(LocalDistributor.java:648)\r\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1(LocalDistributor.java:612)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\r\n\tat java.lang.Thread.run(Unknown Source)\r\n","exception.type": "org.openqa.selenium.SessionNotCreatedException","logger": "org.openqa.selenium.grid.node.config.DriverServiceSessionFactory","session.capabilities": "{"acceptInsecureCerts": true,"browserName": "chrome","goog:chromeOptions": {"args": [ "--disable-gpu" ] } }\n"}}
It worked by adding '--no-sandbox' in chrome options.
import org.apache.xpath.operations.String;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class First {
public static void main(String[] args)
{
WebDriver driver=new FirefoxDriver();
driver.get("www.facebook.com");
driver.manage().window().maximize();
}
}
I am getting this error when I am trying to run it in Eclipse Kepler:
Exception in thread "main" org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
Command duration or timeout: 18 milliseconds
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:17:10'
System info: host: 'Jyoti-PC', ip: '192.168.112.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_40'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=37.0.1, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: a35eb217-b3b2-4de8-abc2-4e72ceb06916
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:306)
at first.main(first.java:10)
Caused by: org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:17:10'
System info: host: 'Jyoti-PC', ip: '192.168.112.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_40'
Driver info: driver.version: unknown
at .FirefoxDriver.prototype.get(file:///C:/Users/Jyoti/AppData/Local/Temp/anonymous573077067589922398webdriver-profile/extensions/fxdriver#googlecode.com/components/driver-component.js:10160)
at .DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/Jyoti/AppData/Local/Temp/anonymous573077067589922398webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12282)
at .DelayedCommand.prototype.executeInternal_(file:///C:/Users/Jyoti/AppData/Local/Temp/anonymous573077067589922398webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12287)
at .DelayedCommand.prototype.execute/<(file:///C:/Users/Jyoti/AppData/Local/Temp/anonymous573077067589922398webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12229)
Exception in thread "main" org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
This exception happens because you are trying to get() a URL that's not prefixed with http:// or https://
driver.get("https://www.facebook.com");
package javaapplication3;
import java.lang.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;
/**
*
* #author kipl74
*/
public class JavaApplication3 {
/**
* #param args the command line arguments
*/
static WebDriver driver = new FirefoxDriver();
public static void main(String[] args) {
// TODO code application logic here
String baseurl="www.google.com";
driver.get(baseurl);
}
}
When I run this code, I am getting following errors. How to resolve it?
Exception in thread "main" org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
Command duration or timeout: 16 milliseconds
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: 'comp74', ip: '192.168.0.74', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_17'
Session ID: 0282db64-b28b-4c3b-ba83-26fe06bd46a3
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, browserConnectionEnabled=true, webStorageEnabled=true, nativeEvents=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=26.0}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:276)
at javaapplication3.JavaApplication3.main(JavaApplication3.java:23)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: f.QueryInterface is not a function
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: 'comp74', ip: '192.168.0.74', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_17'
Driver info: driver.version: unknown
at <anonymous class>.FirefoxDriver.prototype.get(file:///C:/Users/kipl74/AppData/Local/Temp/anonymous2500892407184382634webdriver-profile/extensions/fxdriver#googlecode.com/components/driver_component.js:8720)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/kipl74/AppData/Local/Temp/anonymous2500892407184382634webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:10831)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/kipl74/AppData/Local/Temp/anonymous2500892407184382634webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:10836)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/kipl74/AppData/Local/Temp/anonymous2500892407184382634webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:10778)
Java Result: 1
Method get requires the protocol as part of the URL.
Change:
String baseurl = "www.google.com";
To:
String baseurl = "http://www.google.com";
Please check your calling method to open the browser. I believe you have written code like this:
driver.get("Url"); //Incorrect Code
Correct should be like:
driver.get(Url);// Correct Code
package wait1;
import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Explicit {
public static void main(String[] args) {
FirefoxDriver driver= new FirefoxDriver();
WebDriverWait wait= new WebDriverWait(driver,20 );
driver.get("http://www.91mobiles.com/");
driver.findElement(By.xpath("//*[#id='q']")).sendKeys("Micromax");
//wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[#id='ui-id-22']/span[2]")));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("id=ui-id-172")));
driver.findElement(By.xpath("//*[#id='ui-id-52']")).click();
}
}
I am getting the following error when I execute the above script:
Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 20 seconds waiting for visibility of element located by By.id: id=ui-id-172
Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:33:32'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_25'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:259)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:228)
at wait1.Explicit.main(Explicit.java:20)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"id=ui-id-172"}
Command duration or timeout: 21 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:33:32'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_25'
Session ID: fd977506-2457-4981-a304-f9a9b6b57f4e
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=17.0.7}]
at sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:191)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:307)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:348)
at org.openqa.selenium.By$ById.findElement(By.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:299)
at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:522)
at org.openqa.selenium.support.ui.ExpectedConditions.access$0(ExpectedConditions.java:520)
at org.openqa.selenium.support.ui.ExpectedConditions$4.apply(ExpectedConditions.java:130)
at org.openqa.selenium.support.ui.ExpectedConditions$4.apply(ExpectedConditions.java:1)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208)
... 1 more
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Unable to locate element: {"method":"id","selector":"id=ui-id-172"}
Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:33:32'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_25'
Driver info: driver.version: unknown
The behavior you are getting is the expected bahavior. You specified a 20 second explicit wait and in that time the ExpectedConditions.visibilityOfElementLocated(...) could not be established. So the wait fails with a timeout.
If you want to go on in your program you need to surround the wait in a try-catch block and catch org.openqa.selenium.TimeoutException
Try using like this
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[#id='ui-id-52']"));
Make sure that whatever identification type you use while waiting should be in the statement you use for action. (e.g. click, set etc.)
Here, we have two solutions...
Try increasing your WebDriverWait time to check if it fix the issue.
Try to locate same element by firebug, if it is successfully found by firebug, than WebDriverWait time is the only culprit.
You'll always get a timeout with the code you have. This is the offending line:
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("id=ui-id-172")));
Note how you have By.id("id=ui-id-172"). This is wrong. It would look for an object that has the id id=ui-id-172. While it is possible to have an id with this value (yes, I tried and it works) it is unlikely that this is what you want, especially given your XPath expression on the next line. What you want, to be consistent with the rest of your code, is By.id("ui-id-172").
I am using WebDriverBackedSelenium for the automated testing of a website but my code is working fine for the chrome and firefox but problem in IE
Code is
WebDriver driver = new ChromeDriver();
String baseUrl = "https://mywebsite.com/";
selenium = new WebDriverBackedSelenium(driver, baseUrl);
selenium.fireEvent("//td[#id='skin_container_logoff']/a/table/tbody/tr/td[2]", "click");
This line give the below error
com.thoughtworks.selenium.SeleniumException: JavaScript error (WARNING: The server did not
provide any stacktrace information) Command duration or timeout: 125 milliseconds Build info:
version: '2.18.0', revision: '15704', time: '2012-01-27 15:48:16' System info: os.name: '
Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_24' Driver info:
driver.version: EventFiringWebDriver Command duration or timeout: 735 milliseconds Build info:
version: '2.18.0', revision: '15704', time: '2012-01-27 15:49:22' System info: os.name:
'Linux', os.arch: 'amd64', os.version: '2.6.32-131.2.1.el6.x86_64', java.version: '1.6.0_26-
rev' Driver info: driver.version: RemoteWebDriver at
org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:42)
at org.openqa.selenium.internal.seleniumemulation.Timer.run(Timer.java:39) at
org.openqa.selenium.WebDriverCommandProcessor.execute(WebDriverCommandProcessor.java:145) at
org.openqa.selenium.WebDriverCommandProcessor.doCommand(WebDriverCommandProcessor.java:75) at
com.thoughtworks.selenium.DefaultSelenium.fireEvent(DefaultSelenium.java:210) at
com.example.tests.WebDriverBackedSeleniumEx.fireEvent(WebDriverBackedSeleniumEx.java:103) at
com.example.tests.LoginAdvanceIE.testLoginIE(LoginAdvanceIE.java:48) at
com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:230) Caused by:
org.openqa.selenium.WebDriverException: JavaScript error (WARNING: The server did not provide
any stacktrace information) Command duration or timeout: 125 milliseconds Build info: version:
'2.18.0', revision: '15704', time: '2012-01-27 15:48:16' System info: os.name: 'Windows 7',
os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_24' Driver info: driver.version:
EventFiringWebDriver Command duration or timeout: 735 milliseconds Build info: version:
'2.18.0', revision: '15704', time: '2012-01-27 15:49:22' System info: os.name: 'Linux', os.arch:
'amd64', os.version: '2.6.32-131.2.1.el6.x86_64', java.version: '1.6.0_26-rev' Driver info:
driver.version: RemoteWebDriver at
java.lang.reflect.Constructor.newInstance(Constructor.java:513) at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147) at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113) at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:439) at
org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:353) at
org.openqa.selenium.internal.seleniumemulation.JavascriptLibrary.executeScript(JavascriptLibrary.java
:88) at
org.openqa.selenium.internal.seleniumemulation.FireEvent.handleSeleneseCommand(FireEvent.java:38)
at
org.openqa.selenium.internal.seleniumemulation.FireEvent.handleSeleneseCommand(FireEvent.java:1)
at org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:36)
Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken Build info:
version: '2.18.0', revision: '15704', time: '2012-01-27 15:49:22' System info: os.name: 'Linux',
os.arch: 'amd64', os.version: '2.6.32-131.2.1.el6.x86_64', java.version: '1.6.0_26-rev' Driver
info: driver.version: RemoteWebDriver at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:101) Caused by:
org.openqa.selenium.WebDriverException: JavaScript error (WARNING: The server did not provide any
stacktrace information) Command duration or timeout: 125 milliseconds Build info: version:
'2.18.0', revision: '15704', time: '2012-01-27 15:48:16' System info: os.name: 'Windows 7',
os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_24' Driver info: driver.version: Even
tFiringWebDriver Build info: version: '2.18.0', revision: '15704', time: '2012-01-27 15:49:22'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-131.2.1.el6.x86_64',
java.version: '1.6.0_26-rev' Driver info: driver.version: EventFiringWebDriver at
java.lang.reflect.Constructor.newInstance(Unknown Source) at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147) at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113) at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:439) at
org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:353) at
org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:100) at
$Proxy2.executeScript(Unknown Source) at
org.openqa.selenium.support.events.EventFiringWebDriver.executeScript(EventFiringWebDriver.java:208)
at org.openqa.selenium.remote.server.handler.ExecuteScript.call(ExecuteScript.java:54) at
org.openqa.selenium.remote.server.handler.ExecuteScript.call(ExecuteScript.java:1) at
java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at
java.util.concurrent.FutureTask.run(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown
Source)
I tried the WebDriverWait but I am still getting the error.
I am not sure if this is the problem, but try specifying javascript timeout manually:
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);