首页 > 解决方案 > Java程序中的“驱动程序无法解析”

问题描述

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

`@Test
public void LoginEmail() {

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

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

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

无法复制选项,所以我截取了屏幕截图

标签: javaseleniumautomationappiumhelper

解决方案


你应该先初始化它:

 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();
  }

推荐阅读