Reputation: 10696
How do I go about locating & getting a value for an element like the following?
<input type="hidden" title="username" value="joe.doe">
Any suggestions much appreciated.
Upvotes: 7
Views: 9534
Reputation: 23805
If you are trying to access an element with data-*
attributes as we would do in Bootstrap
, we can select such elements as follows:-
var loginBtn = $('a[data-target="#login-modal"]');
This is same as the accepted answer except that it has ""
around #login-modal
. Without the ""
, it doesn't work.
Good Luck.
Upvotes: 0
Reputation: 16722
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');
});
Upvotes: 16