You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But now we have to do checks like this in each test:
...
constheader=browser.getText('h1');assert(Array.isArray(header),'We have more than one `h1` header on the page!');assert.equals(header,'Hello here!');
...
On the other hand, when we have on the page, for example, a list of elements and want to get the contents of the elements of this list, we expect to get an array of strings:
Firstly, we can do such checks in each test. But this is a very unsuitable option.
The second option — is to override getText and other similar commands in all projects where we use tests. But this method has two important drawbacks:
When the developer first sees the new method, he opens the documentation for wdio and sees an incorrect description
We will not have IDE support for overridden methods
It would be much more convenient and clearer to have a similar functional in the core API.
The text was updated successfully, but these errors were encountered:
Hello
In our project we override wdio command
getText
and add new commandgetTexts
:getText.js
getTexts.js
This helped us avoid such hacks as this one.
My proposal
I have a proposal to change all of these methods in a similar way:
getText(s)
getValue(s)
getAttribute(s)
getTagName(s)
getCssProperty(ies)
I want to do this because this expedient looks like a hack and very often occurs in our tests. What do you think about this?
Use cases:
When a developer writes a test, most often he wants to get the text of some particular element on the page (by the selector):
But now we have to do checks like this in each test:
On the other hand, when we have on the page, for example, a list of elements and want to get the contents of the elements of this list, we expect to get an array of strings:
But in this situation the method
getText
behaves strangely and unexpectedly. Now we have to do checks like this in each test:What can we do about this problem?
Firstly, we can do such checks in each test. But this is a very unsuitable option.
The second option — is to override
getText
and other similar commands in all projects where we use tests. But this method has two important drawbacks:It would be much more convenient and clearer to have a similar functional in the core API.
The text was updated successfully, but these errors were encountered: