KGGGGG
KGGGGG

Reputation: 11

Using selenium webdriver to find list element

I have a list element with a following href link:

<li data-bind="css: { disabled: HasNext{age() == false }" class="disabled">
<a href="#" title="Go to next page" data-bind="click: function() { if(HasNextPage()) updateCurrentPage(CurrentPage() + 1) }">Next</a>
</li>

In testing, I am trying to determine whether an element with the title 'Go to next page' exists within a list element that has the class 'disabled'. The class 'disabled' appears and disappears depending on the page.

Using Selenium Webdriver, how do I determine if there is an element with the class disabled, is immediately followed by an element that has the title 'Go to next page'?

this.Driver.FindElement(By.ClassName("disabled"));
this.Driver.FindElement(By.CssSelector("[title*='Go to next page']"));

thanks in advance!

Upvotes: 1

Views: 1253

Answers (2)

PrateekSethi
PrateekSethi

Reputation: 56

The Xpath you can use to access the list items is:

//li[@class = 'disabled']/child::a[@title = 'Go to next page']

Upvotes: 0

Kirill Polishchuk
Kirill Polishchuk

Reputation: 56162

You can use XPath:

//li[@class = 'disabled'][a/@title = 'Go to next page']

Upvotes: 3

Related Questions