Code Written was in Eclipse LUNA
import org.openqa.selenium.safari.SafariDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.browserlaunchers.locators.InternetExplorerLocator;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class LoginTestCase {
public static void main(String[] args) {
//Creating the Firefox object
WebDriver driver = new FirefoxDriver();
// Opening the ABC WebSite.
driver.navigate().to(“https://ABCWebSite.com “);
//Showing the opened success message
String LoadMsg=”Successfully opened the ABC WebSite”;
JOptionPane.showMessageDialog(null,LoadMsg);
// Entering the User Name
WebElement UserName = driver.findElement(By.name(“txtErUsername”));
UserName.sendKeys(“ABCUser”);
// Entering the Password
WebElement PassWord = driver.findElement(By.name(“txtErPassword”));
PassWord.sendKeys(“Abc123”);
// Clicking on login button
WebElement login = driver.findElement(By.id(“BtnEm”));
login.click();
//Showing the Login success message
String LoginMsg=”Successfully login the ABC WebSite “;
JOptionPane.showMessageDialog(null,LoginMsg);
// Now moving towards the menu page
WebElement TopMenu = driver.findElement(By.className(“rmLeftImage”));
TopMenu.click();
}
}
Note: How to Configure Eclipse and Add Jar files can be learn from following link.
https://www.toolsqa.com/selenium-webdriver/download-and-start-eclipse/