39# How to Read Excel Column names User Login Scenario II Selenium Automation

Published: 26 May 2021
on channel: Knowledge Share
8,259
116

In this session you will more about Excel reading concepts
A Realtime example of passing user credentials from excel to web application in explained in this session in easy way.
You can download the program from the below Git hub repo or copy paste the program ( Program at the end of description box )


𝐃𝐨 𝐲𝐨𝐮 𝐰𝐚𝐧𝐭 𝐭𝐨 𝐥𝐞𝐚𝐫𝐧 𝐒𝐞𝐥𝐞𝐧𝐢𝐮𝐦 𝐀𝐮𝐭𝐨𝐦𝐚𝐭𝐢𝐨𝐧 𝐢𝐧 𝐯𝐞𝐫𝐲 𝐞𝐚𝐬𝐲 𝐰𝐚𝐲 ?
Learn Selenium in easy way by dividing the concepts in to Module wise. Below are the list of Modules wise learning, each contains max 4 to 5 videos that you can complete in 1 or 2 days.
🅽🅾🆃🅴
You have all practice programs pasted in the description on each video.
You have GitHub Repository where all the programs are stored at one place for your practice.
Links pasted at the end
𝐘𝐨𝐮 𝐜𝐚𝐧 𝐣𝐨𝐢𝐧 𝐛𝐞𝐥𝐨𝐰 𝐆𝐫𝐨𝐮𝐩 𝐟𝐨𝐫 𝐦𝐨𝐫𝐞 𝐮𝐩𝐝𝐚𝐭𝐞𝐬 𝐚𝐧𝐝 𝐟𝐨𝐫 𝐜𝐨𝐥𝐥𝐚𝐛𝐨𝐫𝐚𝐭𝐢𝐨𝐧
  / 4754296501308288  
𝐈𝐟 𝐲𝐨𝐮 𝐰𝐚𝐧𝐭 𝐭𝐨 𝐝𝐢𝐬𝐜𝐮𝐬𝐬 𝐨𝐫 𝐬𝐡𝐚𝐫𝐞 𝐨𝐫 𝐠𝐚𝐢𝐧 𝐤𝐧𝐨𝐰𝐥𝐞𝐝𝐠𝐞 𝐨𝐫 𝐭𝐫𝐨𝐮𝐛𝐥𝐞𝐬𝐡𝐨𝐨𝐭 𝐈𝐬𝐬𝐮𝐞𝐬 𝐛𝐲 𝐭𝐚𝐤𝐢𝐧𝐠 𝐡𝐞𝐥𝐩 𝐣𝐨𝐢𝐧 𝐭𝐡𝐞 𝐛𝐞𝐥𝐨𝐰 𝐅𝐨𝐫𝐮𝐦
https://chat.whatsapp.com/Drhb7GEZcrA...
𝐂𝐨𝐫𝐞 𝐉𝐚𝐯𝐚 𝐁𝐚𝐬𝐢𝐜 𝐂𝐨𝐧𝐜𝐞𝐩𝐭𝐬 𝐏𝐥𝐚𝐲𝐥𝐢𝐬𝐭
   • Core Java  
𝐎𝐎𝐏𝐒 𝐂𝐨𝐧𝐜𝐞𝐩𝐭𝐬 𝐏𝐥𝐚𝐲𝐥𝐢𝐬𝐭
   • OOPS Concepts in Java  
𝐅𝐫𝐚𝐦𝐞𝐰𝐨𝐫𝐤 𝐏𝐫𝐞-𝐫𝐞𝐪𝐮𝐢𝐬𝐢𝐭𝐞𝐬
   • Framework Pre-requisites  
𝐆𝐢𝐭𝐇𝐮𝐛 𝐑𝐞𝐩𝐨 𝐟𝐨𝐫 𝐒𝐞𝐥𝐞𝐧𝐢𝐮𝐦 𝐁𝐚𝐬𝐢𝐜 𝐏𝐫𝐨𝐠𝐫𝐚𝐦𝐬 𝐏𝐫𝐚𝐜𝐭𝐢𝐜𝐞
https://github.com/knowledgeshare-tec...
𝐆𝐢𝐭𝐇𝐮𝐛 𝐑𝐞𝐩𝐨 𝐟𝐨𝐫 𝐒𝐞𝐥𝐞𝐧𝐢𝐮𝐦 𝐅𝐫𝐚𝐦𝐞𝐰𝐨𝐫𝐤 𝐝𝐞𝐬𝐢𝐠𝐧 𝐜𝐨𝐧𝐜𝐞𝐩𝐭𝐬
https://github.com/knowledgeshare-tec...
𝐆𝐢𝐭𝐇𝐮𝐛 𝐑𝐞𝐩𝐨 𝐟𝐨𝐫 𝐂𝐨𝐫𝐞 𝐉𝐚𝐯𝐚 𝐩𝐫𝐨𝐠𝐫𝐚𝐦𝐬 𝐩𝐫𝐚𝐜𝐭𝐢𝐜𝐞
https://github.com/knowledgeshare-tec...

Program :
package excelRead_Write;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.concurrent.TimeUnit;

import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import io.github.bonigarcia.wdm.WebDriverManager;

public class ReadExcelUserLoginTest {

public static void main(String[] args) throws IOException, InterruptedException
{
File file=new File(System.getProperty("user.dir") + "\\TestData\\" + "Regression_TestData" + ".xlsx");
FileInputStream inputstream=new FileInputStream(file);
XSSFWorkbook wb=new XSSFWorkbook(inputstream);
XSSFSheet sheet=wb.getSheet("LoginDetails");
/* Open Login page */
WebDriverManager.chromedriver().setup();
WebDriver driver=new ChromeDriver();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.get("http://demowebshop.tricentis.com/login");
// Storing Values in to Variables ( In this case, Usernames and Passwords )
XSSFRow row=null;
XSSFCell cell=null;
String userName=null;
String password=null;
for (int i=1; iLT=sheet.getLastRowNum();i++)
{
row=sheet.getRow(i);
for ( int j=0;jLTrow.getLastCellNum();j++)
{
cell=row.getCell(j);
if(j==0) // We can use Column Name as well, will see in upcoming sessions
{
userName=cell.getStringCellValue();
}
if(j==1) // We can use Column Name as well, will see in upcoming sessions
{
password=cell.getStringCellValue();
}
}
driver.findElement(By.id("Email")).sendKeys(userName);
driver.findElement(By.id("Password")).sendKeys(password);
driver.findElement(By.xpath("//*[@value='Log in']")).click();
String result=null;
try
{
Boolean isLoggedIn=driver.findElement(By.xpath("//a[text()='Log out']")).isDisplayed();
if(isLoggedIn==true)
{
result="PASS";
}
System.out.println("User Name : " + userName + " --- " + "Password : " + password + "---- Login success ? ------ " + result);
//System.out.println("Login successfull : " + isLoggedIn);
driver.findElement(By.xpath("//a[text()='Log out']")).click();
}
catch(Exception e)
{
Boolean isError=driver.findElement(By.xpath("//*[text()='The credentials provided are incorrect']")).isDisplayed();
if(isError==true)
{
result="FAIL";
}
System.out.println("User Name : " + userName + " --- " + "Password : " + password + "---- Login success ? ------ " + result);
}
Thread.sleep(1000);
driver.findElement(By.xpath("//a[text()='Log in']")).click();
}
}
}


Watch video 39# How to Read Excel Column names User Login Scenario II Selenium Automation online without registration, duration hours minute second in high quality. This video was added by user Knowledge Share 26 May 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 8,25 once and liked it 11 people.