我是selenium的新手我无法找到"<a class="standalone clearfix" href="/logout">Sign out</a>"
元素,我尝试使用以下css标识符来查找“退出”按钮
css= div[class='sub-nav chat-bubble']>ul>div:nth-child(3)>li:nth-child(4)>a
请你修改它。
<div class="sub-nav chat-bubble">
<div class="name">Manju Nath</div>
<ul style="background-color: transparent;">
<div class="email force-no-break" style="background-color: transparent;">
<div class="subheader-gray-text">243.3 KB of 2 GB used</div>
<div class="quota_graph_container" style="background-color: rgb(238, 238, 238);">
<li class="first-standalone">
<a class="standalone clearfix" target="_blank" href="/account">Settings</a>
</li>
<li>
<a class="standalone clearfix" href="/install">Install</a>
</li>
<li>
<a class="standalone clearfix" target="_blank" href="/plans">Upgrade</a>
</li>
<li>
<a class="standalone clearfix" href="/logout">Sign out</a>
</li>
</ul>
<div class="chat-bubble-arrow-border"></div>
<div class="chat-bubble-arrow"></div>
</div>
答案 0 :(得分:1)
改用Xpath
您可以通过浏览器检查元素工具
简单地找出元素的xpathfind_element_by_xpath("//div[@class='quota_graph_container']/li[4]/a")
OR
css= div[class='quota_graph_container']>li:nth-child(4)>a
答案 1 :(得分:0)
我同意user1177636。我会尝试使用独特的选择器以及简单或可读的选择器,
css = a[href='/logout']