“驱动无法解析"在 Java 程序中 [英] "driver cannot be resolved" in Java program
本文介绍了“驱动无法解析"在 Java 程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是编程界的新手,所以我不知道如何解决这个问题.
I'm new to the programming world so I wouldn't know how to fix this.
`@Test
public void LoginEmail() {
driver.findElement(By.id("email_button")).sendKeys("xxxxxxxx@gmail.com");`
在 driver.findElement 中,驱动程序带有红色下划线.当我将鼠标悬停在它上面时,这些就是我的选择.
At driver.findElement , driver is underlined red. When I hover over it these are my options.
无法复制选项,所以我截屏了:
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 程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文