我在使用Selenium Java的html5中拖放时遇到问题 [英] I am facing issue in drag and drop in html5 with selenium java

查看:49
本文介绍了我在使用Selenium Java的html5中拖放时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java和Selenium的新手.我在HTML5的dragAndDrop中遇到问题.你能帮我吗?

I am newbie to java and selenium. i am facing issue in dragAndDrop in HTML5. can you please help me?

我正在使用的代码是:

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 &amp;&amp; !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>

推荐答案

这是Selenium和Html5尚未解决的老问题;但是您可以在这里找到一种解决方案(归功于rcorreia): https://gist.github.com/rcorreia/2362544#file-drag_and_drop_helper- js

This is an old problem not fixed yet with Selenium and Html5; but there is a solution that you can find here (credit to rcorreia): https://gist.github.com/rcorreia/2362544#file-drag_and_drop_helper-js

只需执行该js文件js.ExecuteScript(jsfile + "$('#[sourceElement]').simulateDragDrop({dropTarget: '#[targetElement]'})");

这篇关于我在使用Selenium Java的html5中拖放时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆