0

我使用 Selenium IDE 1.10.0 记录了一个测试用例。我将案例导出为 Java/TestNG/Remote Control。

我的 Eclipse 版本是 4.2.0,我安装了 TestNG 插件版本 6.8

我想知道如何在 Eclipse 中创建一个项目来运行这个导出的测试用例?

请给我一些指示或与我分享一些在线教程/文档。谢谢!

下面是Eclipse生成的java代码:

package com.example.tests;

import com.thoughtworks.selenium.*;
import org.testng.annotations.*;
import static org.testng.Assert.*;
import java.util.regex.Pattern;

public class SearchDonor extends SeleneseTestNgHelper {
    @Test public void testSearchDonor() throws Exception {
        // set overall speed of the test case
        selenium.setSpeed("4000");
        selenium.open("/?html=openid");
        selenium.click("css=input[type=\"submit\"]");
        selenium.waitForPageToLoad("30000");
        Thread.sleep(4000);
        selenium.click("id=cmp_admin");
        selenium.waitForPageToLoad("30000");
        selenium.click("id=quicksearch_anchor");
        selenium.click("css=img[alt=\"Member\"]");
        selenium.waitForPageToLoad("30000");
        selenium.type("id=search_name", "suzy");
        selenium.click("css=input[type=\"image\"]");
        selenium.click("link=Balagia, Suzy");
        selenium.waitForPageToLoad("30000");
    }
}
4

1 回答 1

0

经过一些试验和错误。我设法在 Eclipse 中执行导出的代码作为 TestNG 测试。这是我为使其编译而采取的步骤。

1.在Eclipse中创建一个Java项目

2.在Java项目中添加一个类

2a. I copied and pasted the code into the newly created the class

3.右键项目>构建路径>配置构建路径

3a。在 Java Build Path 窗口中选择 library>Add External JARS,然后添加 Selenium Java Driver 文件夹中的所有 JAR 文件(例如,本例中的文件夹名称为 libs),加上 selenium-java-2.31.0.jar 和 selenium-java- 2.31-src.jar

4.单击顶部菜单栏上调试图标旁边的运行图标,运行 AS TestNG 测试

我的代码正在编译,但出现了一些异常错误。我正在盯着一个 TestNG 测试用例!

于 2013-04-09T22:51:06.183 回答