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')?
- find_element_by_css_selector
- find_elements_by_tagname
- search_element_by_class
- fetch_element_by_xpath
- locate_by_selectors
Question 2
How can you input text 'Hello' into a text field named 'username' using Selenium Python?
- driver.find_element_by_name('username').send_keys('Hello')
- driver.find_by_text('username').type('Hello')
- browser.get_element('username').write('Hello')
- driver.search_element('username').put_text('Hello')
- element.send_text('username', 'Hello')
Question 3
Which of the following is the correct way to import the Selenium WebDriver module in a Python script?
- from selenium import webdriver
- import selenium.webdrivers as web
- from webdriver import selenium
- import seleniumdriver as sd
- from webdriver.selenium import Webdrive
Question 4
Which command will close the current browser window but keep the WebDriver session active?
- driver.close()
- driver.quit()
- driver.shutdown()
- driver.exit()
- driver.stop()
Question 5
What is the purpose of implicitly_wait() in Selenium Python?
- It sets a time to wait for elements to appear before throwing an exception.
- It pauses the script execution for a fixed number of seconds.
- It waits until a specific event is triggered by JavaScript.
- It waits until all images on the page are loaded.
- It refreshes the page after a set duration.
Question 6
Which method can be used to select a value from a dropdown element in a Selenium Python script?
- Select(driver.find_element_by_id('dropdown')).select_by_visible_text('Option 1')
- driver.select_option('dropdown', 'Option 1')
- select_value('dropdown', 'Option 1')
- element.choose_by_text('Option 1')
- driver.dropdown('dropdown').select('Option 1')
Question 7
If you want Selenium Python to navigate to a specific web address, which command should you use?
- driver.get('http://example.com')
- driver.open('http://example.com')
- browser.goto('http://example.com')
- navigate.to('http://example.com')
- driver.url('http://example.com')
Question 8
Which exception is raised when Selenium Python fails to find an element by the given locator?
- NoSuchElementException
- ElementNotVisibleException
- AttributeError
- NoElementFound
- NotAnElementError
Question 9
How do you maximize the browser window in Selenium Python after starting the driver?
- driver.maximize_window()
- browser.fullscreen()
- window.maximize()
- driver.set_to_max()
- driver.expand_window()
Question 10
To upload a file using Selenium Python, what should you do if the file input element has the id 'upload'?
- driver.find_element_by_id('upload').send_keys('/path/to/file.txt')
- driver.upload_file('upload', '/path/to/file.txt')
- browser.attach_file('upload', '/path/to/file.txt')
- element.set_file('/path/to/file.txt')
- driver.add_attachment('upload', '/path/to/file.txt')