Recall & Review
beginner
What does the 'find_element(By.NAME, "name")' method do in Selenium?
It locates the first web element on the page that has the specified 'name' attribute.
Click to reveal answer
beginner
How do you find an input field with the name 'username' using Selenium in Python?
Use: driver.find_element(By.NAME, "username") where 'driver' is your WebDriver instance.
Click to reveal answer
intermediate
Why is using 'name' attribute a good locator strategy?
Because 'name' attributes are often unique for form elements and stable, making tests reliable and easy to maintain.
Click to reveal answer
intermediate
What happens if 'find_element(By.NAME, "name")' does not find any element?
It raises a 'NoSuchElementException', indicating the element with that name does not exist on the page.
Click to reveal answer
beginner
Show a simple Selenium Python code snippet to find an element by name and enter text.
from selenium.webdriver.common.by import By
input_field = driver.find_element(By.NAME, "email")
input_field.send_keys("test@example.com")Click to reveal answer
Which Selenium method is used to find an element by its 'name' attribute in Python?
✗ Incorrect
To find an element by its 'name' attribute, use By.NAME with find_element.
What exception is raised if no element with the specified name is found?
✗ Incorrect
NoSuchElementException is raised when the element cannot be found.
Why might 'name' be preferred over 'id' for locating elements?
✗ Incorrect
Name attributes are often stable and meaningful, especially for form inputs.
Which import is necessary to use 'By.NAME' in Selenium Python?
✗ Incorrect
By is imported from selenium.webdriver.common.by to specify locator types.
What is the correct way to enter text into an element found by name 'password'?
✗ Incorrect
Use send_keys on the element found by name to enter text.
Explain how to find a web element by its 'name' attribute using Selenium in Python and handle the case when the element is not found.
Think about locating and error handling.
You got /3 concepts.
Describe why using the 'name' attribute as a locator can be beneficial in test automation.
Consider stability and clarity of locators.
You got /3 concepts.