从IDE生成的基本Selenium Java不工作

从IDE生成的基本Selenium Java不工作,java,eclipse,selenium,selenium-webdriver,Java,Eclipse,Selenium,Selenium Webdriver,我已经从Selenium IDE生成了这个脚本。它在IDE中工作,而不是在Eclipse中:它只运行Firefox20并转到Google。但它不会搜索任何东西 更新:我用Thread.Sleep(3000L)替换了setSpeed 但我不知道如何应对错误评论“定位器策略” IDE源是: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "

我已经从Selenium IDE生成了这个脚本。它在IDE中工作,而不是在Eclipse中:它只运行Firefox20并转到Google。但它不会搜索任何东西

更新:我用Thread.Sleep(3000L)替换了setSpeed 但我不知道如何应对错误评论“定位器策略”

IDE源是:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://www.google.fr/" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
    <td>open</td>
    <td>/</td>
    <td></td>
</tr>
<tr>
    <td>type</td>
    <td>id=gbqfq</td>
    <td>selenium</td>
</tr>
<tr>
    <td>setSpeed</td>
    <td>3000</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>btnG</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>link=Selenium - Web Browser Automation</td>
    <td></td>
</tr>
<tr>
    <td>assertTextPresent</td>
    <td>What is Selenium?</td>
    <td></td>
</tr>
</tbody></table>
</body>
</html>

新测试
新测试
打开
/
类型
id=gbqfq
硒
设定速度
3000
点击
btnG
单击并等待
link=Selenium-Web浏览器自动化
assertTextPresent
什么是硒?

这有时可能是因为使用了旧的selenium罐

http://code.google.com/p/selenium/downloads/list


尝试使用新库,看看是否有效

在您的
testSelenium
方法中,它将文本键入搜索字段,但从不按下Recherche Google search按钮。IDE脚本中包含了该步骤:

<tr>
 <td>click</td>
 <td>btnG</td>
 <td></td>
</tr>

您是否出于某种原因从Eclipse中的脚本中删除了它?

尝试在Eclipse中运行它时,您看到了什么错误?yuo使用的是什么版本的selenium jar?我正在为selenium java和selenium server使用最新版本2.32.0java@MakkyEclipse中没有错误,它只是永远暂停。只有当我关闭Firefox时,它才会显示。我试过了。谷歌搜索为我工作。你有什么例外吗?我使用的是2.32.00,没有最新版本吗?你的firefox使用的是最新版本吗?这将是一个巨大的错误,因为它是非常基本的东西,但谢谢你的回答:)
<tr>
 <td>click</td>
 <td>btnG</td>
 <td></td>
</tr>
driver.findElement(By.id("gbqfba")).click();