I want to click on MAKE UP in the left navigation, Please find attached image and link for the webpage
I am currently using the below code to click on the item but not getting any result.I am able to acces the elements by class name('has-sub').I can even print them but cant click them
obc = driver.find_elements_by_class_name('has-sub')
for ea in obc:
if ea.text == "Makeup":
ea.click()
下面的更多信息是网页的html代码
<li class="has-sub" style="height: 38px;">
<a href="#">Makeup</a>
<ul class="submenu" style="top: 0px;">
<li>
<a id="SBN_facet_Face" href="http://shop.davidjones.com.au/djs/en/davidjones/beauty/face" escapexml="false">Face </a>
</li>
<li>
<a id="SBN_facet_Lips" href="http://shop.davidjones.com.au/djs/en/davidjones/beauty/lips" escapexml="false">Lips </a>
</li>
<li>
<a id="SBN_facet_Eyes" href="http://shop.davidjones.com.au/djs/en/davidjones/beauty/eyes" escapexml="false">Eyes </a>
</li>
<li>
<a id="SBN_facet_Nails" href="http://shop.davidjones.com.au/djs/en/davidjones/beauty/nails" escapexml="false">Nails </a>
</li>
<li>
<a id="SBN_facet_Brushes & Tools" href="http://shop.davidjones.com.au/djs/en/davidjones/beauty/beauty-brushes-accessories" escapexml="false">Brushes & Tools </a>
</li>
<li>
<a id="SBN_facet_Makeup" href="http://shop.davidjones.com.au/djs/en/davidjones/beauty/beauty-makeup" escapexml="false">All Makeup </a>
</li>
</ul>
</li>`enter code here`
任何帮助都将不胜感激
这里的问题是,您试图在文本位于元素下时单击该元素。所以你需要做的是:
我在你的网页上测试了xpath,它成功了
你知道吗根据您提供的HTML,要单击左侧导航窗格中的MAKE-UP,可以使用以下代码块:
我可以点击使用下面的代码
希望这对你有帮助
相关问题 更多 >
编程相关推荐