Selenium Setup and Hello Program
We are using bootstarp program to avoid unnecessary configuration,
Prerequisite :
1. Java 8
2. Eclipse/Intellij IDE
3. Maven
4. chromedriver.exe https://sites.google.com/a/chromium.org/chromedriver
Create maven project with following pom.xml
Let's create our first test program for Login in to web application.
Prerequisite :
1. Java 8
2. Eclipse/Intellij IDE
3. Maven
4. chromedriver.exe https://sites.google.com/a/chromium.org/chromedriver
Create maven project with following pom.xml
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.comviva.pacs.snd</groupId> <artifactId>sndargselenium</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.9.1</version> </dependency> </dependencies> </project>
Let's create our first test program for Login in to web application.
package com.itlifter.autotest.login; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class LoginTest { public static void main(String[] args) throws InterruptedException { System.setProperty("webdriver.chrome.driver", "C:\\Users\\nitin.kumar1\\Desktop\\learning\\testing\\selenium\\chromedriver_win32\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get("https://200.81.36.86/"); WebElement usernameField=driver.findElement(By.id("username")); WebElement passwordField=driver.findElement(By.id("password")); usernameField.sendKeys("Nitin"); passwordField.sendKeys("MyPassword"); WebElement loginButton=driver.findElement(By.id("signInBtn")); while(!loginButton.isEnabled()) { Thread.sleep(2000); } loginButton.click(); Thread.sleep(4000); driver.close(); } }
Comments
Post a Comment