0

I have a button on a page which I need to write a locator for - so far have been unsuccessful so would appreciate some help here :

<div class="border" style="border-radius: 10px 10px 10px 10px;">
<div>
<span id="btnAddClient" class="buttons">
<div id="clientContainer">
<div id="ClientAccordian_204" class="accordion ui-accordion ui-widget ui-helper-reset ui-accordion-icons" role="tablist">
<h3 id="H3Client_204" class="ui-accordion-header ui-helper-reset ui-state-active ui-corner-top" role="tab" aria-expanded="true" tabindex="0">
<div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active" role="tabpanel" style="">
<span id="btnAddYear" class="buttons">
<button onclick="javascript:ShowHideAddYear(204,0);" style="float: right; background-color: rgb(238, 238, 238);">
<button id="btnEditClient_204" title="Edit" style="float:right;">
<br>
</span>
<div id="yearsContainer_204">
</div>
</div>
<div id="ClientAccordian_210" class="accordion ui-accordion ui-widget ui-helper-reset ui-accordion-icons" role="tablist">
<h3 id="H3Client_210" class="ui-accordion-header ui-helper-reset ui-state-active ui-corner-top" role="tab" aria-expanded="true" tabindex="0">
<div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active" role="tabpanel" style="">
<span id="btnAddYear" class="buttons">
<button onclick="javascript:ShowHideAddYear(210,0);" style="float: right; background-color: rgb(238, 238, 238);">
<button id="btnEditClient_210" title="Edit" style="float:right;">
<br>
</span>
<div id="yearsContainer_210">
</div>
</div>
<div id="ClientAccordian_209" class="accordion ui-accordion ui-widget ui-helper-reset ui-accordion-icons" role="tablist">
<div id="ClientAccordian_211" class="accordion ui-accordion ui-widget ui-helper-reset ui-accordion-icons" role="tablist">
<div id="ClientAccordian_215" class="accordion ui-accordion ui-widget ui-helper-reset ui-accordion-icons" role="tablist">
<h3 id="H3Client_215" class="ui-accordion-header ui-helper-reset ui-state-active ui-corner-top" role="tab" aria-expanded="true" tabindex="0">
<div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active" role="tabpanel" style="">
<span id="btnAddYear" class="buttons">
<button onclick="javascript:ShowHideAddYear(215,0);" style="float: right; background-color: rgb(238, 238, 238);">
<button id="btnEditClient_215" title="Edit" style="float:right;">
<br>
</span>
<div id="yearsContainer_215"></div>
</div>
</div>
</div>
</div>

On this page 3 of these button appear but there could be more <button onclick="javascript:ShowHideAddYear(i,j)..>

Common locators like css=#btnAddYear > button or //span[@id=’btnAddYear’]/button[text()=’Add Year’] do not work. Can someone help writing a reliable locator that selects the button uniquely ?

4

3 回答 3

1

感谢您的输入,我尝试了各种事情,例如标签到元素和触发“输入”事件等,但没有任何效果。这原来是 Selenium IE 驱动程序的一个问题。http://code.google.com/p/selenium/issues/detail?id=5142

于 2013-08-06T10:51:09.467 回答
0

我在您提供的 html 中没有看到文本“添加年份”。如果将其更改为 //span[@id='btnAddYear']/button[1] 是否有效?

于 2013-08-05T13:06:50.740 回答
0

那这个呢?

'//span[@id="btnAddYear"]//button[contains(., "Add Year")]'
于 2013-08-05T14:33:44.987 回答