gpt4 book ai didi

java - Java程序中的"driver cannot be resolved"

转载 作者:行者123 更新时间:2023-12-02 10:14:14 24 4
gpt4 key购买 nike

我是编程世界的新手,所以我不知道如何解决这个问题。

`@Test
public void LoginEmail() {

driver.findElement(By.id("email_button")).sendKeys("xxxxxxxx@gmail.com");`

在 driver.findElement 处,驱动程序带有红色下划线。当我将鼠标悬停在它上面时,这些就是我的选择。

无法复制选项,所以我截图了:

Couldn't copy the options, so I took a screenshot

最佳答案

你应该先初始化它:

 try {
WebDriver driver = new AndroidDriver();

// And now use this to visit Google
driver.get("http://www.google.com");

// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));

// Enter something to search for
element.sendKeys("Cheese!");

// Now submit the form. WebDriver will find the form for us from the element
element.submit();

// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
} catch (Exception e) {
e.printStackTrace();
}

关于java - Java程序中的"driver cannot be resolved",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54787045/

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