Jeff Yoo
Jeff Yoo

Reputation: 1

how to get the text of a href in an element using protractor?

The element I have located here in Chrome dev tools looks like this.

<a href="gumby/ui/gumbies/579" title="Mr McGoo meet, Gumby" class="ng-binding">PlayDoh met Mr Potato    Head</a>

how to I get the string "gumby/ui/gumbies/579" out of it using protractor?

tried everything using getText(), getAttribute('href') doesn't seem to work for me.

thanks!

Upvotes: 0

Views: 8395

Answers (2)

Atabic Umer
Atabic Umer

Reputation: 152

There's another way to get text of an anchor tag and then clicking it element(by.partialLinkText('PlayDoh met Mr Potato Head')).click();

Upvotes: 0

deepak
deepak

Reputation: 3172

getAttribute('href') is correct, but did you tried using it on the correct element, like this:

element(by.cssContainingText("a","PlayDoh metMrPotatoHead")).getAttribute('href')

Upvotes: 8

Related Questions