I am new to Seleniun WebDriver and Python, and my question can be quite simple.
So, I have the following HTML code:
<a class="wp-first-item" href="admin.php?page=account">Account</a>
And I'm trying to extract href from it, to be an XPath tool, knowing that its XPath ".//*[@id='toplevel_page_menu']/ul/li[2]/a".
How should I do it?
driver.find_element_by_xpath(".//*[@id='toplevel_page_menu']/ul/li[2]/a").link
or
driver.find_element_by_xpath(".//*[@id='toplevel_page_menu']/ul/li[2]/a").href
It doesn't seem to work, resulting in:
AttributeError: 'WebElement' object has no attribute 'link'
I expect the result to be like "admin.php?page=account".
source
share