Reading multiple data from excel in Selenium POM pattern

Hi Lakshya

Thanks for your all  tutorials and they are very much informative

I have problem which holding me back to proceed to build the framework using POM( reference

I have loginpage with username , password and login button, for username and password data is retrieved from excel sheet which contains multiple user name and password


My requirement is for each row i.e. for user name and password I need to put pass or fail status in excel sheet and take screenshot

Below are the screenshot of my code

Can you please advise or suggest how to proceed and what modification I need to do to my scripts


I have create two classes LoginPages.cs and LoginTest.cs


TestCase Execute UserName Password LoggedUserName
LoginAdmin Yes b Srikanth
LoginAdmin No srikanth.panchikarla@ovvagton.c c Srikanth
LoginAdmin No b Srikanth



I am logging out and logging in again so that next set of data can be entered

public LoginPages Login(string sheetname)

ExcelDataAccess s = new ExcelDataAccess();
DataSet ds=s.ReadExcel(sheetname);
foreach (DataRow item in ds.Tables[0].Rows)

string DisplayedUserName = item[“LoggedUserName”].ToString();
var executeModule = item[“Execute”].ToString();
if (executeModule == “Yes”)
//DisplayedUserName = item[“LoggedUserName”].ToString();
catch (Exception ex)
string msg = ex.Message;

return this;



public void AdminLogin()
LoginPages loginpage = new LoginPages(Driver).GoTo().LoginLinkClick();
// loginpage = new LoginPages(Driver).LoginAs(“LoginAdmin”);
loginpage = new LoginPages(Driver).Login(“LoginAdmin”);
Driver.GetScreenshot().SaveAsFile(_screenshotFolderPath, ImageFormat.Png);

Please let me know if you need any further information

Thanks and regards


Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.