I have the following issue:
- I have a page where the “Save button” becomes clickable only when I enter a certain value inside a text filed.
- What I want to do is to check that if the Save button is disabled, then I need to enter some value in that text field.
What I thought is to have something like this:
JavaScript
x
5
1
if (save button is disabled){
2
enter text inside the filed
3
click save button
4
}
5
What I couldn’t do is to store the value of the save button being disabled into a Boolean variable.
Thank you!
Advertisement
Answer
You can use getAttribute()
int his way:
JavaScript
1
3
1
var yourElement = element(by.id('foo')); //find by id, class or whatever you want
2
expect(yourElement.getAttribute('disabled')).toBe(true)
3
Docs here
So to your purpose you can use something like this:
JavaScript
1
5
1
if (yourElement.getAttribute('disabled')){
2
enter text inside the filed
3
click save button
4
}
5