【发布时间】:2020-10-28 03:53:08
【问题描述】:
以下是源元素的 HTML:
<div title="" class="dragItem row " id="DocSelected-1" draggable="true" type="11" data-content="Salary Slips" data-draggable="item" document-required="1" state="notVerified" accountid="0">
<span class="col-xs-10 dl-no-padding">
<span>Salary Slips</span>
</span>
以下是目标元素的 HTML:
<div class="removeDocs" data-draggable="remove"> Drag here to remove document </div>
下面是实现拖拽的代码,
IWebElement from = driver.FindElement(By.XPath("//div[@id='DocSelected-1']//span[@class='col-xs-10 dl-no-padding']"));
IWebElement to = driver.FindElement(By.ClassName("removeDocs"));
Actions act = new Actions(driver);
act.DragAndDrop(from, to).Build().Perform();
当我尝试使用上面的代码时,测试用例通过但拖放没有完成。
所以请建议执行拖放操作的正确方法。
【问题讨论】:
标签: c# selenium unit-testing testing xpath