如何在Selenium WebDriver中使用TestNg?

桑卡

如何在Selenium WebDriver中使用TestNg?请解释一下这有什么用。我是Selenium WebDriver的新手

富裕的

TestNG可以定义为

1。TestNG is a testing framework designed to simplify a broad range of testing needs, from unit testing (testing a class in isolation of the others) to integration testing (testing entire systems made of several classes, several packages and even several external frameworks, such as application servers).

2.有关TestNG的官方文档,请单击此处

在将TestNG与硒一起使用之前,必须先安装它。考虑到您正在使用eclipse(任何版本),请先进行讨论。

1.There are various ways to install TestNG either follow 这个这个 or simply go to Help/Eclipse MarketPlace. under Find type Test NG and click on the install

现在如何在含硒的日食中使用Test NG

@BeforeTest
    public void TearUP(){
        // preconditions for sample test 
        // like browser start with specific URL
    }


@Test
    public void SampleTest(){
        // code for the main test case goes inside
    }

@AfterTest
public void TearDown1(){
    // thing to done after test is run
    // like memory realese 
    // browser close 

}

以上代码的一些信息

  1. TestNG有各种注释,有关注释的更多信息,请转到上面的链接

    @BeforeSuite:带注释的方法将在此套件中的所有测试运行之前运行。

    @AfterSuite: The annotated method will be run after all tests in this suite have run. 
    @BeforeTest: The annotated method will be run before any test method belonging to the classes inside the <test> tag is run. 
    @AfterTest: The annotated method will be run after all the test methods belonging to the classes inside the <test> tag have run. 
    @BeforeGroups: The list of groups that this configuration method will run before. This method is guaranteed to run shortly before the first test method that belongs to any of these groups is invoked. 
    @AfterGroups: The list of groups that this configuration method will run after. This method is guaranteed to run shortly after the last test method that belongs to any of these groups is invoked. 
    @BeforeClass: The annotated method will be run before the first test method in the current class is invoked. 
    @AfterClass: The annotated method will be run after all the test methods in the current class have been run. 
    @BeforeMethod: The annotated method will be run before each test method. 
    @AfterMethod: The annotated method will be run after each test method.
    

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在Java中使用TestNG Selenium Webdriver在多个类中使用同一浏览器窗口?

如何在Selenium WebDriver中使用JavascriptExecuter设置属性值

如何在Java中使用Selenium WebDriver向下滚动

如何在Python中使用Selenium Webdriver提取文本?

如何在Selenium WebDriver Java中使用JavaScript

如何在Selenium WebDriver的属性文件中使用多行属性?

如何在bokeh文档中使用Selenium WebDriver查找按钮?

如何在Python中使用Selenium Webdriver提取Webelement

如何在testNG中使用组

如何在Java中使用Selenium WebDriver(Selenium 2)在文本框中输入内容?

如何在 C# 中使用 VS 在 Selenium webdriver 中使用相对 Xpath

如何在Python中使用Selenium Webdriver滚动网页而不使用javascript方法execute_script()

在Java中使用Selenium WebDriver

如何在Java中使用Selenium Webdriver模拟打印屏幕按钮

如何在C#中使用Selenium WebDriver获取当前窗口的URL?

如何在 Python 中使用 Selenium WebDriver 根据 html 选择复选框

如何在Python中使用Selenium WebDriver获取元素的CSS值(例如颜色)

如何在Selenium Webdriver中使用Python单击:: before / :: after CC标签?

如何在Selenium WebDriver中使用xPath来获取SVG元素?

如何在Selenium WebDriver中使用Javascript获取元素的背景色

如何在Firefox 19中使用Selenium WebDriver进行鼠标悬停?

如何在python中使用Selenium WebDriver截取部分屏幕截图?

如何在python中使用Selenium WebDriver截取部分屏幕截图?

如何在Selenium WebDriver中使用日期选择器选择特定日期

如何在Java中使用Selenium Webdriver获得标签值

如何在python 3中使用Selenium Webdriver编写<p>标记内?

我们如何在colab.research.google.com中使用Selenium Webdriver?

如何在Java中使用Selenium WebDriver查找特定的表元素?

如何在python中使用Selenium WebDriver获取整个网页源