2016-05-16 85 views
0

我目前使用Webdriver IO,Chimp JS和Cucumber JS,而且我很难将元素拖拽到iframe中的另一个元素。我已经能够找到我想要移动的元素,以及使用client.frame(0);后的iframe中的元素,但是我还没有找到方法来单击该元素,切换到iframe以找到我想要的元素移动到,然后移动元素。试图将元素拖动到iFrame内部的元素(使用Webdriver-io)?

为了更容易,这里有一张照片。我想移动元素1至2元,但元素2是在iframe:

enter image description here

​​,我看到了很多可能有助于操作,如保持,释放转的。但我在桌面上工作,所以我不能使用任何移动操作。

有了这个限制,它看起来像我可用的唯一拖放功能是dragAndDrop,但似乎没有办法将对象拖放到JavaScript版本的iframe中的元素中的webdriver。我是否认为这是正确的?有没有办法单独使用Cucumber JS?我觉得我在这里错过了一些巨大的东西,但我似乎无法弄清楚:\

+0

这不是一个答案,更像是一个建议!您是否尝试过使用[buttonDown](http://webdriver.io/api/protocol/buttonDown.html)和[buttonUp](http://webdriver.io/api/protocol/buttonUp.html) 另外,您应该尝试使用WebdriverIO gitter通道。 –

+0

我刚要回答这个问题,那正是我为了实现这个目标所必须做的。感谢您的建议! – Nagoshi

回答

1

我使用的硒独立驱动程序是selenium-server-standalone-2.50.0.jar(硒释放。 storage.googleapis.com/index.html?path=2.50/)和铬司机我采用的是ChromeDriver 2.29(https://sites.google.com/a/chromium.org/chromedriver/downloads

var webdriverio = require('webdriverio'), 
     dragAndDrop = require('html-dnd').codeForSelectors, 
     should = require('should'); 


    // a test script block or suite 
    describe('Title Test for Web Driver IO - Tutorial Test Page Website', function() { 

     // set timeout to 10 seconds 
     this.timeout(10000); 
     var driver = {}; 

     // hook to run before tests 
     before(function() { 
     // load the driver for browser 
     driver = webdriverio.remote({ desiredCapabilities: {browserName: 'chrome'} }); 
     return driver.init(); 
     }); 

     // a test spec - "specification" 
     it('should be load correct page and title', function() { 
     var sectionId = ""; 
     // load page, then call function() 
     return driver  
      .url('http://localhost:9000') //your url 
      .pause(7000) 
      .moveToObject('#element1') 
      .buttonDown()  
      .moveToObject('#element2') 
      .buttonUp() 
      .pause(2000)  
     .end() 
     }); 

     // a "hook" to run after all tests in this block 
     after(function() { 
     return driver.end(); 
     }); 
    });