I'm using Selenium and JUnit with Java and I want to know if a 404 error occurs when opening a new popup by clicking on a link (i'm searching for a thing like assertTrue(selenium.no404error()).
How can I do that ?
You can't test if the HTTP status code is 404. This is explained in this other thread. The only way is to test for something in the page which can only be in your 404 error page. For instance:
assertTrue(driver.getTitle().contains("404"));
If you're not sure that your page contains something specific like 404 or Page not found. You could generate from the server a special tag code (e.g. a <meta>
tag in the <head>
section) and test for it with the WebDriver
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With