Interacting with Elements: Click, Type, Read and Verify

Selenium 14 min min read Updated: Nov 16, 2026 Beginner
Interacting with Elements: Click, Type, Read and Verify
Beginner Topic 6 of 7

The Element Object

find_element returns a WebElement. You use its methods to act and its properties to read.

Actions

MethodWhat it does
click()Click
send_keys("text")Type text
clear()Empty a text box
submit()Submit the form that contains the element (older style)
send_keys(Keys.ENTER)Press a special key
python from selenium.webdriver.common.keys import Keys box = driver.find_element(By.NAME, "q") box.clear() box.send_keys("selenium python") box.send_keys(Keys.ENTER)
Special keyUse
Keys.ENTERSubmit
Keys.TABMove to next field
Keys.ESCAPEClose pop-up
Keys.BACKSPACEDelete a character
Keys.CONTROL, 'a'Select all (combination)
Keys.PAGE_DOWNScroll
python box.send_keys(Keys.CONTROL, "a") # select all box.send_keys(Keys.BACKSPACE) # delete

Reading Information

PropertyReturns
element.textVisible text (hidden text is empty)
element.get_attribute("value")Attribute such as value, href, class, placeholder
element.get_dom_attribute("href")The attribute exactly as written in HTML
element.get_property("checked")Live JavaScript property
element.tag_nameinput, div ...
element.size{'height': 40, 'width': 200}
element.location{'x': 10, 'y': 80}
element.value_of_css_property("color")A style value
python link = driver.find_element(By.LINK_TEXT, "Elemental Selenium") print(link.text) print(link.get_attribute("href")) print(link.value_of_css_property("color")) box = driver.find_element(By.ID, "username") box.send_keys("ana") print(box.get_attribute("value")) # text typed in the box (not .text!)
text vs value: For an input box, .text is empty. The typed text is in get_attribute("value").

State Checks

MethodTrue when
is_displayed()Element is visible
is_enabled()Element is not disabled
is_selected()Checkbox, radio or option is selected
python driver.get("https://the-internet.herokuapp.com/dynamic_controls") checkbox = driver.find_element(By.CSS_SELECTOR, "#checkbox-example input") print(checkbox.is_displayed()) # True print(checkbox.is_selected()) # False field = driver.find_element(By.CSS_SELECTOR, "#input-example input") print(field.is_enabled()) # False (disabled at start)

Reading Many Elements

python items = driver.find_elements(By.CSS_SELECTOR, ".inventory_item_name") names = [i.text for i in items] print(names) assert names == sorted(names)

A Complete Example

python driver.get("https://www.saucedemo.com") driver.find_element(By.ID, "user-name").send_keys("standard_user") driver.find_element(By.ID, "password").send_keys("secret_sauce") driver.find_element(By.ID, "login-button").click() assert "inventory" in driver.current_url assert driver.find_element(By.CLASS_NAME, "title").text == "Products" products = driver.find_elements(By.CLASS_NAME, "inventory_item") print("Products on page:", len(products))

Typing Into Hidden or Special Fields

  • Date fields often need a format such as 01012026 or 2026-01-01
  • If clear() does not work (React sites), use Ctrl+A then Backspace
  • If a click is intercepted by another element, wait for it to disappear or scroll (see waits and JavaScript lessons)

Conclusion

Use click, send_keys and clear to act, and text, get_attribute, is_displayed, is_enabled and is_selected to read and verify. Remember that typed input is in the value attribute.

Quick Summary: Act: click/send_keys/clear. Read: text/get_attribute. Check: is_displayed/is_enabled/is_selected.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators