Reputation: 35
I'm trying to click the second element where "class=uiComposerAttachment photoAttachment"
Upvotes: 0
Views: 3274
Reputation: 2002
As class is same, you need to identify element as per position. This is second element that you mentioned, so you can use
xpath=(//*[@class="uiComposerAttachment photoAttachment"])[2]
Upvotes: 0
Reputation: 25056
Something different from XPath, is using the nth-child
locator in CSS. Note this isn't supported in IE8 and below, but other modern browsers will be fine. Example to get the 2nd element:
css=*.uiComposerAttachment:nth-child(2)
Upvotes: 2
Reputation: 2337
If there are multiple elements with same xpath you can try below format of xpath to click the desired element.
As per your application, you have 2 elements with same xpath. So you can use the below xpath to click on the second element.
xpath=(//select[@name='listPartition'])[position()=2]
Upvotes: 0
Reputation: 4318
You have to find the Xpath of the class and use the Xpath then try.
click | //*[@class='uiComposerAttachment photoAttachment']
Use this in the selenium IDE
Can you provide snapshot, how you find the Xpath of the class
Upvotes: 1
Reputation: 5667
try this
//*[@class='uiComposerAttachment photoAttachment'][2]
Upvotes: 0