首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试将元素拖动到iFrame内部的元素(使用Webdriver-io)?

尝试将元素拖动到iFrame内部的元素(使用Webdriver-io)?
EN

Stack Overflow用户
提问于 2016-05-17 06:43:53
回答 1查看 930关注 0票数 0

我目前使用的是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来做到这一点吗?我觉得我在这里遗漏了一些重要的东西,但我似乎找不到它:\

EN

回答 1

Stack Overflow用户

发布于 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)

代码语言:javascript
复制
    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();
      });
    });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37264412

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档