【问题标题】:How to run an exported selenium test case using TestNG in Eclipse如何在 Eclipse 中使用 TestNG 运行导出的 selenium 测试用例
【发布时间】:2015-04-20 12:48:36
【问题描述】:

我使用 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");
    }
}

【问题讨论】:

    标签: eclipse-plugin testng selenium-ide


    【解决方案1】:

    经过一些试验和错误。我设法在 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 测试用例!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-20
      • 1970-01-01
      • 2018-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-29
      相关资源
      最近更新 更多