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 CSS Selectors #389

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

Support More Complex CSS Selectors #389

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

Comments

@diba1013
Copy link

diba1013 commented Oct 24, 2019

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.cssSelector, we currently only support simple css selectors. The supported selectors look for some known attributes like id or class. For example:

  • By.cssSelector( "#id" );
  • By.cssSelector( ".class" );

This should be the same for @FindBy.

Solution

We want to support more complex selectors. Note, that this issue should only address selectors that query the current element. It should not look for children or parents. A complete specification of CSS selectors can be found in the CSS specification.

The current element would mean to selects any element (this also includes any * or no selector) and queries a predicate [] or state :. Note that the state may only look at the elements' attributes. Please refer to the examples below.

Examples this issue should address:

  • .class1.class2
  • p.intro
  • div, p
  • a[target]
  • a[target=_blank
  • input:checked

Examples not considered for this issue (see #390):

  • div p
  • div > p
  • p::before
  • p:nth-child(4)

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.

@roesslerj
Copy link
Contributor

briemla added a commit that referenced this issue Nov 24, 2019
Create predicates for css selectors in separate class.
Configure supported css selectors via regex expression and factory
method.
briemla added a commit that referenced this issue Nov 24, 2019
Reduce visibility of classes.
briemla added a commit that referenced this issue Nov 24, 2019
briemla added a commit that referenced this issue Nov 24, 2019
briemla added a commit that referenced this issue Nov 24, 2019
Test building of predicates.
briemla added a commit that referenced this issue Nov 24, 2019
Test multiple selectors in PredicateBuilder.
Refactor PredicateBuilder.
briemla added a commit that referenced this issue Nov 25, 2019
Create predicates for css selectors in separate class.
Configure supported css selectors via regex expression and factory
method.
briemla added a commit that referenced this issue Nov 25, 2019
Reduce visibility of classes.
briemla added a commit that referenced this issue Nov 25, 2019
briemla added a commit that referenced this issue Nov 25, 2019
briemla added a commit that referenced this issue Nov 25, 2019
Test building of predicates.
briemla added a commit that referenced this issue Nov 25, 2019
Test multiple selectors in PredicateBuilder.
Refactor PredicateBuilder.
@briemla
Copy link
Contributor

briemla commented Nov 25, 2019

I checked the css files of some popular websites listed on Wikipedia. Pseudo-Selectors starting with : or :: or class, id and tag based ones are quite common. Attribute based selectors are present, too. Selectors starting with : or :: might be implemented by one rule each. This will allow more selectors than specified on w3schools. As I would expect the sites to be compatible with definition on w3school, this should be no big deal.
Otherwise recheck will start to check syntax errors, e.g. allowing :in-range only on elements with min and max attributes.

briemla added a commit that referenced this issue Dec 1, 2019
Create predicates for css selectors in separate class.
Configure supported css selectors via regex expression and factory
method.
briemla added a commit that referenced this issue Dec 1, 2019
Reduce visibility of classes.
briemla added a commit that referenced this issue Dec 1, 2019
briemla added a commit that referenced this issue Dec 1, 2019
briemla added a commit that referenced this issue Dec 1, 2019
Test building of predicates.
briemla added a commit that referenced this issue Dec 1, 2019
Test multiple selectors in PredicateBuilder.
Refactor PredicateBuilder.
briemla added a commit that referenced this issue Dec 1, 2019
briemla added a commit that referenced this issue Dec 1, 2019
Test building of predicates.
briemla added a commit that referenced this issue Dec 1, 2019
Refactor Has class to simplify implementation of attribute selectors.
Implement all attribute selectors.
@briemla
Copy link
Contributor

briemla commented Dec 1, 2019

All kinds of attribute selectors using [*] specified on w3schools are implemented.

briemla added a commit that referenced this issue Jan 9, 2020
Test multiple selectors in PredicateBuilder.
Refactor PredicateBuilder.
briemla added a commit that referenced this issue Jan 9, 2020
briemla added a commit that referenced this issue Jan 9, 2020
Test building of predicates.
briemla added a commit that referenced this issue Jan 9, 2020
Refactor Has class to simplify implementation of attribute selectors.
Implement all attribute selectors.
briemla added a commit that referenced this issue Jan 9, 2020
Ensure attribute value is available.
briemla added a commit that referenced this issue Jan 18, 2020
Create predicates for css selectors in separate class.
Configure supported css selectors via regex expression and factory
method.
briemla added a commit that referenced this issue Jan 18, 2020
Reduce visibility of classes.
briemla added a commit that referenced this issue Jan 18, 2020
briemla added a commit that referenced this issue Jan 18, 2020
briemla added a commit that referenced this issue Jan 18, 2020
Test building of predicates.
briemla added a commit that referenced this issue Jan 18, 2020
Test multiple selectors in PredicateBuilder.
Refactor PredicateBuilder.
briemla added a commit that referenced this issue Jan 18, 2020
briemla added a commit that referenced this issue Jan 18, 2020
Test building of predicates.
briemla added a commit that referenced this issue Jan 18, 2020
Refactor Has class to simplify implementation of attribute selectors.
Implement all attribute selectors.
briemla added a commit that referenced this issue Jan 18, 2020
Ensure attribute value is available.
@briemla
Copy link
Contributor

briemla commented Jan 18, 2020

Recheck currently supports the following pseudo-class selectors:

  • checked
  • disabled
  • read-only (Different spelling than html attribute)

Recheck currently does not support the following pseudo-class selectors:

  • root
  • indeterminate
  • default
  • enabled
  • link
  • target
  • visited
  • optional
  • required
  • in-range
  • out-of-range
  • invalid
  • valid
  • read-write

An integration test checks all those selectors.

The following classes could be easily supported by a small extension in getAllElementsByPath.js:

  • indeterminate via boolean property
  • root as the property is only defined for the root element (typeof variable === 'undefined')
  • enabled as the opposite of disabled

briemla added a commit that referenced this issue Jan 21, 2020
Create predicates for css selectors in separate class.
Configure supported css selectors via regex expression and factory
method.
briemla added a commit that referenced this issue Jan 21, 2020
Reduce visibility of classes.
briemla added a commit that referenced this issue Jan 21, 2020
briemla added a commit that referenced this issue Jan 21, 2020
briemla added a commit that referenced this issue Jan 21, 2020
Test building of predicates.
briemla added a commit that referenced this issue Jan 21, 2020
Test multiple selectors in PredicateBuilder.
Refactor PredicateBuilder.
briemla added a commit that referenced this issue Jan 21, 2020
briemla added a commit that referenced this issue Jan 21, 2020
Test building of predicates.
briemla added a commit that referenced this issue Jan 21, 2020
Refactor Has class to simplify implementation of attribute selectors.
Implement all attribute selectors.
briemla added a commit that referenced this issue Jan 21, 2020
Ensure attribute value is available.
@briemla
Copy link
Contributor

briemla commented Jan 23, 2020

Other improvements concerning TestHealer are added as JIRA issues: RET-1913 and RET-1912.

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

3 participants