Selenium NoSuchMethodError

I am writing an automated test framework and have already written a significant amount. However, I ran into an error that I cannot fix or find a solution.

The problem arises when selenium tries to answer the date question and select from the date dropdown menu. I have been getting this many times with no problem, but for some reason I am getting the error as shown in the title. After trying to find a solution on google, I decided to come here because it seems like nothing like this happened.

The code where my automatic test breaks are:

new Select(driver.findElement(By.id("AMOUNT_OF_DHP_DATE_FROM_d"))).selectByVisibleText("4th");

new Select(driver.findElement(By.id("AMOUNT_OF_DHP_DATE_FROM_m"))).selectByIndex(4);
    driver.findElement(By.id("AMOUNT_OF_DHP_DATE_FROM_y")).sendKeys("2017");
    driver.findElement(By.id("AMOUNT_OF_DHP_WEEKLY")).sendKeys("50");

new  Select(driver.findElement(By.id("AMOUNT_OF_DHP_DATE_TO_d"))).getFirstSelectedOption();

new Select(driver.findElement(By.id("AMOUNT_OF_DHP_DATE_TO_m"))).getFirstSelectedOption();

driver.findElement(By.id("AMOUNT_OF_DHP_DATE_TO_y")).sendKeys("2017");
clickNext();

      

The error occurs on lines where the selectByVisibleText

and methods are used selectByIndex

. I've used these methods hundreds of times before, no problem. When I run the tests in the browser using the Selenium IDE, it runs without issue. But once the code is piped through Eclipse it doesn't work.

The only thing I can think of is that I converted the project from JUnit to TestNG .. Did this have any impact? I've done this before, but without any problem.

Any help would be greatly appreciated!

EDIT

StackTrace:

java.lang.NoSuchMethodError: org.openqa.selenium.WebElement.setSelected () V

at org.openqa.selenium.support.ui.Select.selectByVisibleText (Select.java:111)

at tns_automation.DHP_Forms.DhpAbstractTest.answerAmountOfDHPQuestion (DhpAbstractTest.java:348)

at tns_automation.DHP.KnowsleyDHPTest.completeAssessmentFormAndBudgetToolBeforeDownloadingPDFFromInTrayWithCookiesEnabled (KnowsleyDHPTest.java:62)

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: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:126)

at org.testng.remote.RemoteTestNG.initAndRun (RemoteTestNG.java:152)

at org.testng.remote.RemoteTestNG.main (RemoteTestNG.java:57)

+3


source to share


1 answer


This problem was solved by importing the latest selenium maven dependency in my pom.xml. I still don't understand why this problem came up as I have used it in other projects. Maven dependency to fix the problem:



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

      

+1


source







All Articles