【问题标题】:Scrolling to element in Selenium using intern.js and leadfoot使用 intern.js 和 Leadfoot 滚动到 Selenium 中的元素
【发布时间】:2014-10-14 04:18:54
【问题描述】:

其中有很多组件,我不确定问题出在哪里,但这是我的问题。我正在使用 intern.js 与 SauceLabs 进行 javascript 功能测试。

以下测试通过了,但是当我转到 SauceLabs 的屏幕截图以查看窗口的行为方式时,它无法正确滚动到元素,因此 .moveMouseTo 无法正常工作。

有一点滚动,但该元素仍然不可见。我研究了 Selenium 并专注,但我是 intern.js 的新手,所以我不确定如何从此处的 Selenium only 帖子中的描述中实现这一点。

这是测试:

'added comment shows the comment added': function () {
        return this.get('remote')
            .get(require.toUrl('index.html'))
            .setFindTimeout(500)
            .setWindowSize(800, 600)
            .findByCssSelector('.ht-comment-box')
            .click()
            .type('My New Comment')
            .end()
            .findByCssSelector('#addComment')
            .click()
            .end()
            .setFindTimeout(500)
            .findByCssSelector('.commentRow:last-child > .commentContent ')
            .moveMouseTo()
            .getVisibleText()
            .then(function (text) {
                assert.strictEqual(text, 'My New Comment',
                    'Adding a comment should display the comment. Showed instead ' + text);
            });
    },

这是滚动的样子,添加的评论是不可见的。

【问题讨论】:

    标签: javascript selenium intern saucelabs


    【解决方案1】:

    我相信您需要将一个元素传递给moveMouseTo

    var remote = this.get('remote');
    
    return remote.get( … )
      // …
      .findByCssSelector( … ).then(function (element) {
        return remote.moveMouseTo(element);
      })
      .getVisibleText();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多