Add current URL on the error message
See original GitHub issueThe problem
The error message on a test failure doesn’t display the URL where we are getting the error.
Details
The following message is helpful. It would be great to add the URL as well.
com.codeborne.selenide.ex.ElementNotFound: Element not found {#dashboardButton}
Expected: visible or transparent: visible or have css value opacity=0
Screenshot: file:/C:/_work/app/build/reports/tests/1570048960084.0.png
Page source: file:/C:/_work/app/build/reports/tests/1570048960084.0.html
Timeout: 4 s.
Caused by: NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"#dashboardButton"}
at com.codeborne.selenide.impl.WebElementSource.createElementNotFoundError(WebElementSource.java:37)
at com.codeborne.selenide.impl.ElementFinder.createElementNotFoundError(ElementFinder.java:100)
at com.codeborne.selenide.impl.WebElementSource.checkCondition(WebElementSource.java:65)
Possible Solution:
We may need to update com.codeborne.selenide.ex.UIAssertionError#uiDetails() and com.codeborne.selenide.ex.ErrorMessages to pull the current url from driver object:
driver.getWebDriver().getCurrentUrl();
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
ajax url append on current url on document ready and giving ...
ajax url append on current url on document ready and giving 302 error · 2. If you want 127.0.0.1:8000/sort-list then in your document....
Read more >Fix Error: HTML Hyperlink Being Appended To Current URL
Troubleshooting suggests on how to fix an issue where a HTML href issue results in the hyperlink being appended to the current URL....
Read more ><input type="url"> - HTML: HyperText Markup Language | MDN
The input value is automatically validated to ensure that it's either empty or a properly-formatted URL before the form can be submitted.
Read more >Router - Angular
How to handle a navigation request to the current URL. One of: ... if navigation fails, you can show an error message with...
Read more >How To Get The Current URL With JavaScript - W3Schools
Read more about the window.location object in our JavaScript Window Location Tutorial. ❮ Previous Next ❯.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The main advantage of knowing the URL is to save a bunch of click and navigation through the page to get into the problematic page.
I agree on the Scenario and all Pros that BorisOsipov posted. I have following feedback on the Cons.
For modern SPA application it is useless. They often use one route for serving bunch of pages. -> Agreed. But knowing the url takes us to the problematic page faster.
For enterprise apps url can be very large enormous and will make error hideous(or if we trim url we won’t have any cons I mentioned above) -> Can we make it a configuration option to decide if we should print the URL or not?
Often you can just open url and server returns corresponding page… So for what we need such url? -> I didn’t get this. What do you mean by “you can just open url” ?
Often app has authentication, so we cant just open url from error and see page. We have to find user\password, log in to app and then open corresponding page from error. A lot of steps, isnt it? -> Assuming you are already logged in. You can simply open the URL and get into the desired page.
Should be done carefully. Url can be quite large and in this case it will make error message hideous