I need to click on the below href element,which is present among similar href elements.
<a id="oldcontent" href="listDetails.do?camp=1865"><u>Re-Call</u></a>
Can anyone provide me xpath to click the above href link?
I need to click on the below href element,which is present among similar href elements.
<a id="oldcontent" href="listDetails.do?camp=1865"><u>Re-Call</u></a>
Can anyone provide me xpath to click the above href link?
Try below locator.
selenium.click("css=a[href*='listDetails.do'][id='oldcontent']");
or
selenium.click("xpath=//a[contains(@href,'listDetails.do') and @id='oldcontent']");
This works properly try this code-
selenium.click("xpath=//a[contains(@href,'listDetails.do') and @id='oldcontent']");
This will get you the generic link:
selenium.FindElement(By.XPath("xpath=//a[contains(@href,'listDetails.do')")).Click();
If you want to have it specify a parameter then you will have to test for each one:
...
int i = 1;
selenium.FindElement(By.XPath("xpath=//a[contains(@href,'listDetails.do?camp=" + i.ToString() + "')")).Click();
...
The above could utilize a for loop which navigates to and from each camp numbers' page, which could verify a static list of camps.
Please excuse if the code is not perfect, I have not tested myself.
what worked for me:
//a[contains(@href,'logout')]
have you tried:
//a[@id='oldcontent']/u[text()='Re-Call']
Below works fine.
//a[@id='oldcontent']
If you've tried certain ones and they haven't worked, then let us know, otherwise something simple like this should work.
//a[@href='listDetails.do?camp=1865']
, note that it looks like the integer at the end is a unique ID, so you will need to cater for this. Do you get the element returned if you do a blanket contains search? //a[contains(@href, 'listDetails.do')]
–
Brace document.getElementById(id);
you will get inconsistent results depending on the browser/version. I would HIGHLY recommend fixing the invalid DOM first. –
Stoner Best way to locate anchor elements is to use link=Re-Call
:
selenium.click("link=Re-Call");
It will work..
© 2022 - 2024 — McMap. All rights reserved.