如何自动化拖拽&使用 Selenium WebDriver Java 删除功能
如何自动化拖拽&在 java 中使用 Selenium WebDriver
删除功能?
How to automate drag & drop functionality using Selenium WebDriver
in java?
推荐答案
有一个页面记录了高级用户交互;其中有很多关于如何生成一系列动作的很好的例子,你可以找到在这里
There is a page documenting Advanced User Interactions; which has a lot of great examples on how to generate a sequence of actions, you can find it here
// Configure the action
Actions builder = new Actions(driver);
builder.keyDown(Keys.CONTROL)
.click(someElement)
.click(someOtherElement)
.keyUp(Keys.CONTROL);
// Then get the action:
Action selectMultiple = builder.build();
// And execute it:
selectMultiple.perform();
或
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(someElement)
.moveToElement(otherElement)
.release(otherElement)
.build();
dragAndDrop.perform();
相关文章