0
0
Selenium Pythontesting~20 mins

Selenium installation (pip install selenium) in Selenium Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Selenium Installation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:00remaining
Understanding Selenium Installation

What is the correct command to install Selenium for Python using pip?

Apip install selenium
Bpip install selenium-python
Cpip install selenium3
Dpip install selenium-webdriver
Attempts:
2 left
💡 Hint

Think about the official package name on PyPI for Selenium.

Predict Output
intermediate
1:30remaining
Check Selenium Version After Installation

What will be the output of the following code snippet after installing Selenium?

Selenium Python
import selenium
print(selenium.__version__)
ARaises AttributeError
BRaises ModuleNotFoundError
CPrints 'selenium'
DPrints the installed Selenium version, e.g., '4.10.0'
Attempts:
2 left
💡 Hint

After successful installation, the selenium module has a __version__ attribute.

🔧 Debug
advanced
1:30remaining
Identify the Error When Selenium is Not Installed

What error will occur if you run this code without installing Selenium?

Selenium Python
from selenium import webdriver
browser = webdriver.Chrome()
ANameError: name 'webdriver' is not defined
BModuleNotFoundError: No module named 'selenium'
CAttributeError: module 'selenium' has no attribute 'webdriver'
DImportError: cannot import name 'webdriver'
Attempts:
2 left
💡 Hint

Think about what happens when Python cannot find the selenium package.

assertion
advanced
1:30remaining
Validating Selenium Installation in a Test Script

Which assertion correctly checks that Selenium is installed by verifying the version string is not empty?

Selenium Python
import selenium
version = selenium.__version__
Aassert version == None
Bassert version > 0
Cassert isinstance(version, str) and len(version) > 0
Dassert selenium.version != ''
Attempts:
2 left
💡 Hint

Check that the version is a non-empty string.

framework
expert
2:00remaining
Automating Selenium Installation Check in CI Pipeline

Which script snippet best ensures Selenium is installed before running tests in a CI pipeline?

A
try:
    import selenium
except ModuleNotFoundError:
    import subprocess
    subprocess.check_call(['pip', 'install', 'selenium'])
B
import selenium
print('Selenium installed')
C
pip install selenium
python -m unittest
D
if selenium not in sys.modules:
    pip install selenium
Attempts:
2 left
💡 Hint

Think about how to programmatically install a package if missing.