gpt4 book ai didi

selenium-webdriver - 如何使用 selenium webdriver 中的操作清除文本框

转载 作者:行者123 更新时间:2023-12-02 03:29:22 26 4
gpt4 key购买 nike

我在使用操作时遇到清除文本框的问题。这是代码:

for (int j = 1; j <= TotalCount; j++) {
//driver.findElement(By.xpath("(//div[@class='fourcolumns']//div//label)[" + j + "]")).sendKeys("Test");
WebElement CustomfieldsTextBox = driver.findElement(By.xpath("(//div[@class='fourcolumns']//div//textarea)[" + j + "]"));
action.moveToElement(CustomfieldsTextBox);
action.click();
action.sendKeys("Testing");
action.build().perform();
}

如何清除文本框?

最佳答案

您可以使用下面的代码片段,

Actions actions = new Actions(driver);

actions.click(driver.findElement(element)
.keyDown(Keys.CONTROL)
.sendKeys("a")
.keyUp(Keys.CONTROL)
.sendKeys(Keys.BACK_SPACE)
.build()
.perform();

关于selenium-webdriver - 如何使用 selenium webdriver 中的操作清除文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52271096/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com