【发布时间】:2020-12-05 13:50:52
【问题描述】:
老实说,此时我什至不知道该怎么做,我在控制台中没有收到任何错误日志,只有我放入脚本中的记录器消息。
当我到达创建仪表板构造函数的代码行时,它会终止测试并声明它失败,最后记录的消息始终是“即将开始查找”
我什至在发布这个问题之前删除了整个构造函数(注释掉了所有代码,删除了驱动程序参数,并在其中放入了一个 print 语句),当我在类中调用 print 方法时,脚本在构造函数的创建发生了。
我不明白发生了什么我可能会遗漏一些非常明显的东西。我失败了,但我也不一定会在控制台中看到特定的错误消息。
这是我试图运行的测试用例:
package com.symphio.testCases;
import java.util.concurrent.TimeUnit;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.symphio.pageObjects.Dashboard;
import com.symphio.pageObjects.loginSymphio;
public class TC_Dashboard_Search_002 extends BaseClass{
@Test
public void searchForTile() throws InterruptedException {
logger.info("Connected to "+ baseURL);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
loginSymphio login = new loginSymphio(driver);
//logs in
login.setUserName(userName);
logger.info("entered username");
login.setPassWord(passWord);
logger.info("entered password");
login.pressSubmit();
logger.info("button pressed");
//searches for tile
Thread.sleep(3000);
logger.info("about to start looking");
Dashboard dashboard = new Dashboard(driver);
dashboard.mouseMover();
logger.info("found Icon");
dashboard.searchBarText(searchText);
logger.info("input text");
dashboard.tileClick();
logger.info("clicked");
}
}
这是我的仪表板页面对象
package com.symphio.pageObjects;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
public class Dashboard {
WebDriver driver;
public Dashboard(WebDriver driver) {
this.driver = driver;
PageFactory.initElements(driver, this);
}
@FindBy(className="search-container")
WebElement searchImg;
@FindBy(xpath="//input[@type='search']")
WebElement searchText;
@FindBy(xpath="//input[contains(@class,'mat-card'), and contains(@class, 'mat-focus-indicator'), and contains(@class, 'arrangement-card')]")
WebElement tileBox;
Actions actions = new Actions(driver);
public void mouseMover() {
Actions mouseOverOnElement = actions.moveToElement(searchImg);
mouseOverOnElement.perform();
}
public void searchBarText(String text) {
searchText.sendKeys(text);
}
public void tileClick() {
tileBox.click();
}
}
控制台错误:
【问题讨论】:
-
失败日志在哪里?如果您从
testng.xml文件运行测试,请将 verbose 属性添加到它。 -
似乎在我添加了详细属性之后,我能够看到实际错误,这是一个空指针异常错误,这是一个很大的帮助,因为现在我知道要开始解决什么问题了
标签: java selenium maven google-chrome selenium-chromedriver