【发布时间】:2016-02-21 20:21:51
【问题描述】:
我正在尝试单击此按钮:
<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
<div class="ui-dialog-buttonset">
<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false">
<span class="ui-button-text">Create</span>
</button>
<button aria-disabled="false" role="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button">
<span class="ui-button-text">Close</span>
</button>
</div>
我想使用 xpath 来实现。这是我的代码:
driver.find_element_by_xpath("/html/body/div[22]/div[3]/div/button[1]")
我也试过了:
driver.find_element_by_xpath(".//div[22]/div[3]/div/button[1]")
我不断收到错误无法定位元素。我应该尝试不同的定位器
【问题讨论】:
标签: python html selenium xpath