Protractor: find the hidden input element by attribute value

How do I find and get a value for an element like the following?

<input type="hidden" title="username" value="joe.doe"> 

Any suggestions that are very much appreciated.

+6
source share
2 answers
 var userNameElm = $('input[title=username]'); it('is present but invisible', function() { expect(userNameElm.isPresent()).toBeTruthy(); expect(userNameElm.isDisplayed()).toBeFalsy(); }); it('should have proper value attribute', function() { expect(userNameElm.getAttribute('value')).toEqual('joe.doe'); }); 
+15
source

If you are trying to access an element with data-* attributes, as it would be in Bootstrap , we can select such elements as follows: -

var loginBtn = $('a[data-target="#login-modal"]');

This is the same as the accepted answer, except that it has a "" around #login-modal . Without a "" it does not work.

Good luck.

0
source

Source: https://habr.com/ru/post/978841/


All Articles