0
0
Selenium Pythontesting~10 mins

Reading test data from Excel in Selenium Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the library needed to read Excel files.

Selenium Python
import [1]
Drag options to blanks, or click blank then click option'
Aopenpyxl
Bselenium
Crequests
Dunittest
Attempts:
3 left
💡 Hint
Common Mistakes
Importing selenium instead of openpyxl
Trying to import unittest for Excel reading
2fill in blank
medium

Complete the code to load the Excel workbook named 'data.xlsx'.

Selenium Python
workbook = openpyxl.[1]('data.xlsx')
Drag options to blanks, or click blank then click option'
AWorkbook
Bopen_workbook
Cread_excel
Dload_workbook
Attempts:
3 left
💡 Hint
Common Mistakes
Using Workbook which creates a new file
Using read_excel which is not in openpyxl
3fill in blank
hard

Fix the error in accessing the active sheet from the workbook.

Selenium Python
sheet = workbook.[1]
Drag options to blanks, or click blank then click option'
Aget_active_sheet
Bactive
Cactive_sheet
Dsheet_active
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names like get_active_sheet()
Using incorrect property names like active_sheet
4fill in blank
hard

Fill both blanks to read the value from cell A1 in the active sheet.

Selenium Python
value = sheet.[1]('[2]').value
Drag options to blanks, or click blank then click option'
Acell
BA1
C['A1']
Dcells
Attempts:
3 left
💡 Hint
Common Mistakes
Using cells instead of cell
Using incorrect cell address format
5fill in blank
hard

Fill all three blanks to create a dictionary of test data from Excel rows where column 1 is key and column 2 is value.

Selenium Python
test_data = {row[[1]].value: row[[2]].value for row in sheet.iter_rows(min_row=2)}
print(test_data[[3]])
Drag options to blanks, or click blank then click option'
A0
B1
C'username'
D'password'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up column indexes
Using value instead of key to print