如何在groovy中使用硒测试案例?比如在链接上叮当作响。
测试用例
<html>
...
<body>
<table>
<tr>
<td>open</td>
<td>https://url.web:8010/</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=service=homeLink</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=name=contentLink,service=Queue</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=BackLink</td>
</tr>
...
GROOVY脚本
// Setup credentials
def String[] credentials = new String[2]
credentials[0] = "username"
credentials[1] = "password"
def cred = [(JMXConnector.CREDENTIALS):credentials]
// Setup JMX connection with credentials
def serviceURL = 'service:jmx:rmi:///jndi/rmi://url.web:8010/jmxrmi'
def service = JmxFactory.connect(new JmxUrl(serverUrl), cred).MBeanServerConnection
如何使用点击并从selenium脚本等待
答案 0 :(得分:0)
Groovy本质上就是Java。因此,GroovyTest案例的结构与JUnit3测试完全相同。
class SampleTest extends GroovyTestCase {
void test_FirstTest() {
WebDriver driver = new FirefoxDriver()
driver.get(some url)
.....
}
}
如果您愿意,可以查看我在Groovy中编写的几个示例测试,here。