实例化类tests.TestBigFamilyCard时发生错误。检查以确保可以实例化

时间:2018-10-11 11:09:26

标签: java selenium-webdriver intellij-idea automated-tests selenium-chromedriver

我是自动化测试的初学者。我正在尝试使用Page Object Pattern标准构建测试用例。在下面,我暂时放置代码:

BaseTest.java

package tests;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeTest;

public class BaseTest {
  public WebDriver driver;
  public WebDriverWait wait;

@BeforeClass
public void setUp() {
    driver = new ChromeDriver();
    wait = new WebDriverWait(driver, 15);
    driver.manage().window().maximize();
}

@AfterClass
public void tearDown() {
    driver.quit();
}
}

BasePage.java

package pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.WebDriverWait;

public class BasePage {
public WebDriver driver;
public WebDriverWait wait;


public BasePage(WebDriver driver, WebDriverWait wait) {
    this.driver = driver;
    this.wait = wait;
}


public void click (By elementLocation) {
    driver.findElement(elementLocation).click();
}


public void SendKeys (By elementLocation) {
    driver.findElement(elementLocation).sendKeys();
}

}

HomePaga.java

package pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.WebDriverWait;


public class HomePage extends BasePage {
public HomePage (WebDriver driver, WebDriverWait wait) {
    super(driver, wait);
}


String baseURL = "http://localhost:4200/dashboard";


String BigFamilyCard = "client-individualPerson-bigFamilyCard-details-bttn";


public void OpenUFE() {
    driver.get(baseURL);
}


public void OpenBigFamilyCard() {
    click(By.className(BigFamilyCard));
}
}

BigFamilyCard.java

package pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.WebDriverWait;
import pages.BasePage;

public class BigFamilyCard extends BasePage {


public BigFamilyCard(WebDriver driver, WebDriverWait wait) {
    super(driver, wait);
}



By DetailsButton = By.id("client-individualPerson-bigFamilyCard-details-bttn");
By EditionButton = By.id("client-insdividualPerson-bigfamilyCard-edit-bttn");
By BigFamilyCardNumber = By.id("cardNumber-inputText");
By ReleaseDate = By.id("releaseDate-calendar");
By ExpirationDate = By.id("expirationDate-calendar");
By NextButton = By.id("next-bttn");
By SignedCheckbox = By.id("signed-checkbox");
By SaveButton = By.id("save-bigFamilyCard-bttn");


public void OpenBigFamilyCard() {
    driver.findElement(DetailsButton).click();
    driver.findElement(EditionButton).click();
    driver.findElement(BigFamilyCardNumber).click();
    driver.findElement(ReleaseDate).click();
    driver.findElement(ExpirationDate).click();
    driver.findElement(NextButton).click();
    driver.findElement(SignedCheckbox).click();
    driver.findElement(SaveButton).click();
    }
    }

TestBigFamilyCard.java

  package tests;

  import org.openqa.selenium.WebDriver;
  import org.testng.annotations.Test;
  import pages.BasePage;
  import pages.BigFamilyCard;
  import pages.HomePage;
  import org.openqa.selenium.support.ui.WebDriverWait;

  public class TestBigFamilyCard extends BasePage {


public TestBigFamilyCard(WebDriver driver, WebDriverWait wait) {
    super(driver, wait);
}

@Test
public void BigFamilyCardEdition() {

    // Page Instantiations - instancje stron
    HomePage homePage = new HomePage(driver, wait);
    BigFamilyCard bigFamilyCard = new BigFamilyCard(driver, wait);

    // Page Methods

    homePage.OpenUFE();
    homePage.OpenBigFamilyCard();
    bigFamilyCard.OpenBigFamilyCard();

    }
    }

在运行测试时,我得到了交流-未找到测试,并且“实例化类test.TestBigFamilyCard时发生错误。请检查以确保可以实例化” 有人可以帮我解决这个问题吗?

0 个答案:

没有答案