Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support More Complex XPath #391

Open
diba1013 opened this issue Oct 24, 2019 · 2 comments
Open

Support More Complex XPath #391

diba1013 opened this issue Oct 24, 2019 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@diba1013
Copy link

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 diba1013 added enhancement New feature or request help wanted Extra attention is needed labels Oct 24, 2019
@roesslerj
Copy link
Contributor

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

@diba1013
Copy link
Author

diba1013 commented May 4, 2020

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Development

No branches or pull requests

2 participants