I am testing a page similar to Google search where you would enter the search terms in the provided text box, and click Search, and the next page returns a bunch of results matching your search term. These results are all links to documents (doc files), and are random depending on your searched text. I am having a problem clicking on the first results link. I record the steps using selenium IDE, but when I run the tests, it fails on the point where it has to click on the first results link. The error I’m getting is:
Selenium.SeleniumException: ERROR: Command execution failure. Please search the forum at http://clearspace.openqa.org for error details from the log window. The error message is: Permission denied
I have tried this two ways:
selenium.Click("xpath=//html/body/form/div[2]/div[3]/div[3]/table/tbody/tr/td[2]/span/a/");
selenium.Click("xpath=//span[contains(@class,'ResultList_Title_Link')][1]/a");
When I right-click on the first results link, and do a inspect element, I see:
<w_lit_documenttitle wid="82e0-9888a350e66b">MEMORANDUM OF <span style="background-color:#FFFF66;color:#333333;font-weight:bold" name="wlCitedDoc" id="wlCitedDoc">LAW</span> COMPLAINT</w_lit_documenttitle>
The Xpath for the above is:
/html/body/form/div[2]/div[3]/div[3]/table/tbody/tr/td[2]/span/a/w_lit_documenttitle
i believe you have to do this in dynamic way as you are saying clicking on FIRST LINK.
after the results page loaded with all the results as a links,
// if the id’s are defined for every link you are going to click
String[] links = selenium.getAllLinks();
for(String link : links)
selenium.click(link);
//if no id’s are defined
selenium.getEval(“window.document.getElementsByTagName(‘a’)[0].click()”); //this is to click the first link
i hope this is what you are looking for