Laravel dusk asserting for 404 errors

隐身守侯 提交于 2019-12-02 03:01:27

问题


I'm trying to use laravel dusk to test for 404 not found error. Specifically when loading an image. After reading the laravel dusk documentation I've found no asserts that could help me test if a 404 exception occurs.

Is there a good way of getting a browser test to know whether a resource has failed loading or is it simply not possible?


回答1:


There is intentionally no way to access HTTP status codes:

https://github.com/laravel/dusk/issues/422
https://github.com/facebook/php-webdriver/issues/470




回答2:


You can use browser -> driver -> manage() -> getLog('browser') to get the log and see if there is a 404 Error



来源:https://stackoverflow.com/questions/51711350/laravel-dusk-asserting-for-404-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!