-1
我嘗試在textarea中使用driver.findElement(By.classname(「aoT」))。sendKeys(「hello」)輸入文本,但它引發異常Expected [object Undefined]未定義爲字符串。如何使用selenium webdriver在textarea中設置文本
public class Test_sele {
static WebDriver driver;
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.gecko.driver","C:\\ffdriver\\geckodriver.exe");
driver = new FirefoxDriver();
driver.get("https://www.gmail.com");
Thread.sleep(20000);
WebElement compose = driver.findElement(By.className("z0"));
compose.click();
Thread.sleep(10000);
//WebElement to = driver.findElement(By.className("aoT"));
//System.out.println(to);
//to.sendKeys("na");
//to.click();
//to.sendKeys("na");
driver.findElement(By.className("aoT")).clear();
driver.findElement(By.className("aoT")).sendKeys("hello");
driver.close();
}
}
請幫我出其他替代或做一些修改 感謝
爲什麼恢復改善您的文章格式的編輯?只是好奇。 –