I am using Selenium 2.53.0 and Firefox version is 46.0.1.
Please find the code below which i am running from Ant :
#Test
public void Browser() {
// Luanching Firefox browser
FirefoxDriver driver=new FirefoxDriver();
driver.get("http://flipkart.com");
driver.quit();
}
Note:
If I run the code from eclipse working as expected without any issues. But if I run the same code from Ant using Build.xml, I am getting below error:
**org.openqa.selenium.WebDriverException: org.openqa.selenium.WebDriverException: Unable to bind to locking port 7054 within45000 ms**
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_111'
Driver info: driver.version: firefox
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_111'
Driver info: driver.version: firefox
at org.openqa.selenium.firefox.internal.ExtensionConnectionFactory.connectTo(ExtensionConnectionFactory.java:46) at org.openqa.selenium.firefox.FirefoxDriver.connectTo(FirefoxDriver.java:139)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:129)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:109)
at test.NewTest.Browser(NewTest.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.Met
Please suggest a solution how to resolve above mentioned issue ?
Related
I'm using Selenium 4.6.0 and trying to create a simple test to run and below is the code I'm using
private static WebDriver driver;
dc.setBrowserName("chrome");
driver=new RemoteWebDriver(new URL(remoteURL), dc);
Chrome driver version: 107.0.5304.62
Chrome version: 107.0.5304.122
Chrome driver is compatible with the browser version. I have used both http://localhost:4444 and the http://192...**:4444 but both run into the same exception
Exception
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Host info: host: 'RAM', ip: '192.***.**.***'
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_333'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome}], desiredCapabilities=Capabilities {browserName: chrome}}]
Capabilities {}
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:559)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at framework.maincontroller.MainController.createDriver(MainController.java:2472)
at framework.maincontroller.MainController.setUp(MainController.java:2851)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:385)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:321)
at org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:700)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:527)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:824)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)
Caused by: java.lang.NoSuchMethodError: com.google.common.collect.ImmutableMap.of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableMap;
at org.openqa.selenium.chrome.AddHasCasting.getAdditionalCommands(AddHasCasting.java:38)
at org.openqa.selenium.remote.Dialect.lambda$bindAdditionalCommands$1(Dialect.java:80)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.openqa.selenium.remote.Dialect.bindAdditionalCommands(Dialect.java:79)
at org.openqa.selenium.remote.Dialect.access$100(Dialect.java:29)
at org.openqa.selenium.remote.Dialect$2.getCommandCodec(Dialect.java:54)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at
org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:541)
... 24 more
I've been trying to open tabs in browsers via Selenium and seems to work on all except Safari.
I'm trying the following:
public void openNewTab(String url) {
((JavascriptExecutor) getWebDriver()).executeScript("window.open('" + url + "','_blank');");
}
I've seen some answers in other languages to pass the --legacy argument but not an equivalent for Java.
Any hints?
Update
Some related answers include:
Request body does not contain required parameter 'handle'
Here's the error I'm getting when trying the code on the following OS via SauceLabs:
Mac 10.13
Mac 10.14
iPad Pro (12.9 inch) Simulator
org.openqa.selenium.InvalidArgumentException: Request body does not contain required parameter 'handle'.
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z'
System info: host: 'itako4501.prod.miso', ip: 'fe80:0:0:0:ca0:e26a:55bf:fecd%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14', java.version: '9.0.4'
Driver info: driver.version: unknown
Command duration or timeout: 0 milliseconds
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:903)
Caused by: org.openqa.selenium.InvalidArgumentException: Request body does not contain required parameter 'handle'.
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z'
System info: host: 'itako4501.prod.miso', ip: 'fe80:0:0:0:ca0:e26a:55bf:fecd%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14', java.version: '9.0.4'
Driver info: driver.version: unknown
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'x-r', ip: 'fe80:0:0:0:4ac:2f6c:527b:c271%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '11.0.3'
Driver info: driver.version: unknown
This will open a new tab. tried on MacOs Mojave safari Version 12.1.2 (14607.3.9)
driver.get("http://google.com");
((JavascriptExecutor) driver).executeScript("window.open('http://cnn.com','_blank');");
When I use a proxy with ChromeDriver I have Class Cast Exception.
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
if (!Context.getProxy().isEmpty()) {
Proxy proxy = new Proxy();
proxy.setHttpProxy(Context.getProxy());
capabilities.setCapability(CapabilityType.PROXY, proxy);
}
System.setProperty(Driver.CHROME.getDriverName(), pathWebdriver);
return new ChromeDriver(capabilities);
if Context.getProxy().isEmpty() = true, I Web driver is ok, but if I Set a proxy I have this error:
org.openqa.selenium.WebDriverException: Unable to convert: Capabilities [{ensureCleanSession=true, proxy=Proxy(manual, http=renn.proxy.corp.xxxx:8080), loggingPrefs=org.openqa.selenium.logging.LoggingPreferences#5df041, browserName=chrome, version=, platform=ANY, unexpectedAlertBehaviour=accept}]
at org.openqa.selenium.remote.BeanToJsonConverter.convert(BeanToJsonConverter.java:69)
...
...
Caused by: org.openqa.selenium.WebDriverException: Unable to convert: Capabilities [{ensureCleanSession=true, proxy=Proxy(manual, http=renn.proxy.corp.xxxx:8080), loggingPrefs=org.openqa.selenium.logging.LoggingPreferences#5df041, browserName=chrome, version=, platform=ANY, unexpectedAlertBehaviour=accept}]
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'ITEM-72885', ip: '192.168.84.9', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_66'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:88)
at org.openqa.selenium.remote.BeanToJsonConverter.convert(BeanToJsonConverter.java:66)
... 84 more
Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to java.lang.String
at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:223)
at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:143)
at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:189)
at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:86)
... 85 more
Problem resolved when I upgraded the driver version.
I have written a very basic script to just login to an application and logout. The script stop working as soon as it logs in to the application and an exception is given and I cant figure out the reason for this. This is the script.
public class Login {
WebDriver driver = new FirefoxDriver();
String url = "http://xxxxxxxxx";
#Test
public void login_class() {
driver.get(url + "/Web/guest/login.aspx");
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.id("txtUserName")).clear();
driver.findElement(By.id("txtUserName")).sendKeys("xxxxx#gmc.com");
driver.findElement(By.id("txtPassword")).clear();
driver.findElement(By.id("txtPassword")).sendKeys("xxxxx123");
driver.findElement(By.id("btnLogin")).click();
driver.get(url + "Web/guest/home/default.aspx");
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(
By.cssSelector("span.menu-icons-sprite.menu-icon-signout"))
.click();
}
#BeforeTest
public void create_driver() {
driver.get(url);
driver.manage().window().maximize();
}
#AfterTest
public void exit() {
driver.quit();
}
}
And the exception given is followed
FAILED: login_class
org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
Command duration or timeout: 5.10 seconds
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
System info: host: 'xxxxx-PC', ip: '10.0.0.192', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_45'
Session ID: 1e311cd0-34d1-4dd2-9cde-e52cbb9fb52e
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=WINDOWS, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, nativeEvents=false, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=42.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:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:311)
at bileetaTest.Login.login_class(Login.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:112)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:176)
Caused by: org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
System info: host: 'xxxx-PC', ip: 'xxxxxxx', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_45'
Driver info: driver.version: unknown
at .FirefoxDriver.prototype.get(file:///C:/Users/xxxxxx/AppData/Local/Temp/anonymous3548365288572112291webdriver-profile/extensions/fxdriver#googlecode.com/components/driver-component.js:10523)
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
The issue was I have to add another "/" before the Path I had provided.
I am seeing this exception when launching Chrome Browser using RemoteWebDriver.
I have tried getting the latest versions of selenium server and chromedriver, but with no luck.
I seem to run out of ides.
Has anyone encountered this error and has found a solution.
12:48:18.012 INFO - Registering the node to hub :http://mydomain:4444/grid/regi
ster
12:50:38.741 INFO - Executing: [new session: {platform=ANY, browserName=chrome,
chromeOptions={args=[--user-data-dir=C:\Use..., version=}] at URL: /session)
12:50:38.771 INFO - Creating a new session for Capabilities [{platform=ANY, brow
serName=chrome, chromeOptions={args=[--user-data-dir=C:\Users\vidder\AppData\Loc
al\Vidder_Inc\SDP Browser\userdata, --start-maximized --profile-directory=Defaul
t], extensions=[]}, version=}]
Starting ChromeDriver (v2.4.226107) on port 29990
12:51:00.234 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException:
java.lang.reflect.InvocationTargetException
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info: host: 'vidder-PC3', ip: '10.10.104.69', os.name: 'Windows 7', os.ar
ch: 'amd64', os.version: '6.1', java.version: '1.7.0_15'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSessi
on.java:176)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSessio
n.java:112)
at org.openqa.selenium.remote.server.DefaultSession.createSession(Defaul
tSession.java:89)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(De
faultDriverSessions.java:104)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSessio
n.java:63)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConf
ig.java:205)
at org.openqa.selenium.remote.server.JsonHttpRemoteConfig.handleRequest(
JsonHttpRemoteConfig.java:192)
at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverS
ervlet.java:201)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.
java:167)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet
.java:139)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.jav
a:428)
at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler
.java:677)
at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.j
ava:568)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:914)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:9
86)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.
java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationT
argetException
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info: host: 'vidder-PC3', ip: '10.10.104.69', os.name: 'Windows 7', os.ar
ch: 'amd64', os.version: '6.1', java.version: '1.7.0_15'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructo
r(DefaultDriverFactory.java:72)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(De
faultDriverFactory.java:56)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(
DefaultSession.java:215)
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:169)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructo
r(DefaultDriverFactory.java:62)
... 9 more
Caused by: org.openqa.selenium.WebDriverException: unknown error: Chrome failed
to start: exited normally