【发布时间】:2013-03-13 14:25:52
【问题描述】:
我对 Seleniun WebDriver 和 Python 比较陌生,我的问题可能有点基本。
所以,我有以下 HTML 代码:
<a class="wp-first-item" href="admin.php?page=account">Account</a>
并且我正在尝试从中提取href,使用XPath,知道它的XPath 是".//*[@id='toplevel_page_menu']/ul/li[2]/a"。
我该怎么做?
driver.find_element_by_xpath(".//*[@id='toplevel_page_menu']/ul/li[2]/a").link
或
driver.find_element_by_xpath(".//*[@id='toplevel_page_menu']/ul/li[2]/a").href
似乎不起作用,导致:
AttributeError: 'WebElement' object has no attribute 'link'
我希望结果类似于"admin.php?page=account"。
【问题讨论】:
标签: python python-2.7 selenium-webdriver