sara
sara

Reputation: 39

How to find the "href" of the last <tr> element?

ImageI am trying to get the "href" of a particular frame which you can find in the image , i tried as much as i can but i am not able to get the "href"

List<WebElement> list=d.findElements(By.xpath("html/body/table/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr/td/form/table/tbody/tr[52]/td"));

                   for(WebElement e : list){
                       String link = e.getAttribute("href");
                      System.out.println(link);

I tried the above code , i took the Xpath of that frame and tried to get the href of that frame . Link: "https://iaeme.com/ijciet/issues.asp?VType=8&IType=10&JType=IJCIET&PageNumber=1"

Upvotes: 1

Views: 81

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193268

As per the xpath you shared to get all the "href" attributes you can use the following code block :

List<WebElement> list = d.findElements(By.xpath("//form[@name='form1']/table/tbody/tr[last()]/td/a"));
    for(WebElement e : list)
        System.out.println(e.getAttribute("href"));

Upvotes: 1

Related Questions