Recall & Review
beginner
What is the main purpose of reading test data from a CSV file in Selenium tests?
To separate test data from test scripts, making tests easier to maintain and allowing multiple data sets to be tested without changing the code.
Click to reveal answer
beginner
Which Python module is commonly used to read CSV files for test data?
The built-in
csv module is commonly used to read CSV files in Python.Click to reveal answer
beginner
How do you open a CSV file safely in Python to read test data?
Use a
with open('filename.csv', newline='') block to open the file. This ensures the file is properly closed after reading.Click to reveal answer
beginner
What is a simple way to loop through rows of a CSV file to use as test data?
Use
csv.reader(file) to get rows, then loop with for row in reader: to access each row's data.Click to reveal answer
beginner
Why is it better to use CSV files for test data instead of hardcoding data in Selenium scripts?
CSV files allow easy updates to test data without changing code, support multiple test cases, and help keep tests clean and organized.
Click to reveal answer
Which Python module helps read CSV files for Selenium test data?
✗ Incorrect
The csv module is designed to read and write CSV files easily.
What does the 'newline' parameter do when opening a CSV file in Python?
✗ Incorrect
Using newline='' prevents extra blank lines when reading CSV files on some platforms.
How do you access each row of data when reading a CSV file?
✗ Incorrect
csv.reader returns an iterable that you can loop through to get each row.
Why is separating test data from test scripts useful?
✗ Incorrect
Separating data allows updating test inputs without changing test code.
Which of these is NOT a benefit of using CSV files for test data?
✗ Incorrect
CSV files store data but do not run tests automatically.
Explain how to read test data from a CSV file in a Selenium Python test script.
Think about file handling and looping through data.
You got /4 concepts.
Why is it a good practice to keep test data in CSV files instead of hardcoding it in Selenium scripts?
Consider maintenance and reusability.
You got /4 concepts.