recheck-web icon indicating copy to clipboard operation
recheck-web copied to clipboard

Support More Complex XPath

Open diba1013 opened this issue 5 years ago • 2 comments

Problem

When we encounter missing elements with the Unbreakable Selenium, we try to find the old element inside the golden master. Therefore, we query the By used and look what type was used (i.e. By.id, By.class).

However, when we try to find By.xpath, we currently only support simple XPath. Furthermore, we do not follow common format as described in #132. For example, we require:

  • By.xpath( "//input[1]" );
  • By.xpath( "/html[1]/body[1]/div[1]" );

This should be the same for @FindBy.

Solution

We want to support the xpath specification. Note that browsers might only support XPath 1.0.

The current element would mean to selects any element (this also includes any * or no selector) and queries parent, children, state : or pseudo-element ::. Note that the state may only look at the elements' parent or children. Please refer to the examples below. Note that those examples are not complete, refer to the specification for more.

Examples this issue should address

  • /html/body/div[1]
  • /html//div[2]
  • //input[@type=file]
  • //*[@id="foo"]/summary

Community

I kindly ask the community to provide examples below that should be reflected with this issue, so that we can use these to test the implementation.

diba1013 avatar Oct 24 '19 08:10 diba1013

As mentioned ... I'd close this one and split the remaining un-implemented examples into separate issues...?

roesslerj avatar Nov 01 '19 14:11 roesslerj

Some selectors reported in #585 :

driver.findElement( By.xpath( "//*[@id=\"username\"]" ) ).sendKeys( "Simon" );
driver.findElement( By.xpath( "/html/body/div/div/form/div[2]/input" ) ).sendKeys( "secret" );
driver.findElement( By.xpath( "//*[text()='Sign in']" ) ).click();

diba1013 avatar May 04 '20 09:05 diba1013