.clear((在我的测试脚本中不使用testng版本6.14.2,但是当我在没有测试的情况下运行相同的代码时,清晰的方法是按预期工作的。我正在运行如下所述的代码:driver.findelement(by.id(" email"((。clear((;但是此LOC没有执行任何动作。
blockquote
clear((为我工作。参考以下片段
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class Testngexample {
private WebDriver driver;
@BeforeClass
public void setUp() {
System.setProperty("webdriver.chrome.driver","Add chromedriver path chromedriver.exe");
driver = new ChromeDriver();
}
@AfterClass
public void tearDown() {
driver.quit();
}
@Test
public void GoogleEarch() throws InterruptedException {
driver.get("https://www.google.com/");
driver.manage().window().maximize();
driver.findElement(By.name("q")).click();
driver.findElement(By.name("q")).sendKeys("testing");
Thread.sleep(5000);
driver.findElement(By.name("q")).clear();
Thread.sleep(5000);
driver.close();
}
}