【问题标题】:Selenium, php, phpUnit, 404 error calls testComplete() rather than continue, how do I stop this?Selenium, php, phpUnit, 404 错误调用 testComplete() 而不是继续,我该如何停止呢?
【发布时间】:2011-03-15 14:57:26
【问题描述】:

Selenium, php, phpUnit, 404 错误调用 testComplete() 而不是继续,我该如何停止呢?

我正在使用 selenium 服务器和 phpUnit 来运行基于 php 的测试。我的测试很简单,测试页面是否存在,如果它加载,页面上没有错误,然后继续。我有一个丢失的页面,而不是说,是的,它不在那里,我得到了更多:

时间:16 秒,内存:14.75Mb

有 1 个错误:

1) OlympicsSiteMapEnglishPages::testMyTestCase PHPUnit_Framework_Exception:来自 Selenium RC 服务器对 testComplete() 的响应。 XHR 错误:URL = http://my.url/somepage Response_Code = 404 Error_Message = 未找到。

/some/path/some_file.php:375

失败! 测试:1,断言:0,错误:1。

我真的需要弄清楚如何阻止它这样做!我试过像这样捕获异常:

试试{ $this->open("/rel/url.php", 1); } 捕捉(PHPUnit_Framework_AssertionFailedError $e){ return array_push($this->verificationErrors, $e->toString()); }

任何线索,我真的需要帮助!

非常感谢,

亚历克斯

【问题讨论】:

    标签: php testing selenium phpunit


    【解决方案1】:
    • PHPUnit_Framework_Exception 继承自 Exception
    • PHPUnit_Framework_AssertionFailedError 继承自 Exception

    如果您想同时捕获它们,您要么必须在更早的时候捕获“预期的”PHPUnit_Framework_Exception(并可能将其重新抛出为PHPUnit_Framework_AssertionFailedError),或者求助于通用的try{} catch(Exception $e){}

    【讨论】:

      【解决方案2】:

      经过一番挖掘之后没有任何效果,所以我的 hackie hack 方式非常慢,它首先尝试使用以下方法打开每个 url:

      if(@fopen(rtrim($this->url, "/") . "/blah/blah/blah","r")) {

      //做一些不应该退出浏览器的测试,因为我们知道页面存在。

      }

      请有人找到更好的做事方式!

      【讨论】:

        猜你喜欢
        • 2014-04-18
        • 2012-04-15
        • 1970-01-01
        • 1970-01-01
        • 2018-07-13
        • 2012-03-29
        • 1970-01-01
        • 1970-01-01
        • 2022-07-25
        相关资源
        最近更新 更多