How to use property file as a object repository in Selenium WebDriver Automation?

0 votes

How to use property files as an object repository in Selenium WebDriver Automation?

Jan 22 in Selenium by Neha
• 6,180 points
120 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Create any file & save it with .properties extension For example - Add new file in eclipse By right click on project > New > Fille and add below properties.

Username = xyz
Password = 123

Write Below code to access this file

String filepath = "./config.properties" ; // Path of .properties file
File f = new File(filepath); 
FileInputStream fs = new FileInputStream(f);

Properties pro = new Properties();
Pro.Load(fs);
pro.getProperty("Username"); // return value "xyz"  return type string 
pro.getProperty("Password"); // retun  value "123" return type string

Also, use-

driver.findelement(By.id("user")).sendKeys(pro.getProperty("Username"));
driver.findelement(By.id("pass")).sendKeys(pro.getProperty("Password"));
answered Jan 22 by Frankie
• 9,710 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How to use link as a locator to find element in selenium?

Hello @Jino, its amazing to explore ways ...READ MORE

answered Dec 21, 2018 in Selenium by Nabarupa
54 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
145 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
539 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
137 views
0 votes
1 answer

How to send ALT/SHIFT/CONTROL key in Selenium WebDriver?

When we generally use ALT/SHIFT/CONTROL keys, we ...READ MORE

answered Feb 8 in Selenium by Frankie
• 9,710 points
508 views
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.