Cross_Column

Friday, 30 January 2026

Selenium WebElement Operations



Selenium WebElement Operations in Python

๐Ÿงฉ Selenium WebElement Operations in Python

WebElement operations are actions performed on web elements such as buttons, input fields, checkboxes, links, and dropdowns. These operations form the core interaction layer of Selenium automation.


๐Ÿ–ฑ Click Operation

Used to click on buttons, links, checkboxes, and radio buttons.

driver.find_element(By.ID, "loginBtn").click()
---

⌨ Send Keys (Input Text)

Used to enter text into input fields.

driver.find_element(By.ID, "username").send_keys("admin")
driver.find_element(By.ID, "password").send_keys("12345")
---

๐Ÿงน Clear Text Field

Clears existing text from an input field.

driver.find_element(By.ID, "search").clear()
---

๐Ÿ“„ Get Text

Used to fetch visible text from an element.

text = driver.find_element(By.ID, "message").text
print(text)
---

๐Ÿท Get Attribute

Used to fetch attribute value of an element.

value = driver.find_element(By.ID, "email").get_attribute("value")
placeholder = driver.find_element(By.ID, "email").get_attribute("placeholder")
---

๐Ÿ‘ isDisplayed()

Checks whether element is visible on the UI.

status = driver.find_element(By.ID, "submit").is_displayed()
print(status)
---

⚙ isEnabled()

Checks whether element is enabled or disabled.

status = driver.find_element(By.ID, "submit").is_enabled()
print(status)
---

✔ isSelected()

Checks whether checkbox or radio button is selected.

status = driver.find_element(By.ID, "remember").is_selected()
print(status)
---
๐ŸŽฏ Best Practices:
  • Always use waits before operations
  • Verify element visibility before action
  • Use stable locators
  • Validate element state before click
  • Log every major action
---
๐ŸŽฏ Conclusion:

WebElement operations are the heart of Selenium automation. Mastering these methods allows you to build reliable, stable, and scalable automation frameworks.

No comments:

Post a Comment

Few More

Interview & Real-Time Examples

Advanced Selenium Automation Guide with Python ๐Ÿš€ Advanced Selenium Automation with Python...