出于某种原因,我无法识别下面的html button class="next"
中的按钮元素。我尝试了各种方法,但我从来没有得到积极的打击。我已经确认它不是在iframe和我尝试的所有方法(id,class,xpath(" // li [@class =' next'] / button"))Im希望有人可以指出我的愚蠢。
<div id="ember1199" class="ember-view">
<ol id="ember1582" class="results-paginator ember-view">
<!---->
<li class="page-list">
<ol>
<li class="active">1</li>
<li><button data-ember-action="" data-ember-action-1585="1585">2</button></li>
<li><button data-ember-action="" data-ember-action-1587="1587">3</button></li>
<li><button data-ember-action="" data-ember-action-1589="1589">4</button></li>
<li><button data-ember-action="" data-ember-action-1591="1591">5</button></li>
<li><button data-ember-action="" data-ember-action-1593="1593">6</button></li>
<li><button data-ember-action="" data-ember-action-1595="1595">7</button></li>
<li><button data-ember-action="" data-ember-action-1597="1597">8</button></li>
<li><button data-ember-action="" data-ember-action-1599="1599">9</button></li>
<li><button data-ember-action="" data-ember-action-1601="1601">10</button></li>
</ol>
</li>
<li>
<button class="next" data-ember-action="" data-ember-action-1602="1602" data-is-animating-click="true">
<div class="next-text">
Next
</div>
<span class="svg-icon-wrap">
<span class="visually-hidden">Next</span>
<li-icon aria-hidden="true" type="chevron-right-icon" size="small">
<svg viewBox="0 0 24 24" width="24px" height="24px" x="0" y="0" preserveAspectRatio="xMinYMin meet" class="artdeco-icon">
<g class="small-icon" style="fill-opacity: 1">
<path d="M9,8L5,2.07,6.54,1l4.2,6.15a1.5,1.5,0,0,1,0,1.69L6.54,15,5,13.93Z"></path>
</g>
</svg>
</li-icon>
</span>
</button>
</li>
</ol>
</div>
答案 0 :(得分:0)
要使用class="next"
标识按钮元素,您可以使用以下任一项:
<强> css_selector
强>
driver.find_element_by_css_selector("button.next span.svg-icon-wrap > span")
<强> xpath
强>
driver.find_element_by_xpath("//button[@class='next']//span[@class='svg-icon-wrap']/span")