Selenium with Python: 2025 Easy Interview Quiz Quiz

  1. Question 1

    Which WebDriver method in Selenium Python finds the first matching element by its CSS selector, for example driver.find_element_by_css_selector('.login')?

    1. find_element_by_css_selector
    2. find_elements_by_tagname
    3. search_element_by_class
    4. fetch_element_by_xpath
    5. locate_by_selectors
  2. Question 2

    How can you input text 'Hello' into a text field named 'username' using Selenium Python?

    1. driver.find_element_by_name('username').send_keys('Hello')
    2. driver.find_by_text('username').type('Hello')
    3. browser.get_element('username').write('Hello')
    4. driver.search_element('username').put_text('Hello')
    5. element.send_text('username', 'Hello')
  3. Question 3

    Which of the following is the correct way to import the Selenium WebDriver module in a Python script?

    1. from selenium import webdriver
    2. import selenium.webdrivers as web
    3. from webdriver import selenium
    4. import seleniumdriver as sd
    5. from webdriver.selenium import Webdrive
  4. Question 4

    Which command will close the current browser window but keep the WebDriver session active?

    1. driver.close()
    2. driver.quit()
    3. driver.shutdown()
    4. driver.exit()
    5. driver.stop()
  5. Question 5

    What is the purpose of implicitly_wait() in Selenium Python?

    1. It sets a time to wait for elements to appear before throwing an exception.
    2. It pauses the script execution for a fixed number of seconds.
    3. It waits until a specific event is triggered by JavaScript.
    4. It waits until all images on the page are loaded.
    5. It refreshes the page after a set duration.
  6. Question 6

    Which method can be used to select a value from a dropdown element in a Selenium Python script?

    1. Select(driver.find_element_by_id('dropdown')).select_by_visible_text('Option 1')
    2. driver.select_option('dropdown', 'Option 1')
    3. select_value('dropdown', 'Option 1')
    4. element.choose_by_text('Option 1')
    5. driver.dropdown('dropdown').select('Option 1')
  7. Question 7

    If you want Selenium Python to navigate to a specific web address, which command should you use?

    1. driver.get('http://example.com')
    2. driver.open('http://example.com')
    3. browser.goto('http://example.com')
    4. navigate.to('http://example.com')
    5. driver.url('http://example.com')
  8. Question 8

    Which exception is raised when Selenium Python fails to find an element by the given locator?

    1. NoSuchElementException
    2. ElementNotVisibleException
    3. AttributeError
    4. NoElementFound
    5. NotAnElementError
  9. Question 9

    How do you maximize the browser window in Selenium Python after starting the driver?

    1. driver.maximize_window()
    2. browser.fullscreen()
    3. window.maximize()
    4. driver.set_to_max()
    5. driver.expand_window()
  10. Question 10

    To upload a file using Selenium Python, what should you do if the file input element has the id 'upload'?

    1. driver.find_element_by_id('upload').send_keys('/path/to/file.txt')
    2. driver.upload_file('upload', '/path/to/file.txt')
    3. browser.attach_file('upload', '/path/to/file.txt')
    4. element.set_file('/path/to/file.txt')
    5. driver.add_attachment('upload', '/path/to/file.txt')