Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » Selenium » Solved Programs » Launch Google in Selenium Automation

How to launch Google in Selenium Automation


package com.selenium.test;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class BrokenLinks {

public static void main(String[] args) {
	
WebDriver driver = new ChromeDriver();

driver.get("https://google.com");		

List <WebElement> links = driver.findElements(By.tagName("a"));
System.out.println("Total links = "+  links.size());

for (int i=0; i<links.size(); i++) {
	
	System.out.println(links.get(i).getAttribute("href"));
}
	
}

}