我需要执行操作 - 双击元素并同时选择所有值,然后删除内容并输入新值。
下面我已经实现了相同的。它会对元素执行双击但不执行Keys.Control + "a"
,删除和更改值
IWebElement AmountTextBoxElement = driver.FindElement(By.Id("id_to_find"));
Actions act= new Actions(driver);
act.DoubleClick(AmountTextBoxElement).Build().Perform();
WaitingPeriod.SleepMedium();
AmountTextBoxElement.SendKeys(Keys.Control + "a");
WaitingPeriod.SleepMedium();
AmountTextBoxElement.SendKeys(Keys.Delete);
WaitingPeriod.SleepMedium();
AmountTextBoxElement.SendKeys("2323609");
答案 0 :(得分:0)
您可以尝试使用ActionBuilder
Actions action = new Actions();
action.MoveToElement(AmountTextBoxElement);
action.keyDown(Keys.CONTROL).sendKeys("A").keyUp(Keys.CONTROL).perform();