Recall & Review
beginner
What is a properties file in Selenium Java testing?
A properties file is a simple text file used to store configuration data like URLs, usernames, and passwords. It helps keep test settings separate from code, making tests easier to manage and update.
Click to reveal answer
beginner
How do you load a properties file in Java?
You use the <code>Properties</code> class and its <code>load()</code> method with a <code>FileInputStream</code>. This reads the key-value pairs from the file into the Properties object.Click to reveal answer
beginner
Why use a properties file instead of hardcoding values in Selenium tests?
Using a properties file allows easy updates to configuration without changing code. It supports running tests in different environments by just changing the file, improving flexibility and reducing errors.
Click to reveal answer
beginner
Show a simple example of a properties file content for Selenium tests.
Example:<br>url=https://example.com<br>username=testuser<br>password=pass123
Click to reveal answer
beginner
How do you retrieve a value from a loaded Properties object?
Use the
getProperty("key") method. For example, props.getProperty("url") returns the URL string stored in the properties file.Click to reveal answer
What is the main purpose of a properties file in Selenium Java tests?
✗ Incorrect
Properties files store configuration like URLs and credentials separately, making tests easier to maintain.
Which Java class is used to read a properties file?
✗ Incorrect
The Properties class provides methods to load and access key-value pairs from a properties file.
How do you access a value for a key 'username' from a Properties object named 'props'?
✗ Incorrect
The correct method to get a value by key is getProperty("key").
What file extension is commonly used for properties files?
✗ Incorrect
Properties files typically use the .properties extension.
Why is it better to use a properties file for URLs instead of hardcoding them?
✗ Incorrect
Using a properties file lets you change URLs easily without touching the test code.
Explain how to use a properties file to manage configuration in Selenium Java tests.
Think about separating data from code and how Java reads files.
You got /4 concepts.
Describe the benefits of using a properties file for test configuration compared to hardcoding values.
Consider what happens when URLs or credentials change.
You got /4 concepts.