Complete the code to get the value of the "href" attribute from the link element.
link = driver.find_element(By.ID, "home-link") href_value = link.get_attribute([1]) print(href_value)
The get_attribute method requires the attribute name as a string. To get the URL, use "href".
Complete the code to check if the "disabled" attribute is present on the button element.
button = driver.find_element(By.CSS_SELECTOR, ".submit-btn") disabled_attr = button.get_attribute([1]) if disabled_attr: print("Button is disabled") else: print("Button is enabled")
The "disabled" attribute indicates if a button is disabled. Use "disabled" to check its presence.
Fix the error in the code to correctly get the "placeholder" attribute from the input element.
input_box = driver.find_element(By.NAME, "email") placeholder_text = input_box.get_attribute([1]) print(placeholder_text)
The attribute name must be a string with quotes. Without quotes, it causes a NameError.
Fill both blanks to create a dictionary of element IDs and their "title" attributes for all elements with class "item".
elements = driver.find_elements(By.CLASS_NAME, "item") titles = {element.get_attribute([1]): element.get_attribute([2]) for element in elements} print(titles)
Use "id" to get element IDs and "title" to get the title attribute values.
Fill all three blanks to filter elements with a "data-status" attribute equal to "active" and create a list of their "name" attributes.
elements = driver.find_elements(By.TAG_NAME, "div") active_names = [element.get_attribute([1]) for element in elements if element.get_attribute([2]) == [3]] print(active_names)
Get the "name" attribute for the list. Filter elements where "data-status" equals "active".