Bird
0
0

Which of the following shows the correct way to use pytest's parametrize decorator for multiple parameters in Selenium tests?

easy📝 Syntax Q3 of 15
Selenium Python - Data-Driven Testing
Which of the following shows the correct way to use pytest's parametrize decorator for multiple parameters in Selenium tests?
A@pytest.parametrize('username password', [('user1', 'pass1'), ('user2', 'pass2')])
B@pytest.mark.parametrize('username, password', [('user1', 'pass1'), ('user2', 'pass2')])
C@pytest.mark.parametrize(['username', 'password'], ['user1', 'pass1'])
D@pytest.parametrize('username, password', 'user1', 'pass1')
Step-by-Step Solution
Solution:
  1. Step 1: Syntax of parametrize

    pytest.mark.parametrize takes a string of comma-separated parameter names and a list of tuples with values.
  2. Step 2: Verify options

    @pytest.mark.parametrize('username, password', [('user1', 'pass1'), ('user2', 'pass2')]) correctly uses the decorator with parameter names and a list of tuples.
  3. Final Answer:

    @pytest.mark.parametrize('username, password', [('user1', 'pass1'), ('user2', 'pass2')]) -> Option B
  4. Quick Check:

    Parametrize needs parameter names string and list of tuples [OK]
Quick Trick: Use comma-separated string and list of tuples in parametrize [OK]
Common Mistakes:
  • Misspelling 'parametrize' as 'parametrize'
  • Passing parameters as a list of strings instead of tuples
  • Using incorrect decorator syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes