簡體   English   中英

如何使用Selenium Webdriver對下面提供的代碼片段使用拖放功能

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM