TestNG-未找到测试

时间:2019-06-23 19:49:25

标签: java automation annotations testng

我的代码有问题。我想测试网站上的某些元素,但是运行测试后,TestNG会引发错误:“未找到测试”。

我已经尝试创建一个新的testng.xml,但是它不起作用。

package tests;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.testng.Assert;
import org.testng.annotations.*;
import pages.LoginToAutomationAccount;

public class TestsOnLogin {
    WebDriver driver;

//    @FindBy(css = "a[class='login'][rel='nofollow']")
//    WebElement signInButton;
//
    public TestsOnLogin(WebDriver driver){
        this.driver=driver;
        //PageFactory.initElements(driver, this);
    }

    LoginToAutomationAccount account;

    @BeforeSuite
    public void setUp() {
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\Gabriel\\Downloads\\chromedriver.exe");
        driver = new ChromeDriver();
        driver.get("http://automationpractice.com/index.php");
    }

    @Test
    public void test_HomePageLogin() {
        //Locate Sign-In button and press it to start the adventure
        driver.findElement(By.cssSelector("a[class='login'][rel='nofollow']")).click();
        //completion for object -account-
        account = new LoginToAutomationAccount(driver);
        //login to website account
        account.loginAutomationPage("gabriel.noki9@gmail.com", "capptain3");
        //verify if it is logged in
        String textConfirmation = account.getConfirmationLogin();
        Assert.assertTrue(textConfirmation.contains("My account"));

    }

    @AfterSuite
    public void downPage(){
        driver.quit();
    }


}

TestNG文件-我试图修改链接,但不起作用

    <?xml version="1.0" encoding ="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="LoginToAutomationAccount">
    <test name="testngTest">
        <packages>
            <package name="tests" />
        </packages>
    </test>
</suite>

0 个答案:

没有答案
相关问题