请帮助。我认为初始化页面时出现错误
<xsl:strip-space elements="*"/>
等
public class AuthStepDefinitions {
private final AuthPage authPage = new AuthPage();
@When("^user on Auth Page$")
public void onAuthPage() {
AuthPage.getStartPage();
}
等
public class AuthPage extends TestBase {
private String loginPassrod = "test@test.test";
@FindBy(id = "USER_LOGIN")
private WebElement loginInput;
@FindBy(id = "USER_PASSWORD")
private WebElement userPassword;
@FindBy(className = "btn")
private WebElement btnEntrance;
@FindBy(css = "table.dataTable")
private WebElement table;
@FindBy(css = "a.button-new")
private WebElement create;
@FindBy(className = "sidebar-profile")
private WebElement profile;
public AuthPage() {
PageFactory.initElements(new HtmlElementDecorator(new HtmlElementLocatorFactory(driver)), this);
}
等
我认为这里有问题
public abstract class TestBase {
/**
* Default timeout for waiting
*/
private static final int ELEMENT_TIMEOUT_SECONDS = 20;
protected static WebDriver driver;
JavascriptExecutor js = (JavascriptExecutor) driver;
public void setup() {
System.setProperty("webdriver.chrome.driver", BaseProperties.driverDir );
driver = new ChromeDriver();
driver.manage().window().maximize();
}
protected static void onMainPage() {
driver.get("хxx");
}
以下信息可能会有所帮助
这是整个堆栈跟踪
private final AuthPage authPage = new AuthPage();
PageFactory.initElements(new HtmlElementDecorator(new HtmlElementLocatorFactory(driver)), this);
}
答案 0 :(得分:0)
对我来说会有所帮助:
public AuthPage() {
super.setup();
PageFactory.initElements(driver, this);
}
Pom.xml中的依赖关系已更新,并删除了不必要的内容。
答案 1 :(得分:-1)
在调用Pagefactory initElements方法时未初始化您的驱动程序。如下所示更新Authpage构造函数可以解决您的问题。
public AuthPage() {
super.setup();
TestBase.onMainPage();
PageFactory.initElements(new HtmlElementDecorator(new HtmlElementLocatorFactory(TestBase.driver)), this);
}