Reputation: 51
<a href="someCoolLinkText.com">
<h3 class="main-header">
COOL LINK
</h3>
</a>
What is best way to find and click on this link?
Upvotes: 0
Views: 435
Reputation: 52665
Try to locate required node by its link text:
element(by.linkText('COOL LINK')).click()
Note that you should use text exactly as it appears on page, but not as it appears in HTML source code
Update
You can try to use ExpectedCondition to wait for link appearance in DOM:
var EC = protractor.ExpectedConditions;
browser.wait(EC.elementToBeClickable(element(by.linkText('COOL LINK'))), 5000).click();
Upvotes: 2
Reputation: 193108
The text COOL LINK is within <h3>
tag so you can use xpath
as :
//a[@href='someCoolLinkText.com']/h3[@class='main-header' and contains(.,'COOL LINK')]
Upvotes: 0