0
<a ui-sref="apps.service" href="#/apps/service"> <i class="glyphicon glyphicon-list icon zoom-icon text-info-dker"></i> <span class="font-bold"> Service</span> </a> 

How can I locate the element?

driver.findElement(By.partialLinkText("service")).click(); driver.findElement(By.xpath("ui[href$=services]")); 

4 Answers 4

1

partialLinkText is case sensitive. Try

driver.findElement(By.partialLinkText("Service")).click(); 

The element is in <a> tag, not <ui> tag

driver.findElement(By.xpath(".//a[href*='services']")); 
Sign up to request clarification or add additional context in comments.

Comments

0

You should try using xpath with WebDriverWait to wait until element visible and enable as below :-

new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.xpath(".//a[contains(.,'Service')]"))).click(); 

Comments

0

It is better to use contains in to locate element in this xpath. The below xpath will be accurate.

driver.findElement(By.xpath("//a/span[contains(text(),'Service')]")

Comments

0

This XPath,

//a[normalize-space() = 'Service'] 

will select all a elements whose normalized string value equals "Service" -- perfect for the example you show.

Be wary of solutions based upon contains() as they will also match strings that include additional leading or trailing text, which may or may not be what you want.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.