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

Add toMatch by id matcher #27

Closed
ofirdagan opened this issue Sep 26, 2016 · 4 comments
Closed

Add toMatch by id matcher #27

ofirdagan opened this issue Sep 26, 2016 · 4 comments

Comments

@ofirdagan
Copy link
Contributor

ofirdagan commented Sep 26, 2016

In order to select components in the tests we use the testID property of course.

Right now you can't check the text by testID. It'll be great if we could do it.
Another great thing is to implement the toMatch matcher so we won't break on every tiny text change.

Protractor syntax is:

expect($('#my-id').getText()).toMatch('some partial text');

P.S - if the toMatch is too complicated having the ability to check the text by Id is also good enough.

Go team WIX!

@talkol talkol added this to the Version 1 milestone Oct 6, 2016
@talkol talkol self-assigned this Oct 6, 2016
talkol pushed a commit that referenced this issue Oct 7, 2016
@talkol
Copy link

talkol commented Oct 7, 2016

Part of the EarlGrey philosophy is that all assertions/matchers are run in the app (on the Testee). This means you can't return the text to the Tester and do the comparison there.

This means the preferred syntax is:
expect(element(by.id('UniqueId204'))).toHaveText('I contain some text');

@talkol talkol closed this as completed in 75abc70 Oct 7, 2016
@talkol
Copy link

talkol commented Oct 7, 2016

The toHaveText is very specific to text-related components like UILabel, RCTText.

In addition to this assertion, I added a more general one:
expect(element(by.id('UniqueId204'))).toHaveLabel('I contain some text');

This tests the accessibility label which is usually (unless overridden specifically) the same as the text. The benefit of this one is that it will work on more view types. The drawback is that it can be overridden so it's not necessarily the text displayed to the user.

@vasyas
Copy link
Contributor

vasyas commented Nov 3, 2017

So is there a way to test if a text related component contains a substring
(instead of testing if component text equals to given substring)
?

@sapjax
Copy link

sapjax commented Dec 13, 2017

@talkol
I think we also need a getText() method, let me for example:

  1. user fills username and password to create a bitcoin wallet address.
  2. native generate an address with a mnemonic, this mnemonic is a random string depends on the algorithm in native code.
  3. app display the mnemonic text on the screen, the user needs to copy mnemonic text to paper.
  4. after user copied, app display a textarea, the user needs to type mnemonic into textarea, then the app will check whether user copied the mnemonic text right.

In the situation above, I need to do:

const mnemonic = element(by.id('mnemonic')).getText()
element(by.id('textarea')).typeText(mnemonic)
element(by.id('next')).tap()

@wix wix locked and limited conversation to collaborators Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants