2016-05-16 13 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(); 
     }); 
    });