Interview Questions

How to launch website using Selenium Web Driver?

package in.techdive.automation.ui;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;

/**
 * Selenium automation to Launch Techdive.in Website and open the 'Contact Us'
 * link.
 */

public class MyFirstAutomation {

        public static void main(String[] args) {

                System.out.println("IEDriverServer.exe loaded from C:/ drive...");
                System.setProperty("webdriver.ie.driver", "C:/IEDriverServer.exe");

                WebDriver driver = new InternetExplorerDriver();

                // And now use this to visit Techdive.in
                System.out.println("Waiting to load techdive.in...");
                driver.get("http://www.techdive.in");

                // Find the Contact Us Link element by its name and click
                System.out.println("Ready to click 'Contact Us' link...");
                WebElement element = driver.findElement(By.linkText("Contact Us1"));
                element.click();
                System.out.println("Contact Us Link clicked...");

                driver.findElement(By.id("edit-submit")).click();

                driver.close();
                driver.quit();
        }
}

0
No votes yet
Your rating: None