【问题标题】:Selenium-PHPUnit Error accessing elements in an IFrameSelenium-PHPUnit 访问 IFrame 中的元素时出错
【发布时间】:2023-04-02 07:17:01
【问题描述】:

我需要一些关于 selenium-phpunit 实现的建议。 我正在使用 selenium RC 和 phpunit 与 php-webdriver-bindings 连接 phpunit 和 selenium 来执行一些自动化测试任务。

当我尝试访问 iframe 中的元素时,问题就来了。正常的 getElementBy(LocatorStrategy::id,'@requiredelement') 不起作用,因为它在使用“phpunit filename.php”运行代码时会给出“NoSuchElementException”。

根据我在一些问答中看到的内容,有一些实现可以在 java、c#、python 中的 iframe 的实现过程中更改窗口。不确定这些实现是否适用于 php。

我在 Ubuntu 12.04 上运行 phpunit 3.7 和 include_file“webdriver.php”,它是 php-webdriver-bindings 的相关函数(http://code.google.com/p/php-webdriver-bindings/ )。未检测到 iframe 中的元素。

【问题讨论】:

    标签: iframe selenium phpunit


    【解决方案1】:

    尝试使用它:

    $this->selectFrame("<xpath to get iframe>>"); // for example: //*[@id='iframe']
    $this->assertElementPresent("<xpath to get to element in frame>"); 
    

    一分钟前已经破解了 - 它有效 =)

    【讨论】:

    • 抱歉这么晚才回复。它实际上正在工作。感谢您的建议。 $this 的值应该从加载的页面更改为实际上使 iframe 成为父级的框架。
    猜你喜欢
    • 2016-04-05
    • 2021-11-01
    • 2020-01-13
    • 1970-01-01
    • 1970-01-01
    • 2020-09-08
    • 2017-05-16
    • 2021-03-02
    • 1970-01-01
    相关资源
    最近更新 更多