Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- URL = http://web.com/user-portal
- ClickOnLoginLink = //*[@id='app']/div/main/section/ul/li[1]/a
- Email = //input[@name='username']
- Pwd = //input[@name='password']
- Submit = //button[@name='loginButton']
- package com.provider;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.ResultSetMetaData;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.util.ArrayList;
- import java.util.Properties;
- import oracle.net.ns.NetException;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.firefox.FirefoxDriver;
- import org.testng.annotations.BeforeSuite;
- public class BaseClass {
- static WebDriver driver;
- public void main (String[] args) throws ClassNotFoundException, SQLException, NetException {
- String driver_DBPath = "jdbc:oracle:thin:@Host:Port:SID";
- String DB_username = "*****";
- String DB_password = "*****";
- String Query = "select * from Table";
- Class.forName("oracle.jdbc.OracleDriver");
- Connection con = DriverManager.getConnection(driver_DBPath, DB_username, DB_password);
- Statement stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery(Query);
- }
- @BeforeSuite
- public void setup() throws InterruptedException, IOException{
- driver=new FirefoxDriver();
- driver.manage().window().maximize();
- Properties obj = new Properties();
- FileInputStream objfile = new FileInputStream(System.getProperty("user.dir") +"\src\com\provider\Object.Properties");
- obj.load(objfile);
- driver.get(obj.getProperty("URL"));
- }
- }
- package com.provider;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.util.Properties;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebElement;
- import org.testng.Assert;
- import org.testng.annotations.Test;
- public class ProApp extends BaseClass{
- @Test
- public void setUpConnection() throws ClassNotFoundException, SQLException, FileNotFoundException, InterruptedException, IOException {
- String driver_DBPath = "jdbc:oracle:thin:@Host:Port:SID";
- String DB_username = "*****";
- String DB_password = "*****";
- String Query = "select * from Table";
- Connection con = DriverManager.getConnection(driver_DBPath, DB_username, DB_password);
- Statement stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery(Query);
- while(rs.next()){
- String Email = rs.getString("CLAIM_NUMBER");
- String Pwd = rs.getString("INDIVIDUAL_NUM");
- testUserNamePassword(Email, Pwd);
- }
- }
- @Test(priority=1)
- public void clickLoginLink() throws InterruptedException, IOException {
- Properties obj = new Properties();
- FileInputStream objfile = new FileInputStream(System.getProperty("user.dir") +"\src\com\provider\Object.Properties");
- obj.load(objfile);
- Thread.sleep(1000);
- driver.findElement(By.xpath(obj.getProperty("ClickOnLoginLink"))).click();
- Thread.sleep(1000);
- }
- @Test(priority=2)
- public void testUserNamePassword(String Email1, String Pwd1) throws InterruptedException, IOException {
- Thread.sleep(1000);
- Properties obj = new Properties();
- FileInputStream objfile = new FileInputStream(System.getProperty("user.dir") +"\src\com\provider\Object.Properties");
- obj.load(objfile);
- Thread.sleep(1000);
- driver.findElement(By.xpath(obj.getProperty("Email"))).clear();
- Thread.sleep(1000);
- driver.findElement(By.xpath(obj.getProperty("Email"))).sendKeys(Email1);
- Thread.sleep(1000);
- driver.findElement(By.xpath(obj.getProperty("Pwd"))).clear();
- Thread.sleep(1000);
- driver.findElement(By.xpath(obj.getProperty("Pwd"))).sendKeys(Pwd1);
- Thread.sleep(1000);
- driver.findElement(By.xpath(obj.getProperty("Submit"))).click();
- Thread.sleep(1000);
- }
- @Test(priority=3)
- public void loginVerify() throws InterruptedException, IOException{
- Properties obj = new Properties();
- FileInputStream objfile = new FileInputStream(System.getProperty("user.dir") +"\src\com\provider\Object.Properties");
- obj.load(objfile);
- Assert.assertEquals("Wel Come To Testing World!!!", driver.findElement(By.xpath(obj.getProperty("WelComeToTestingWorld"))).getText());
- }
- @Test(priority=4)
- public void logonVerify() throws InterruptedException, IOException{
- Properties obj = new Properties();
- FileInputStream objfile = new FileInputStream(System.getProperty("user.dir") +"\src\com\provider\Object.Properties");
- obj.load(objfile);
- WebElement DashboardHeader = driver.findElement(By.xpath(obj.getProperty("WelComeToTestingWorld")));
- DashboardHeader.getText().equals("Wel Come To Testing World!!!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement