How to click on All links in web page in Selenium WebDriver

后端 未结 8 2014
余生分开走
余生分开走 2020-12-29 00:04

I have 10 different pages contain different links. How to click on all the links?

Conditions are : i) I don\'t know how many links are there ii) I want to count and

8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-29 00:46

    public static void main(String[] args) 
        {
            FirefoxDriver fd=new FirefoxDriver();
            fd.get("http:www.facebook.com");
            List links=fd.findElements(By.tagName("a"));
            System.out.println("no of links:" +links.size());
    
            for(int i=0;i

    This program clicks on a link, navigates back to the page and clicks the second link again.

提交回复
热议问题