How to use Selenium WebDriver in Java:
Selenium Program to Login to a Specific Web Page
// Java Program to Login to a specific Webpage
// Using Selenium WebDriver and ChromeDriver
// Importing package module to code fragment
package login_test;
// Importing required classes
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
// Main class
public class Test {
// Main driver method
public static void main(String[] args)
{
// Path of chrome driver
// that will be local directory path passed
System.setProperty(
"webdriver.chrome.driver",
"C:\\Users\\Admin\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
// URL of the login website that is tested
driver.get("https://auth.w3wiki.org/");
// Maximize window size of browser
driver.manage().window().maximize();
// Enter your login email id
driver.findElement(By.id("luser"))
.sendKeys("xyz@gmail.com");
// Enter your login password
driver.findElement(By.id("password"))
.sendKeys("xyz12345");
driver.findElement(By.className("signin-button"))
.click();
}
}
Code will perform these Below-mentioned steps:
- Chrome Driver will start successfully and Chrome browser will open.
- It will automatically open the w3wiki login page and add details for login.
- If the details are valid, it will redirect to its website.
Selenium WebDriver Tutorial | Working, Benefits and Limitations
Selenium WebDriver is one of the most important part of of the Selenium test suite and this Selenium WebDrive Tutorial will provide you with the answer to why it is the most important Selenium suite, along with all the basic concepts.
Selenium is an open-source program that automates web browsers. Selenium Webdriver is mainly used to execute the scripts according to the browser we are using. Selenium is a powerful tool for controlling web browsers through programs.
It is functional for all browsers, works on all major OS, and its scripts are written in various languages, i.e., Python, Java, C#, etc., we will be working with Python. Selenium has four major components Selenium IDE, Selenium RC, Selenium Web driver, and Selenium GRID.
Table of Content
- What is Selenium?
- Selenium Components
- What is Selenium WebDriver?
- Selenium WebDriver Framework Architecture
- Basic Steps in a Selenium WebDriver Script
- How Selenium WebDriver Works
- How to use Selenium WebDriver in Java:
- Benefits of Selenium WebDriver
- Limitations of Selenium WebDriver
Contact Us