I am new to automation world and working on automating the BBC website . I have got number of links and also the text present in that links. . I want to click on a particular link with text "Accessibility Help". please advise how can i do it. following is my code:
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class BBC_AllLinks {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
WebDriver driver = new FirefoxDriver();
driver.get("http://www.bbc.com");
List<WebElement> allLinks = driver.findElements(By.tagName("a"));
//Total number of links in the webpage
System.out.println("Total Links--> "+allLinks.size());
//35th index
Thread.sleep(4000);
for (int i =0; i<=allLinks.size();i++)
System.out.println(allLinks.get(i).getText()+"----"+allLinks.get(i).isDisplayed());
}
}