Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to show how documentation helps repeat tests.
Testing Fundamentals
def test_login(): # Step 1: Open browser open_browser() # Step 2: Enter username enter_text('username_field', [1]) # Step 3: Enter password enter_text('password_field', 'pass123') # Step 4: Click login click_button('login') assert is_logged_in() == True
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using random or changing usernames that break repeatability.
✗ Incorrect
Documentation specifies exact inputs like 'admin_user' to ensure the test can be repeated exactly.
2fill in blank
mediumComplete the code to document the expected result for repeatability.
Testing Fundamentals
def test_add_item(): add_item('apple') result = get_cart_items() assert result == [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Expecting wrong or extra items in the cart.
✗ Incorrect
The documentation states the cart should contain only ['apple'] after adding it, ensuring repeatability.
3fill in blank
hardFix the error in the test to follow documented steps for repeatability.
Testing Fundamentals
def test_remove_item(): add_item('orange') remove_item([1]) result = get_cart_items() assert result == []
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Removing an item not added, causing test failure.
✗ Incorrect
The documented test adds 'orange' and removes 'orange' to ensure repeatability and correct results.
4fill in blank
hardFill both blanks to document a test that checks login failure with wrong password.
Testing Fundamentals
def test_login_fail(): enter_text('username_field', [1]) enter_text('password_field', [2]) click_button('login') assert is_logged_in() == False
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid usernames or correct passwords that break the test logic.
✗ Incorrect
Documentation specifies using 'admin_user' with 'wrong_pass' to test login failure repeatably.
5fill in blank
hardFill all three blanks to document a test that verifies item quantity update.
Testing Fundamentals
def test_update_quantity(): add_item([1]) update_quantity([2], [3]) result = get_item_quantity([2]) assert result == 5
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different item names or quantities than documented.
✗ Incorrect
Documentation uses 'apple' as item, updates quantity to 5, and checks that quantity for repeatability.