【发布时间】:2016-08-03 10:35:46
【问题描述】:
我的页面包含两个下一步按钮。在这里我需要单击两个中的一个特定的“下一步”按钮。这里的问题是两个下一个按钮都具有相同的 HTML 内容。它们具有唯一的 ID,但它不是静态的。它是动态的,并且会一直变化。 在这里如何使用任何方法识别我的元素?
按照我为“下一步”按钮 2 添加的父代码。这里我们只有一个唯一标识符,称为 uId : 'navigationPanel'。请你帮我看看如何在我的 xpath 创建中使用它?
<div id="idx_layout_ContentPane_102" class="dijitContentPane idxContentPane wizardNavigationPanel wizardNavigationPanelBottom" data-mojo-props=" 'class' : 'wizardNavigationPanel wizardNavigationPanelBottom' , uId : 'navigationPanel' , renderHidden : true ,scParamDataFn : function() { return { 'aria-label' : this.getSimpleBundleString('Region_wizard_navigation') } } " data-mojo-type="idx/layout/ContentPane" role="region" aria-label="Wizard navigation" widgetid="idx_layout_ContentPane_102">
<span class="dijit dijitReset dijitInline dijitButton idxButtonDerived navPrevious" role="presentation" widgetid="dijit_form_Button_11">
<span class="dijit dijitReset dijitInline idxButtonDerived idxSpecialButton navNext dijitButton" role="presentation" widgetid="dijit_form_Button_12">
<span class="dijitReset dijitInline dijitButtonNode" role="presentation" data-mojo-attach-event="ondijitclick:__onClick">
<span id="dijit_form_Button_12" class="dijitReset dijitStretch dijitButtonContents" aria-labelledby="dijit_form_Button_12_label" role="button" data-mojo-attach-point="titleNode,focusNode" tabindex="0" style="-moz-user-select: none;">
<span class="dijitReset dijitInline dijitIcon idxNextPageIcon" data-mojo-attach-point="iconNode"/>
<span class="dijitReset dijitToggleButtonIconChar">●</span>
<span id="dijit_form_Button_12_label" class="dijitReset dijitInline dijitButtonText" data-mojo-attach-point="containerNode">Next</span>
</span>
</span>
<input class="dijitOffScreen" type="button" data-mojo-attach-point="valueNode" aria-hidden="true" role="presentation" tabindex="-1" data-mojo-attach-event="onclick:_onClick" value=""/>
</span>
ID 总是不同的。我需要识别“下一步”按钮 1。
【问题讨论】:
-
在这种情况下,您需要借助这些按钮的父级。你能粘贴按钮前后的html吗?
-
@pArAs 更新了父代码。我们有一个名为 uId 的唯一标识符。请您帮我看看如何在 xpath 中使用它。
标签: html selenium xpath selenium-webdriver automation