Elsid
Elsid

Reputation: 243

Using Selenium webdriver Java to locate elements with unclear Id's classes

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

Answers (3)

Elsid
Elsid

Reputation: 243

Solved it this is what I got and it worked

driver.findElement(By.cssSelector(".links > a[ng-click*=Photos]"));

Upvotes: 0

agarora
agarora

Reputation: 15

This CSS selector should work, you can use By.CssSelector:

.links > a[ng-click*="Photos"]

Upvotes: 1

Ahmed Magdy
Ahmed Magdy

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:

  1. http://www.w3schools.com/css/css_attribute_selectors.asp
  2. http://www.sitepoint.com/web-foundations/attribute-selector-css-selector/

Upvotes: 0

Related Questions