我是java和selenium的新手。我在HTML5中的public static void draganddrop(WebDriver driver ,WebElement Source, WebElement Destination)
{
Actions action = new Actions(driver);
action.dragAndDrop(Source, Destination).build().perform();
}
面临问题。你能帮帮我吗?
我使用的代码是:
<li data-ng-repeat="item in questionType" id="divDrag0" class="ng-scope">
<!-- ngIf: !isSurveyStarted || (isSurveyStarted && !isSurveyLock) -->
<a data-ng-if="!isSurveyStarted || (isSurveyStarted && !isSurveyLock)" href="javascript:void(0)" draggable="true" id="1" class="ng-binding ng-scope">Single Choice </a>
<!-- end ngIf: !isSurveyStarted || (isSurveyStarted && !isSurveyLock) -->
<!-- ngIf: isSurveyStarted && isSurveyLock --> </li>
first_draw
&#13;
答案 0 :(得分:1)
这是Selenium和Html5尚未修复的旧问题;但有一个解决方案,你可以在这里找到(信贷rcorreia): https://gist.github.com/rcorreia/2362544#file-drag_and_drop_helper-js
只需执行该js文件table.row.add({
"Id": 11,
"Employee": {
"LogonName": "Example11"
}
});
答案 1 :(得分:0)
通过drag and drop
界面
Actions
版本
new Actions(driver)
.moveToElement(source)
.pause(Duration.ofSeconds(1))
.clickAndHold(source)
.pause(Duration.ofSeconds(1))
.moveByOffset(1, 0)
.moveToElement(destination)
.moveByOffset(1, 0)
.pause(Duration.ofSeconds(1))
.release().perform();
在我的应用程序中,当我clickAndHold
目标元素发生变化时。这就是我添加暂停的原因。