Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用intern.js和leadfoot滚动到Selenium中的元素_Javascript_Selenium_Intern_Saucelabs - Fatal编程技术网

Javascript 使用intern.js和leadfoot滚动到Selenium中的元素

Javascript 使用intern.js和leadfoot滚动到Selenium中的元素,javascript,selenium,intern,saucelabs,Javascript,Selenium,Intern,Saucelabs,有这么多的组成部分,我不知道问题发生在哪里,但这是我的问题。我正在使用intern.js对SauceLabs进行javascript功能测试 但是,下面的测试通过了,当我转到SauceLabs的屏幕截图查看窗口的行为时,它没有正确地滚动到元素,因此.moveMouseTo工作不正常 有一点滚动,但元素仍然不可见。我研究了Selenium和focus,但我对intern.js是新手,所以我不确定如何从这里的Selenium-only帖子中的描述实现这一点 以下是测试: 'added comment

有这么多的组成部分,我不知道问题发生在哪里,但这是我的问题。我正在使用intern.js对SauceLabs进行javascript功能测试

但是,下面的测试通过了,当我转到SauceLabs的屏幕截图查看窗口的行为时,它没有正确地滚动到元素,因此
.moveMouseTo
工作不正常

有一点滚动,但元素仍然不可见。我研究了Selenium和focus,但我对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);
            });
    },
下面是滚动的外观,添加的注释不可见


我认为您需要将一个元素传递给
moveMouseTo

var remote = this.get('remote');

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

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

var remote = this.get('remote');

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