I've got a div in an HTML Page of which the name is always known and inside this div there is an href, the details of which are not known. It could be the direct child of the parent or it could be a further grandchild. Looks something like this:
<div class="divName">
...
<a href="some url">some text</a>
...
</div>
I know that there will only be one link within this div, so I want to find the one link and click it.
I've tried the following but it doesn't seem to be working:
element(by.classname('divName')).find('a').click();
Any ideas?
element(by.css('.divName a')).click();
Or the shorter notation:
$('.divName a').click();
figured out a solution:
ptor.findElement(protractor.By.className('clsName'))
.findElements(protractor.By.tagName('a'))
.then(function(links){
links[0].click();
//place expects here, otherwise it will run async and your expects will be hit
//before the lookup
});
This seems to work pretty well for my purposes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With