我有一个类“FormFieldContainer”的自动生成的类ID。我想在文本框_13 (也是自动生成的ID)中输入文本。 此方案中唯一一致的值是前面的标签“Broker Code”。如何使用标签作为参考在文本框中输入文本?
HTML下面。抱歉格式化。我还在努力解决这个问题: - (
<div class="FormFieldContainer" id="my_test_FormFieldContainer_15" widgetid="my_test_FormFieldContainer_15">
<link href="/tswApp/my/test/FormFieldContainer.css" type="text/css" rel="stylesheet">
<div data-dojo-attach-point="formFieldHeaderPoint" class="FormFieldHeader">
<div data-dojo-attach-point="formFieldContainerLabelPt" class="FieldLabel">Broker Code</div>
<div data-dojo-attach-point="requiredIndicator" class="FieldRequiredIndicator" style="display: table-cell;">(required)</div>
<div data-dojo-attach-point="formFieldLinkContainerPoint" class="FieldLinkContainer"></div>
</div>
<div data-dojo-attach-point="containerNode" class="Field">
<div data-dojo-attach-point="inputContainer" class="SimpleInputContainer">
<div role="presentation" id="widget_dijit_form_TextBox_13" class="dijit dijitReset dijitInline dijitLeft dijitTextBox" widgetid="dijit_form_TextBox_13">
<div class="dijitReset dijitInputField dijitInputContainer"><input type="text" autocomplete="off" data-dojo-attach-point="textbox,focusNode" class="dijitReset dijitInputInner" tabindex="0" id="dijit_form_TextBox_13" value=""><span class="dijitPlaceHolder dijitInputField" style="">Enter broker code</span></div>
</div>
<div class="ClearButton widgetHidden"></div>
</div>
</div>
答案 0 :(得分:3)
或者,您也可以依赖“输入经纪人代码”文本,该文本位于所需span
元素之后的input
标记中。 preceding-sibling
axis会有所帮助:
//span[. = 'Enter broker code']/preceding-sibling::input
答案 1 :(得分:2)
尝试
//div[text()='Broker Code']/../..//input
如果这是唯一的输入控件,我建议您使用input