Chrome is not getting launched when code is executedfrom ANT | Selenium Forum
M
Posted on 10/12/2016
Softwares Version
Eclipse 4.5.0
JDK 1.8.0
JRE 1.8.0
Selenium 2.53.0
TestNG 6.9.9
Chorme 54.0

Not able to run below code from Ant getting "java.lang.NoSuchMethodError: org.openqa.selenium.remote.DesiredCapabilities.setCapability"

Note: When i run code directly from eclipse, able to launch chrome successfully.

Please guide me how to launch chrome from Ant/Build.xml when code is written in TestNg.


code :
@Test
public void Browser() {

System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
ChromeDriver driver=new ChromeDriver();
driver.get("http://flipkart.com");
//driver.quit();

Error trace :
java.lang.NoSuchMethodError: org.openqa.selenium.remote.DesiredCapabilities.setCapability(Ljava/lang/String;Ljava/lang/Object;)V
at org.openqa.selenium.chrome.ChromeOptions.toCapabilities(ChromeOptions.java:236)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
at test.NewTest.Browser(NewTest.java:12)
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.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.TestNG.privateMain(TestNG.java:1355)
at org.testng.TestNG.main(TestNG.java:1324)

M
Replied on 11/12/2016

Please make sure you have included all jars for selenium
Also install chrome again


M
Replied on 12/12/2016

Please find the list of jars i have added to my project to launch Chrome in the attachment.

Please guide me how to resolve this issue

Responsive image

M
Replied on 13/12/2016

Please install chrome again


M
Replied on 14/12/2016

Sir,

Now am using all the jars provided by you. I have downloaded all the jars from "Download Code" .

Selenium Version : 2.53
Chrome : 55.0

Note: I have kept chromedriver in D drive (D:\chromedriver_win32\chromedriver.exe)

Now am getting following error :

[color=#FF0040:12sjry8e]org.openqa.selenium.WebDriverException: java.io.IOException:[/color:12sjry8e] Cannot run program "C:\Users\Pavan\Local Settings\Application
Data\Google\Chrome\Application\chrome.exe":
CreateProcess error=2, The system cannot find the file specified
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_111'
Driver info: driver.version: chrome
at org.openqa.selenium.chrome.ChromeBinary.start(ChromeBinary.java:55)
at org.openqa.selenium.chrome.ChromeDriver.startClient(ChromeDriver.java:75)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:50)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:60)
at test.NewTest.Browser(NewTest.java:12)
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.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:673)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.runWorkers(TestRunner.java:1125)
at org.testng.TestRunner.privateRun(TestRunner.java:749)
at org.testng.TestRunner.run(TestRunner.java:600)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
at org.testng.SuiteRunner.run(SuiteRunner.java:223)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:965)
at org.testng.TestNG.runSuitesLocally(TestNG.java:890)
at org.testng.TestNG.run(TestNG.java:824)
at org.testng.TestNG.privateMain(TestNG.java:1128)
at org.testng.TestNG.main(TestNG.java:1092)
Caused by: java.io.IOException: Cannot run program "C:\Users\Pavan\Local Settings\Application Data\Google\Chrome\Application\chrome.exe":
CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at org.openqa.selenium.chrome.ChromeBinary.start(ChromeBinary.java:41)
... 28 more
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 30 more


M
Replied on 15/12/2016

Sir,
Please suggest the solution to resolve the issue.


M
Replied on 18/12/2016

try this github forum.
https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/265