Java.lang.NoSuchMethodError is throwing | Selenium Forum
20% Off Lockdown Learning Discount Avail now

Java.lang.NoSuchMethodError is throwing

N
Nibin K Mathew Post on 22/05/2020

Throwing the below error while executing the program, Attached the pom.xml file used to compile

Please help

 

FAILED: TestB
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:135)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:177)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:363)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:100)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:105)
at com.Demoproject.app.base.BaseTest.openBrowser(BaseTest.java:18)
at com.Demoproject.app.testcases.DummyTestB.TestB(DummyTestB.java:13)
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:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:744)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)


===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

package com.Demoproject.app.testcases;

import org.testng.annotations.Test;

import com.Demoproject.app.base.BaseTest;

public class DummyTestB extends BaseTest{

@Test

public void TestB() {

openBrowser("Mozilla");
navigate();
click();
Type();


}

}

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

package com.Demoproject.app.base;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class BaseTest {

public WebDriver driver;

public void openBrowser(String btype){

if(btype.equals("Mozilla"))
driver=new FirefoxDriver();
else if(btype.equals("Chrome")){
System.setProperty("webdriver.chrome.driver", "F:\\Selenium Repository\\Selenium Browser jars\\chromedriver.exe");
driver=new ChromeDriver();
}
else if(btype.equals("IE")){
driver=new InternetExplorerDriver();
}


}
public void navigate(){

}

public void click(){
}
public void Type(){
}
/*****************Validations***************************/
public boolean verifyTitle(){
return false;

}
public boolean isElementPresent(){
return false;
}

public boolean verifyText(){
return false;
}

/****************Reporting******************************/
public void reportPass(String msg){


}
public void reportFail(String msg){


}
public void takeScreenshot(){
}
}

N
Nibin K Mathew Reply on 25/05/2020

Any more info needed please let me know,I'm stuck here.

S

Instructor

Support Team 5 days go

Please use the stable version of selenium - 3.141.59

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.5</version>
</dependency>

N
Nibin K Mathew 5 days go

Yes it works.Thanks!!

Related Post