Automation in Selenium (JAVA)

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/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: