package selenium.basics;
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.interactions.Actions;
public class ChromeTest {
public static void main(String[] args) {
//Task: Open google.com on Chrome Browser
String homepage="https://usa.m3.com";
System.out.println("Registering the driver");
//Register chrome driver
System.setProperty("webdriver.chrome.driver","/Users/gd/Downloads/Selenium/drivers/chromedriver");
//Open www.google.com
WebDriver driver = new ChromeDriver();
//Open url
System.out.println("Opening web page");
driver.get(homepage);
//Get title
String title = driver.getTitle();
System.out.println("Title:" + title);
String expectedTitle = "Connecting the Healthcare Community | M3 USA";
//Match title
if(expectedTitle.equals(title)) {
System.out.println("Title matched..");
}else {
System.out.println("Title is not correct");
}
//Clicking menus
Actions action = new Actions(driver);
WebElement integratedSolutionsMenuItem = driver.findElement(By.xpath("//*[@id=\"menu-item-22\"]/a"));
WebElement attractingSubItem = driver.findElement(By.xpath("//*[@id=\"menu-item-87\"]/a"));
action.moveToElement(integratedSolutionsMenuItem).click(attractingSubItem).build().perform();
}
}