0

コードは CSS を使用してボタンに焦点を合わせて強調表示しますが、プログラミング言語として c# を使用して Selenium RC で CSS を使用してボタンをクリックすることはできません。これが私のコードです。

   if(selenium.IsElementPresent("css=button[id$=searchButton]"))  //finds the button               
   {                                                                  
   selenium.Focus("css=button[id$=searchButton]"); // focuses the button                       
   selenium.Highlight("css=button[id$=searchButton]");     //highlights the button                       
   selenium.Click("css=button[id$=searchButton]");      //doesn't click the button???      
   }

以下の Xpath コードは、C# を使用した Selenium RC で問題なく動作します。

   selenium.Click("xpath=//button[matches(@id,'.*searchButton')]"); //works fine with this xpath code

ボタンの HTML コードは次のとおりです。

<td align="left" style= "vertical-align : top;">
<button type="button" class="ClassButton" id="genId_38_:mainPanel_genId_39:searchButton"  tabindex="0">
Click Me</button>
</td>

少しでも助けていただければ幸いです。

4

2 に答える 2

0

これを試して

selenium.Click("css=button[id$='searchButton']"); 
于 2012-05-03T07:18:08.403 に答える
-1

やってみました

selenium.InvokeMember("click");
于 2012-03-26T16:02:58.923 に答える