This script opens a simple HTML page with a link, button, and input box. It gets and prints their attributes using get_attribute.
from selenium import webdriver
from selenium.webdriver.common.by import By
# Setup driver (make sure chromedriver is in PATH)
# Open a simple test page
html = '''
<html>
<body>
<a id="home-link" href="https://example.com/home" title="Home Page">Home</a>
<button id="submit-btn" disabled>Submit</button>
<input name="email" value="user@example.com" />
</body>
</html>
'''
# Load the HTML content
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless')
driver = webdriver.Chrome(options=options)
driver.get('data:text/html;charset=utf-8,' + html)
# Get attributes
link = driver.find_element(By.ID, 'home-link')
href = link.get_attribute('href')
title = link.get_attribute('title')
button = driver.find_element(By.ID, 'submit-btn')
disabled = button.get_attribute('disabled')
input_box = driver.find_element(By.NAME, 'email')
value = input_box.get_attribute('value')
print(f"Link href: {href}")
print(f"Link title: {title}")
print(f"Button disabled attribute: {disabled}")
print(f"Input value: {value}")
driver.quit()