Quality Testing

Quality is delighting customers

Hi Friends , I am unable to make an automation script (Using webdriver + java). My test case is : After login into website , I have to check all links of all pages only at a time leaving out "Logout". Right Now I am able to test only opened page links successfully. please help me.

Views: 137

Reply to This

Replies to This Discussion

Hi Dilip,

It may help you. If not please let me know. :)

List<WebElement> linksize = driver.findElements(By.tagName("a"));
linksCount = linksize.size();
System.out.println("Total no of links Available: "+linksCount);
links= new String[linksCount];
System.out.println("List of links Available: ");

// print all the links from webpage
for(int i=0;i<linksCount;i++)
links[i] = linksize.get(i).getAttribute("href");

Hi Vishal ,

         Thank you to reply. Your code is working fine to get links of opened page . I have to check nested links . Means  when I open page I do login and then get all links . Now each link has a new page which also contains many links . I have to store all links (May be some duplicate no problem). After storing all links of my application I have to check status code of all links (Leaving out "Logout Link").


Hi Dilip,

I do understand your issue. However, I'll try mentioned code in my script and revert back to you :)


Vishal D.

HI Dilip,

I have tried this code with my script. However it is working fine on my side. Just to confirm have you used 'driver.findElements it works with Elements only.. :) wish you good luck 



Vishal D


TTWT Magazine





© 2021   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service