Let's say I have the following code:
HtmlUnitDriver driver = ...
List<WebElement> elements = Stream.of(
By.tagName("h1"),
By.tagName("h2"),
By.cssSelector("h3"),
By.cssSelector("h4")
).map(driver::findElement).toList();
...
When one of that elements is missing, I get different error messages:
org.openqa.selenium.NoSuchElementException: Unable to locate element with name: 'h1'
org.openqa.selenium.NoSuchElementException: Unable to locate element with name: 'h2'
org.openqa.selenium.NoSuchElementException: Returned node (null) was not a DOM element
org.openqa.selenium.NoSuchElementException: Returned node (null) was not a DOM element
I hope you see what the problem is: While I can identify what is missing from the error message for By.tagName, I can't do that from the error message for By.cssSelector, what makes it hard to find the root cause for an error.
So I'd like to ask if we can include the specific locator in each error message of HtmlUnitDriver.findElement.
Let's say I have the following code:
When one of that elements is missing, I get different error messages:
org.openqa.selenium.NoSuchElementException: Unable to locate element with name: 'h1'org.openqa.selenium.NoSuchElementException: Unable to locate element with name: 'h2'org.openqa.selenium.NoSuchElementException: Returned node (null) was not a DOM elementorg.openqa.selenium.NoSuchElementException: Returned node (null) was not a DOM elementI hope you see what the problem is: While I can identify what is missing from the error message for
By.tagName, I can't do that from the error message forBy.cssSelector, what makes it hard to find the root cause for an error.So I'd like to ask if we can include the specific locator in each error message of
HtmlUnitDriver.findElement.