Recall & Review
beginner
What is the main benefit of reading test data from a JSON file in Selenium tests?
It separates test data from test scripts, making tests easier to maintain and reuse with different data sets.
Click to reveal answer
beginner
How do you load JSON data in Python for Selenium tests?
Use Python's built-in
json module with json.load() to read JSON data from a file.Click to reveal answer
beginner
Which Python statement correctly opens a JSON file named
data.json for reading?<pre>import json
with open('data.json', 'r') as file:
data = json.load(file)</pre>Click to reveal answer
intermediate
Why is it better to use JSON files for test data instead of hardcoding data in Selenium scripts?
Because JSON files allow easy updates without changing code, support multiple data sets, and improve test clarity.
Click to reveal answer
beginner
What is a common structure of JSON test data for a login test?
A list or dictionary with keys like
username and password for each test case.Click to reveal answer
Which Python module is used to read JSON files for test data?
✗ Incorrect
The
json module is designed to parse JSON data in Python.What is the correct way to open a JSON file named
testdata.json for reading?✗ Incorrect
Use mode 'r' to open a file for reading.
Why should test data be stored outside Selenium test scripts?
✗ Incorrect
Separating data from code improves maintainability and reusability.
Which of these is a valid JSON data type for test data?
✗ Incorrect
JSON supports objects (dictionaries), arrays, strings, numbers, booleans, and null.
What does
json.load(file) do in Python?✗ Incorrect
json.load() reads JSON from a file and parses it into Python data types.Explain how to read test data from a JSON file in a Selenium Python test.
Think about file handling and JSON parsing in Python.
You got /4 concepts.
Describe the advantages of using JSON files for test data in automated testing.
Consider maintainability and flexibility.
You got /4 concepts.