我目前使用的是Webdriver IO、Chimp JS和Cucumber JS,我在将一个元素拖动到iframe中的另一个元素时遇到了一些困难。我已经能够找到我想要移动的元素,以及使用client.frame(0);后在iframe中的元素,但是我还没有找到一种方法来单击元素,切换到iframe来定位我想要移动到的元素,然后移动元素。
为了方便起见,这里有一张图片。我想将元素1移动到元素2,但元素2在iframe中:

Looking through the docs,我看到了很多有潜在帮助的动作,比如hold,release ext。但我在桌面上工作,所以我不能使用任何移动操作。
有了这个限制,看起来我唯一可用的拖放功能是dragAndDrop,但是在javascript版本的Webdriver中,似乎没有一种方法可以将对象拖放到iframe中的元素中。我这样想对吗?有什么方法可以单独使用Cucumber JS来做到这一点吗?我觉得我在这里遗漏了一些重要的东西,但我似乎找不到它:\
发布于 2017-04-14 19:49:09
我使用的selenium独立驱动程序是selenium-server-standalone-2.50.0.jar(selenium-release.storage.googleapis.com/index.html?path=2.50/),而chrome驱动程序是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();
});
});https://stackoverflow.com/questions/37264412
复制相似问题