0

An issue with addextension from my file path directory, any idea what could have went wrong? ok this the complete exception stack trace. having add issues with chrome extension, it seems java.io.file is not working as expected. i tried run in a separate project folder so just to confirm my suspicion but the issue doesn't seems to go away

 FAILED: LaunchBrowserextension
java.lang.NoSuchMethodError: 'void org.openqa.selenium.chrome.ChromeOptions.addExtensions(java.io.File[])'
    at testpackage.addextension.LaunchBrowserextension(addextension.java:24)
    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:567)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.privateRun(TestRunner.java:648)
    at org.testng.TestRunner.run(TestRunner.java:505)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
    at org.testng.SuiteRunner.run(SuiteRunner.java:364)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
    at org.testng.TestNG.runSuites(TestNG.java:1049)
    at org.testng.TestNG.run(TestNG.java:1017)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

My full code

    import java.io.File;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.Test;


    public class addextension {

    @Test
    public void LaunchBrowserextension() throws InterruptedException
        WebDriver driver = new ChromeDriver();
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\User\\Desktop\\chromedriver.exe");
                ChromeOptions options = new ChromeOptions();
                options.addExtensions(new File("C:\\Users\\User\\Downloads\\abc\\Chrome.crx"));

                DesiredCapabilities capabilities = new DesiredCapabilities();
                capabilities.setCapability(ChromeOptions.CAPABILITY, options);
                ChromeDriver driver = new ChromeDriver(capabilities);

            System.out.println("Opening extension");
            driver.get("chrome-extension://mooikfkahbdckldjjndioackbalphokd/index.html");

            driver.navigate().refresh();
            System.out.println("Refresh successfully");

        }
    }
demon sky
  • 23
  • 2
  • 8
  • 1
    Does this answer your question? [How do I fix a NoSuchMethodError?](https://stackoverflow.com/questions/35186/how-do-i-fix-a-nosuchmethoderror) And also [How to get java.lang.NoSuchMethodError](https://stackoverflow.com/questions/6798767/how-to-get-java-lang-nosuchmethoderror) – kaweesha May 29 '20 at 04:40
  • i tried running the codes in a new class on a standalone project and still hitting same error results.hmm any idea why? – demon sky May 29 '20 at 05:15
  • main post updated – demon sky May 29 '20 at 05:20

0 Answers0