![](/img/trans.png)
[英]How to automate drag & drop functionality using Selenium WebDriver Java
[英]How to use drag and drop functionality for the snippet provided below using Selenium Webdriver
以下代码包含拖放功能。
如何使用Selenium Web驱动程序为下面提供的代码片段使用拖放功能。 尝试使用硒总部提供的拖放功能,但不适用于我的情况。
<div id="NamingDefaultsContent" style="display: block;">
<div class="rcContainer">
<div class="form-group">
<label class="col-sm-1 control-label"/>
<div style="width: 100%; color: Gray">Naming Config(Drag and Drop to change the order)</div>
<div class="col-reg-12 col-sm-offset-1">
<table id="columns" cellspacing="0" cellpadding="0" style="width: 90%; margin-top: 0px; top: -1">
<tbody>
<tr>
<td>
<table class="gridviewlist">
<tbody>
<tr>
<td> Position 1 </td>
</tr>
</tbody>
</table>
<div class="column" draggable="true">
<label for="NamePartAtPos1">First Name</label>
<input id="NamePartAtPos1" type="hidden" value="0" name="NamePartAtPos1" data-val-required="The First Name field is required." data-val-number="The field First Name must be a number." data-val="true"/>
</div>
</td>
<td>
<table class="gridviewlist">
<tbody>
<tr>
<td> Position 2 </td>
</tr>
</tbody>
</table>
<div class="column" draggable="true">
<label for="NamePartAtPos3">Last Name</label>
<input id="NamePartAtPos3" type="hidden" value="1" name="NamePartAtPos3" data-val-required="The Last Name field is required." data-val-number="The field Last Name must be a number." data-val="true"/>
</div>
</td>
<td>
<table class="gridviewlist">
<tbody>
<tr>
<td> Position 3 </td>
</tr>
</tbody>
</table>
<div class="column" draggable="true">
<label for="NamePartAtPos2">Middle Name</label>
<input id="NamePartAtPos2" type="hidden" value="2" name="NamePartAtPos2" data-val-required="The Middle Name field is required." data-val-number="The field Middle Name must be a number." data-val="true"/>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
不确定拖放的确切位置,但这可能很有用
public ObjectPage filter(int lowerThreshold, int highThreshold) {
Actions action = new Actions(getWebDriver());
action.dragAndDropBy(findElement(".className .thumbMin"), lowerThreshold, 0).perform();
waitFor(elementIsNotDisplayed("#waiting_dialog"));
action.dragAndDropBy(findElement(".className .thumbMax"), highThreshold, 0).perform();
waitFor(elementIsNotDisplayed("#waiting_dialog"));
return this;
}
希望有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.