gpt4 book ai didi

java - 如何解决../selenium-server-standalone-3.141.59.jar无法驱动模块描述

转载 作者:行者123 更新时间:2023-12-02 09:34:41 25 4
gpt4 key购买 nike

引导层初始化时发生错误java.lang.module.FindException:无法派生 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");
}

}

}

image of source code and error

最佳答案

  1. 我建议重新考虑使用 Selenium Remote Control由于它是相当过时的方法,不再受支持,Selenium Java 客户端的当前稳定版本是 3.141.59它提供WebDriver API这是 W3C Standard截至目前。
  2. 实现选项 1 后,删除那些 Thread.sleep()因为它是某种形式的表演anti-pattern ,去Explicit Wait相反,请查看 How to use Selenium to test web applications using AJAX technology以获得全面的解释和代码示例。

  3. 最好使用依赖管理解决方案,例如 Apache Maven它将自动检测并下载您的项目 transitive dependencies 。相关的 pom.xml 文件类似于:

    <?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>

关于java - 如何解决../selenium-server-standalone-3.141.59.jar无法驱动模块描述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57631195/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com