以下是该元素后面的HTML:
<div id="app_banner_menu">
<ul class="AspNet-Menu">
<li><a data-bind="" url="/ParagonLS/Home/Page.mvc" tabDescription="Home" subTabDescription="" subTabMaxAllowed="0" targetEx="" rel="" subTabGroup="false" subTabGroupAdd="false" subTabStartIndex="" subTabGroupClose="false" fullWindow="False" hideAddressBar="False"><span id="home-nav" class="MenuIcons homeButton"></span></a></li>
<li>
<span id="search-nav" class="MenuIcons searchButton"></span>
<div>
<ul>
<li>
Search By Class
<ul>
<li><a data-bind="" url="/ParagonLS/Search/Property.mvc/Index/1" tabDescription="Residential Detached" subTabDescription="Criteria" subTabMaxAllowed="3" targetEx="" rel="" class=" SearchByClass1 " subTabGroup="true" subTabGroupAdd="true" subTabStartIndex="0" subTabGroupClose="true" fullWindow="False" hideAddressBar="False">Residential Detached</a></li>
<li><a data-bind="" url="/ParagonLS/Search/Property.mvc/Index/2" tabDescription="Residential Attached" subTabDescription="Criteria" subTabMaxAllowed="3" targetEx="" rel="" class=" SearchByClass2 " subTabGroup="true" subTabGroupAdd="true" subTabStartIndex="0" subTabGroupClose="true" fullWindow="False" hideAddressBar="False">Residential Attached</a></li>
这是我为实现相同目的而编写的代码,但是它不起作用。
resedential_detached_class = browser.find_element_by_xpath("//div[contains(text(),'Residential Detached')]").click()
如何仅选择该元素并单击打开它?它将带我到一个新页面。
答案 0 :(得分:0)
您尝试过这个硒标签吗?
resedential_detached_class = browser.find_element_by_link_text('Residential Detached')。click()