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

[Feature Request] Add a matchExactly flag to text based properties #272

Open
sukima opened this issue Dec 13, 2016 · 6 comments · May be fixed by #488
Open

[Feature Request] Add a matchExactly flag to text based properties #272

sukima opened this issue Dec 13, 2016 · 6 comments · May be fixed by #488
Assignees
Labels

Comments

@sukima
Copy link
Contributor

sukima commented Dec 13, 2016

contains and clickOnText both use text input to find elements and act on them. Currently that textual match will match any subset of the text to search for.

Discussed in the slack channel a possible solution is to add a modifier to say we want to match the exact text instead of a subset.

Example

<button>foo</button>
<button>foobar</button>
let page = PageObject.create({
  clickButton: clickOnText('button')
});
page.clickButton('foo');

The above will match both buttons.

Alternatively it could look like:

let page = PageObject.create({
  clickButton: clickOnText('button', {matchExact: true})
});
page.clickButton('foo');

Which will match only the first button.

@san650 san650 added the feature label Dec 13, 2016
@juanazam juanazam self-assigned this Dec 21, 2016
@juanazam
Copy link
Collaborator

@sukima thanks for your request, I will try to work on this soon 😄

@mum-never-proud mum-never-proud linked a pull request Mar 29, 2020 that will close this issue
@mum-never-proud
Copy link
Contributor

guys I was in need of this feature, thought of raising a pr

do let me know for any changes

tanks :)

cc: @san650

@ro0gr
Copy link
Collaborator

ro0gr commented Mar 29, 2020

hm.. that's surprising to me. I believe that matchExact behavior should have been a default.
But changing it now, would probably break some test suites..

@ro0gr
Copy link
Collaborator

ro0gr commented May 8, 2020

just realized we could add support for this directly to the clickable(:

const p = create();

await p.click('Some button text');

fortunately, currently click( does not support any arguments, and I can't think of any other than a label to click on. Obviously, it would make clickOnText( action redundant.

It feels like matchExact=false behavior should not be allowed at all, cause it's non-deterministic and error prone. So I think we may not need an extra flag for that.

@ro0gr
Copy link
Collaborator

ro0gr commented Jan 20, 2021

Curious, if there are any real use cases for matchExactly: false, which is the only possible behavior currently?

I'm considering a breaking change in v2, in order to make clickOnText to strictly click on exact text only.

@san650
Copy link
Owner

san650 commented Jan 21, 2021

I would guess that sometimes you get generated or random text e.g. an auto-generated id or current date so you want to match part of the label instead of the full text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants