Sammidbest
Sammidbest

Reputation: 515

Unable to locate the correct element using xpath

I am facing issue in selecting a particular drop down from the webpage. enter image description here

I need to select the second highlighted div tag in the image above.

The xpath that I am trying to use is:

//div[@class='page-container']//table//div[@class='ui-multiselect-selected-container']

Kindly suggest how can I edit the xpath to select the second div tag.

I am new to xpaths and any help will be appreciated.

Upvotes: 0

Views: 187

Answers (2)

bindul
bindul

Reputation: 66

The second row has a tr class. When you use //div[@class='page-container']//table//div[@class='ui-multiselect-selected-container'] since your are referring to relative div(using //) it points to 1st element found by default.

I see that the tr element for the second multiselect has a class attribute, which makes unique so, this will be //div[@class='page-container']//table//tr[@class='rowRelativeTo']//div[@class='ui-multiselect-selected-container']

You can also use the style elements which are unique: //div[@class='page-container']//table//tr[@class='rowRelativeTo']//div[@style='float:right'] /div[@class='ui-multiselect-selected-container']

Upvotes: 0

Prasad
Prasad

Reputation: 25

I think the below xpath should work to locate the second instance

(//div[@class='ui-multiselect-selected-container'])[2] 

Upvotes: 1

Related Questions