2 回答

TA貢獻1934條經驗 獲得超2個贊
你應該先初始化它:
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();
}

TA貢獻1865條經驗 獲得超7個贊
AndroidDriver driver = new AndroidDriver(new URL("localhost:4723/wd/hub"), cap); 這應該是類或本地可訪問性。聲明為類對象,即在此文本夾具中或在由該類繼承的父類中或在本地初始化,即在測試方法中。
添加回答
舉報