Bird
0
0

Given this Selenium Python snippet:

medium📝 Predict Output Q5 of 15
Selenium Python - Cross-Browser Testing
Given this Selenium Python snippet:
if 'firefox' in driver.capabilities['browserName'].lower():
    print('Firefox workaround applied')
else:
    print('Standard flow')

What will be printed if the browser is Firefox?
AError: AttributeError
BStandard flow
CNo output
DFirefox workaround applied
Step-by-Step Solution
Solution:
  1. Step 1: Convert browserName to lowercase

    driver.capabilities['browserName'].lower() returns 'firefox' for Firefox browser.
  2. Step 2: Check substring presence

    'firefox' in 'firefox' is True, so the if block executes printing 'Firefox workaround applied'.
  3. Final Answer:

    Firefox workaround applied -> Option D
  4. Quick Check:

    Substring check triggers workaround = C [OK]
Quick Trick: Use .lower() to avoid case issues in browser checks [OK]
Common Mistakes:
  • Not converting to lowercase causing false negatives
  • Expecting else block to run for Firefox
  • Misusing 'in' operator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes