如果有人能帮我写一个XPath来实现以下目标,我将不胜感激:
任何方法都会帮我很大的忙。你知道吗
我的前两次尝试都失败了:
browser.find_element_by_xpath("//*[starts-with(@id,'revit_form_Button_' ) and ends-with(@id,'0')]").click()
browser.find_element_by_xpath("//*[boolean(number(substring-before(substring-after(@id, 'revit_form_Button_'), '0')))]").click()
<div id="reporting_grid_CellReportTitle_10" class="rptCellReportTitle" widgetid="reporting_grid_CellReportTitle_10">
<div dojoattachpoint="divReportTitle" class="rptCellReportTitleSpanNode"><span class="dijit dijitInline dijitReset revitButtonHideBackground revitButton" data-dojo-attach-point="focusNode,titleNode,stateNode" role="button" aria-labelledby="revit_form_Button_30_label" data-dojo-attach-event="ondijitclick:_onClick" tabindex="0" id="revit_form_Button_30" widgetid="revit_form_Button_30" style="position: relative; user-select: none;">
<span class="dijitReset revitIconNode dijitNoIcon" data-dojo-attach-point="iconNode" style="display: none;"></span>
<span class="dijitReset dijitButtonText" id="revit_form_Button_30_label" data-dojo-attach-point="containerNode" style="padding-left: 0px; text-transform: none;"><b>Daily Tech Totals / Daily Tech Totals / Employee Daily Totals Report</b></span>
<span class="dijitReset revitIconNode revitIconRightNode dijitNoIcon" data-dojo-attach-point="iconRightNode"></span>
<input type="button" value="" class="dijitOffScreen" tabindex="-1" role="presentation" data-dojo-attach-point="valueNode">
</span></div>
<div dojoattachpoint="divNotes" class="rptCellReportTitleNotesNode"></div>
<div dojoattachpoint="divSchedule" class="rptCellReportTitleScheduleNode"></div>
</div>
<div id="reporting_grid_CellReportTitle_11" class="rptCellReportTitle" widgetid="reporting_grid_CellReportTitle_11">
<div dojoattachpoint="divReportTitle" class="rptCellReportTitleSpanNode"><span class="dijit dijitInline dijitReset revitButton revitButtonHideBackground" data-dojo-attach-point="focusNode,titleNode,stateNode" role="button" aria-labelledby="revit_form_Button_31_label" data-dojo-attach-event="ondijitclick:_onClick" tabindex="0" id="revit_form_Button_31" widgetid="revit_form_Button_31" style="position: relative; user-select: none;">
<span class="dijitReset revitIconNode dijitNoIcon" data-dojo-attach-point="iconNode" style="display: none;"></span>
<span class="dijitReset dijitButtonText" id="revit_form_Button_31_label" data-dojo-attach-point="containerNode" style="padding-left: 0px; text-transform: none;"><b>Daily Tech Totals / Daily Tech Totals / Employee Daily Totals Report</b></span>
<span class="dijitReset revitIconNode revitIconRightNode dijitNoIcon" data-dojo-attach-point="iconRightNode"></span>
<input type="button" value="" class="dijitOffScreen" tabindex="-1" role="presentation" data-dojo-attach-point="valueNode">
</span></div>
<div dojoattachpoint="divNotes" class="rptCellReportTitleNotesNode"></div>
<div dojoattachpoint="divSchedule" class="rptCellReportTitleScheduleNode"></div>
</div>
在XPath 1.0中没有
ends-with
,但是您可以使用满足附加条件
添加如下子句
或者
到XPath。在您的示例中,子元素是
<b>
。所以,你也可以写child::b
而不是child::*
。你知道吗综合起来:
这是一个XPath表达式。为了便于阅读,可以分成几行,但也可以是一行。你知道吗
相关问题 更多 >
编程相关推荐