Reputation: 243
Hi I need to know how to locate an element that has no ID or name, and is located within classes, without using xPath for Webdriver
How can I locate the link in the image below without using xPath, using webdriver.
I've included an image:
Upvotes: 2
Views: 1524
Reputation: 243
Solved it this is what I got and it worked
driver.findElement(By.cssSelector(".links > a[ng-click*=Photos]"));
Upvotes: 0
Reputation: 15
This CSS selector should work, you can use By.CssSelector:
.links > a[ng-click*="Photos"]
Upvotes: 1
Reputation: 172
You can use css selectors to select this link by attributes for example by ng-click, data-target, and href attributes
div.links > a[ng-click="loadModal('Photos')" data-target="#myModal" href="#"]
References and tutorials:
Upvotes: 0