从java转换为TestNG

从java转换为TestNG,java,selenium-webdriver,testng,Java,Selenium Webdriver,Testng,虽然这将是一个简单的过程,但对我来说似乎很复杂。请有人帮助找到以下问题的正确解决方案: 在一个包selenium.tests.postTip中包含200个测试,如下所示: package selenium.tests.postTip; import java.util.List; import selenium.BaseTest; import selenium.DriverBase; import org.openqa.selenium.By; import org.openqa.selen

虽然这将是一个简单的过程,但对我来说似乎很复杂。请有人帮助找到以下问题的正确解决方案: 在一个包selenium.tests.postTip中包含200个测试,如下所示:

package selenium.tests.postTip;

import java.util.List;
import selenium.BaseTest;
import selenium.DriverBase;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.testng.annotations.Test;

public class PostBadmintonOddEven extends DriverBase {

@Test
public void main() throws Exception {
    WebDriver driver = BaseTest.login();
    Thread.sleep(2000);

    List<WebElement> allSports = driver.findElements(By.xpath("//ul[@class='be-sportpicker__list']//div[@class='be-sport-thumb__title be-typo-be']"));
    driver.findElement(By.xpath("/html/body/be-root/main//be-scroller//be-sportpicker//ul[@class='be-sportpicker__list']/li/a[contains(@href,\"/badminton\")]")).click();
    Thread.sleep(2000);

    BaseTest.betTypeOddEvenFullEvent(driver);

  }
 }

提前谢谢。

您可以使用@AfterMethod检查,而不是@AfterTest方法

如果这还不能解决,
在TestNG中,您使用什么来获取所有测试@带有动态数组或Excel的数据提供程序

错误的做法是错误地命名测试类和方法。重命名测试类,使其具有前缀或后缀形式的测试标签。您还使用@Test注释对main方法进行了注释。主方法是JVM启动的实际入口点。为描述测试方法的方法使用自定义名称

你收到错误了吗?您还可以在testng.xml中使用packages属性。请参考第二个例子,非常感谢。不知道我在做什么不正确
@AfterTest
driver.quit();