[英]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.