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

Question: Regexp Selector #400

Closed
zakrush opened this issue Jan 23, 2022 · 1 comment
Closed

Question: Regexp Selector #400

zakrush opened this issue Jan 23, 2022 · 1 comment
Labels

Comments

@zakrush
Copy link

zakrush commented Jan 23, 2022

Hi, guys

Can someone help me with regexp of selector?

I have this selector:
#issues-field-company_id-1923-picker-listEl where 1923 it's changed values.
How can I select element by selene library?

@yashaka
Copy link
Owner

yashaka commented Feb 20, 2022

Hey!

This question has a little for Selene to deal with.

Technically, in Selene we can do things like:

element = browser.all('.item').filtered_by(have.attribute('id').value('issues-field-company_id-1923-picker-listEl'))

And probably we can add the support of something like:

element = browser.all('.item').filtered_by(have.attribute('id').value_matched('issues-field-company_id-\d+-picker-listEl'))

Probably we should (see #401)... But his is definitely a low-priority feature, because you rarely need regex for such filtering. Reasons:

  1. In most cases just "filtering by contains is enough:
element = browser.all('.item').filtered_by(have.attribute('id').value_containing('issues-field-company_id-'))
  1. In many cases, for better speed of location, you would be interested in somthing like
element = browser.element('id^=issues-field-company_id'))

or

elements = browser.all('id^=issues-field-company_id'))

I recommend you using one of the options above.

@yashaka yashaka closed this as completed Feb 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants