java - Selenium 脚本启动层初始化期间显示错误

标签 java selenium

我是 Selenium 的新手。使用 eclipse 运行我的第一个测试用例,但在运行代码时出现以下错误。

 Error occurred during initialization of boot layer
    java.lang.module.FindException: Unable to derive module descriptor for C:\selenium-server-standalone-3.9.0.jar
    Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.apache.bsf.BSFManager not in module

我已经在我的项目中导入了 selenium-server-3.9.0、selenium-server-standalone-3.9.0 和 bsf-2.4.0 jar 文件。

这是我在 eclipse 上运行的代码:

package Automation;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Testing {
    public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver", "C:\\chromedriver_win32.exe");

        WebDriver driver = new ChromeDriver();
        driver.get("http://www.gmail.com");
        driver.manage().window().maximize();
        driver.manage().deleteAllCookies();
        driver.findElement(By.id("identifierId")).sendKeys("guptasakshi34@gmail.com");
        driver.findElement(By.className("RveJvd snByac")).click();
        String at = driver.getTitle();
        String et = "gmail";
        driver.close();
        if(at.equalsIgnoreCase(et))
        {
            System.out.println("Test Successful");

        }
        else
        {
            System.out.println("Test Failue");
        }

    }

}

最佳答案

我认为问题可能是您导入了 Selenium 服务器和独立服务器。您需要选择其中之一(我更喜欢独立服务器,因为 Selenium 服务器要求您记住执行以下操作

webdriver-manager start

及相关命令。独立服务器只需在您的exports.config 文件中指定即可,您无需担心它。

关于java - Selenium 脚本启动层初始化期间显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54849743/

相关文章:

java - 是否可以像在 Java 中那样访问 C++ 中的静态成员类?

java - 如何将 jTextPane 中的整个(突出显示或不突出显示)文本设置为正常?

java - 在WebDriver中,是否可以获取不可见标签的内容?

java - 有没有办法让 gecko.driver 可供共享代码中的每个人使用?

python - 如何使用 Selenium WebDriver 提取文本输入中输入的文本?

python - 获取 XKCD 图像的 src 链接?

python - 带有 Selenium 错误 : Message: 'phantomjs' executable needs to be in PATH 的 PhantomJS

java - 删除特定子字符串之前的空格

java - 你如何找到 0 和 1 的二维矩阵中的矩形数?

java - 如何将文本值存入数组?