简体   繁体   English

我如何使用Selenium Server在PHPUnit中测试404错误

[英]How do i test for 404 errors in PHPUnit using Selenium Server

I'm trying to write tests with PHP Unit using Selenieum Server, one test i got to make is checking for 404 error pages for images and hyperlinks 我正在尝试使用Selenieum Server用PHP Unit编写测试,我要做的一项测试是检查图像和超链接的404错误页面

the hard part to this is that the tests are for a Magento Setup so they have a custom 404 error page which is actually a CMS page but is selected in the backend to appear when you get a 404 error, also, my local server environment when i view an image which would 404 just shows a white page, in the same browser on a different server environment owned by a team mate, they have text showing up say "Bad Request", both URLS are the same and we entered the page in the exact same way 困难的部分是测试是针对Magento安装程序的,因此它们具有自定义的404错误页面,该页面实际上是CMS页面,但是在收到404错误时也会在后端选择该页面,同时还会出现我的本地服务器环境我查看的图像显示404仅显示白页,在同一队友拥有的不同服务器环境中的同一浏览器中,他们的文本显示为“错误的请求”,两个URL都相同,因此我们在完全一样

when i try using $this->open('kjdasfhkfajdhkfjhafds') which goes to a 404 error page it doesn't seem to throw an exception, i could check for elements on the page to see if they match the expected 404 page i would get but as i have said above, viewing an image gives a different page and that page is also different between servers 当我尝试使用$this->open('kjdasfhkfajdhkfjhafds')转到404错误页面时,它似乎没有引发异常,我可以检查页面上的元素以查看它们是否与预期的404页面匹配得到,但是正如我上面所说的,查看图像给出了不同的页面,并且该页面在服务器之间也不同

I'm in exactly the same situation and I'm experimenting to find a solution. 我处在完全相同的情况下,我正在尝试寻找解决方案。 So far the one that seems to work is check. 到目前为止,似乎有效的方法是检查。

$this->check($url);

seems to atleast return an error on 404 so I am going with that at the moment. 似乎至少会在404上返回错误,因此我现在要处理该错误。 If anybody has any better suggestions feel free to share them :-) 如果有人有更好的建议,请随时分享:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用phpunit测试此类? - How do I test this class using phpunit? Selenium,php,phpUnit,404错误调用testComplete()而不是继续,如何停止此操作? - Selenium, php, phpUnit, 404 error calls testComplete() rather than continue, how do I stop this? 如何在不运行每个函数的新浏览器窗口的情况下运行PHPUnit Selenium测试? - How do I run a PHPUnit Selenium test without having a new browser window run for each function? 如何在PHPUnit中测试异常*处理*? - How do I test exception *handling* in PHPUnit? 如何使用 PHPUnit 测试多个异常? - How do I test for multiple exceptions with PHPUnit? 将PHPUnit与Selenium结合使用,如何测试元素完全包含某些元素? - Using PHPUnit with Selenium, how can I test that an element contains exactly something? 在使用PHPUnit进行测试时,如何在使用实现IteratorAggregate接口的Mock类时防止重新声明错误? - How do I prevent redeclaration errors when using Mock classes that implement the IteratorAggregate interface when testing with PHPUnit? 如何捕获Selenium PHPUnit测试运行时发生的php错误? - How to catch php errors which occurs while Selenium PHPUnit test running? 使用 phpunit 测试错误 404 - Test error 404 with phpunit 如何使用 PHPUnit 用 arguments 测试 __construct? - How do I use PHPUnit to test __construct with arguments?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM