2016-05-16 9 views
0

私は現在Webdriver IO、Chimp JS、Cucumber JSを使用していますが、iframeの内側にある別の要素に要素をドラッグするのは少し難しいです。 client.frame(0);を使用した後に、移動したい要素とiframe内の要素を見つけることができましたが、要素をクリックする方法が見つからず、iframeに切り替えて、必要な要素を見つけましたに移動し、要素を移動します。iFrameの内部にある要素に要素をドラッグしようとしています(Webdriver-ioを使用しています)?

簡単にするために、ここに画像があります。私は要素2に要素1を移動したい。しかし素子2はiframe内にある:

enter image description here

​​、私はホールド、リリース内線のような潜在的に有用な行動の多くを参照してください。しかし、私はデスクトップ上で作業しているので、私はモバイルアクションを使用することはできません。

この制限では、私に利用可能なドラッグアンドドロップ機能は、dragAndDropだと思われますが、javascriptのバージョンでiframeの要素にオブジェクトをドラッグアンドドロップする方法はないようですWebdriver。私はこれを考えて正しいのでしょうか?キュウリJSを使用してこれを行うには、幾分か? \

+0

です! [buttonDown](http://webdriver.io/api/protocol/buttonDown.html)と[buttonUp](http://webdriver.io/api/protocol/buttonUp.html) また、 WebdriverIO Gitterチャンネルを試してみる必要があります。 –

+0

私はこれにちょうど答えようとしていました。あなたの提案をありがとう! – Nagoshi

答えて

1

私が使ったセレン・スタンドアロン・ドライバーは、セレニウム・サーバー・スタンドアロン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(); 
     }); 
    }); 
関連する問題