如何处理测试用例失败的场景

时间:2018-02-23 12:42:18

标签: java selenium selenium-webdriver testng

在TestNG中, 我写了一个方法来注册最多100个用户的任何应用程序,然后我从excel文件中编写代码输入(用户ID和密码)并注册这些用户, 当我在45或46个用户注册中运行失败时,如果我再次运行它失败,因为已经注册了多达45个用户,我怎么能解决这个问题。

package com.stm.test;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.Test;
public class RegistrationTest
{

    @Test //This is TestNG annotation
    public void testRegister()
    {
        WebDriver driver = new FirefoxDriver();
        driver.get(“http://newtours.demoaut.com/”);
        driver.findElement(By.linkText(“REGISTER”)).click();
        driver.findElement(By.name(“firstName”)).sendKeys(“User1”);
        driver.findElement(By.name(“lastName”)).sendKeys(“Surname1”);
        driver.findElement(By.name(“phone”)).sendKeys(“123456789”);
        driver.findElement(By.name(“userName”)).sendKeys(“user1@test.com”);
        driver.findElement(By.name(“address1”)).sendKeys(“Test Address”);
        driver.findElement(By.name(“city”)).sendKeys(“Test City”);
        Select select = new Select(driver.findElement(By.name(“country”)));
        select.selectByVisibleText(“ANGOLA”);
        driver.findElement(By.name(“email”)).sendKeys(“user1@test.com”);
        driver.findElement(By.name(“password”)).sendKeys(“user1”);
        driver.findElement(By.name(“confirmPassword”)).sendKeys(“user1”);
        driver.findElement(By.name(“register”)).click();
        driver.close();
        driver.quit();
    }

}

我为一个用户写这个,但我想从excel文件中注册更多用户。

0 个答案:

没有答案