【问题标题】:How to scroll to a specific element in selenium?如何滚动到硒中的特定元素?
【发布时间】:2019-10-08 15:18:40
【问题描述】:

我正在尝试用一些文本填充字段,但它在屏幕上不可见,需要滚动才能可见。

我正在使用 moveto 函数

$this->webdriver->moveto($this->element);

但它给了我以下错误

PHPUnit_Extensions_Selenium2TestCase_WebDriverException: Offset within element cannot be scrolled into view: (373.5, 15): [object HTMLInputElement]

我可以在 stackoverflow 上看到很多关于此错误的帖子,但我没有找到任何特定于 php selenium 测试的帖子。

我该如何解决这个问题?

【问题讨论】:

    标签: php selenium-webdriver scroll phpunit


    【解决方案1】:

    您可以使用 moveToElement 功能。它对我有用。

    财政年度:- https://github.com/facebook/php-webdriver/blob/master/lib/interactions/WebDriverActions.php#L164

    【讨论】:

    • moveToElement 功能不可用
    • 所以你需要降级你的版本并检查它是否可用。这是我们用来执行此操作的功能。
    • 我有这个"phpunit/phpunit": "dev-only-repeat-failed as 4.8.0", "phpunit/phpunit-selenium": "dev-better-exception-handling as 1.4.2",。我应该降级到哪个版本?
    • v4.8.0 也检查一下我认为你也可以做瘦360logica.com/blog/…
    猜你喜欢
    • 1970-01-01
    • 2013-02-28
    • 2022-10-14
    • 2019-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-12
    相关资源
    最近更新 更多