0
0
Selenium Pythontesting~10 mins

Parameterize with test data 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 pytest module needed for parameterization.

Selenium Python
import [1]
Drag options to blanks, or click blank then click option'
Apytest
Bselenium
Crequests
Dunittest
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unittest instead of pytest
Forgetting to import any testing module
2fill in blank
medium

Complete the code to add the pytest decorator for parameterizing the test with two inputs.

Selenium Python
@pytest.mark.[1]("input,expected")
def test_example(input, expected):
    assert input + 1 == expected
Drag options to blanks, or click blank then click option'
Afixture
Bskip
Cmark
Dparametrize
Attempts:
3 left
💡 Hint
Common Mistakes
Using @pytest.mark.fixture instead
Misspelling the decorator name
3fill in blank
hard

Fix the error in the parameterized test data format by completing the code.

Selenium Python
@pytest.mark.parametrize("input,expected", [
    (1, 2),
    (2, [1]),
    (3, 4)
])
def test_add_one(input, expected):
    assert input + 1 == expected
Drag options to blanks, or click blank then click option'
A5
B3
C2
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong expected values that do not match input + 1
Syntax errors in the list of tuples
4fill in blank
hard

Fill both blanks to create a parameterized test that checks if a string contains a substring.

Selenium Python
@pytest.mark.parametrize("text,substring")
def test_contains(text, substring):
    assert [1] in [2]
Drag options to blanks, or click blank then click option'
Asubstring
Btext
Attempts:
3 left
💡 Hint
Common Mistakes
Reversing the order of substring and text
Using equality instead of 'in'
5fill in blank
hard

Fill all three blanks to create a parameterized test that checks if a number is within a range.

Selenium Python
@pytest.mark.parametrize("num,low,high")
def test_in_range(num, low, high):
    assert [1] <= [2] <= [3]
Drag options to blanks, or click blank then click option'
Alow
Bnum
Chigh
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping num with low or high
Using separate comparisons instead of chained