0
0
Selenium Pythontesting~10 mins

Full page screenshot 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 take a screenshot using Selenium in Python.

Selenium Python
driver = webdriver.Chrome()
driver.get('https://example.com')
driver.save_screenshot('[1]')
driver.quit()
Drag options to blanks, or click blank then click option'
Aimage.bmp
Bfullpage.png
Cscreenshot.jpg
Dcapture.gif
Attempts:
3 left
💡 Hint
Common Mistakes
Using unsupported image formats like .gif or .bmp
Forgetting to provide a filename
Using incorrect method names
2fill in blank
medium

Complete the code to scroll the page before taking a screenshot.

Selenium Python
driver = webdriver.Chrome()
driver.get('https://example.com')
driver.execute_script('[1]')
driver.save_screenshot('fullpage.png')
driver.quit()
Drag options to blanks, or click blank then click option'
Awindow.scrollBy(0, -100)
Bwindow.scrollTo(0, 0)
Cwindow.scrollTo(0, document.body.scrollHeight)
Dwindow.scrollBy(100, 0)
Attempts:
3 left
💡 Hint
Common Mistakes
Scrolling to the top instead of bottom
Using negative scroll values incorrectly
Not scrolling at all before screenshot
3fill in blank
hard

Fix the error in the code to correctly take a screenshot using Selenium in Python.

Selenium Python
driver = webdriver.Chrome()
driver.get('https://example.com')
full_screenshot = driver.get_screenshot_as_file('[1]')
print('Screenshot saved:', full_screenshot)
driver.quit()
Drag options to blanks, or click blank then click option'
Afullpage.png
Bscreenshot.txt
Cimage.jpeg
Dcapture.pdf
Attempts:
3 left
💡 Hint
Common Mistakes
Using unsupported file extensions
Confusing method names for screenshots
Not checking the return value of the screenshot method
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that stores element IDs and their text content for all elements with class 'item'.

Selenium Python
elements = driver.find_elements(By.CLASS_NAME, '[1]')
texts = {element.get_attribute('[2]'): element.text for element in elements}
Drag options to blanks, or click blank then click option'
Aitem
Bid
Cclass
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong attribute names like 'class' or 'name'
Mixing up class name and id attribute
Not using dictionary comprehension syntax correctly
5fill in blank
hard

Fill all three blanks to filter elements with text length greater than 5 and save their IDs and texts in a dictionary.

Selenium Python
elements = driver.find_elements(By.CLASS_NAME, '[1]')
filtered = {element.get_attribute('[2]'): element.text for element in elements if len(element.text) [3] 5}
Drag options to blanks, or click blank then click option'
Aitem
Bid
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators
Using wrong attribute names
Not filtering elements correctly