简体   繁体   中英

How to solve unable to drive module description for ../selenium-server-standalone-3.141.59.jar

Error occurred during initialization of boot layer java.lang.module.FindException: Unable to derive module descriptor for C:\\Users\\admin\\eclipse-workspace\\Testing\\lib\\selenium-server-standalone.jar

Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.eclipse.jetty.http.Http1FieldPreEncoder not in module
package Testing;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

public class Testing {

    public static void main(String[] args) throws InterruptedException
    {
        Selenium selenium= new DefaultSelenium("localhost",4444,"firefox","http://www.calculator.net");
        selenium.start();
        selenium.open("/");
        selenium.windowMaximize();
        selenium.click("xpath=.//*[@id=''hl3']/li[3]/a"); 
        Thread.sleep(4000);
        selenium.focus("id=cpar1");
         selenium.type("css=input[id=\"cpar1\"]", "10"); 
        selenium.focus("id=cpar2"); 
         selenium.type("css=input[id=\"cpar2\"]", "50"); 
         (selenium).click("xpath=.//*[@id='content']/table[1]/tbody/tr[2]/td/input[2]"); 
         // verify if the result is 5
         Thread.sleep(4000);
         String result = selenium.getText("xpath=.//*[@id='content']/p[2]/font/b");
         //String result = selenium.getValue("xpath=.//*[@id='cpar3']");
         System.out.println("Result:"+result);

         if (result.equals("5")/*== "5"*/){
            System.out.println("Pass");
         }
         else{
            System.out.println("Fail");
         }

    }

}

源代码和错误的图像

  1. I would recommend reconsidering using Selenium Remote Control as it is quite outdated approach which is no longer supported, current stable version of Selenium Java client is 3.141.59 and it provides WebDriver API which is a W3C Standard as of now.
  2. Once you implement option 1 get rid of those Thread.sleep() as it's a some form of a performance anti-pattern , go for Explicit Wait instead, check out How to use Selenium to test web applications using AJAX technology for comprehensive explanation and code examples.

  3. It's better to use a dependency management solution like Apache Maven which will automatically detect and download your project transitive dependencies . A relevant pom.xml file would be something like:

     <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>selenium</artifactId> <version>1.0-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>8</source> <target>8</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.141.59</version> </dependency> </dependencies> </project> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM