2013-09-23 19 views
0

JI刚开始使用Selenium来测试网站。但是,我无法使用链接和xpath找到网站上的按钮。 网址是http://hra.case.edu/info。如果您在名字输入框中键入类似约翰,网站将呈现一个表格,显示您可能的用户。我需要点击第一个按钮“这就是我”。未能通过Selenium IDE在网站上找到按钮

这里是硒

我的测试用例的源代码
<tr> 
    <td>open</td> 
    <td>/</td> 
    <td></td> 
</tr> 
<tr> 
    <td>clickAndWait</td> 
    <td>link=Get Started</td> 
    <td></td> 
</tr> 

<tr> 
    <td>keyPress</td> 
    <td>name=searchFirstName</td> 
    <td>John</td> 
</tr> 
<tr> 
    <td>selectWindow</td> 
    <td>name={&quot;$&quot;:{&quot;memLimit&quot;:2000,<br />&quot;autoFlush&quot;:true,<br />&quot;crossDomain&quot;:false,<br />&quot;includeProtos&quot;:false,<br />&quot;includeFunctions&quot;:false,<br />&quot;currentDomain&quot;:&quot;case.edu&quot;}}</td> 
    <td></td> 
</tr> 
<tr> 
    <td>clickAndWait</td> 
    <td>//*[@id='select_user']/tr[1]/td[1]/a</td> 
</tr> 

It fails at the last step said [error] Element Xpath//*[@id'select_user']/tr[1]/td[1]/a not found 

任何人都知道如何查找按钮? 谢谢! p.s.我可以使用Firebug的控制台来定位按钮

>>> $x(".//*[@id='select_user']/tr[1]/td[1]/a") 
[a.btn /midlife/149] 
+0

好的,亲瑕疵解决了,这是因为在“这是我按钮”之前有一段延迟。只需在点击之前放置一个waitforelementPresent动作即可。 – Koshien

回答

0

,你只需要等待这样的

command - waitForElementPresent

target - Xpath//*[@id'select_user']/tr[1]/td[1]/a

-1

尝试用下面的XPath

"//div[@id='content']//tbody[@id='select_user']/tr[1]//a" 
+0

仍然没有工作:( – Koshien

+0

,以确保公正,我在硒的代码是 \t​​clickAndWait \t​​// DIV [@ ID = '内容'] // TBODY [@ ID = 'select_user']/TR [1] // a \t​​ – Koshien