In the Python Selenium module, once I have a WebElement
object I can get the value of any of its attributes with get_attribute()
:
f
You can find using element.get_property() method.
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://www.ultimateqa.com/complicated-page/")
logo = driver.find_element(By.XPATH, "//img[@id='logo']")
attrs=[]
for attr in logo.get_property('attributes'):
attrs.append([attr['name'], attr['value']])
print(attrs)
Output:
[['src', 'https://www.ultimateqa.com/wp-content/uploads/2019/01/horizontal_on_transparent_by_logaster-2.png'], ['alt', 'Ultimate QA'], ['id', 'logo'], ['data-height-percentage', '100'], ['data-actual-width', '912'], ['data-actual-height', '410']]