selenium - 除非我手动单击浏览器元素,否则 Chromedriver 不起作用
问题描述
我是 selenium 的新手,正在尝试并行运行 firefox 和 chrome 的基本测试。Everthing 适用于 Firefox,但 chrome 无法正常工作。实际上 chrome 浏览器会打开,但什么都不做,除非我单击电子邮件输入,然后单击任何期望电子邮件输入的位置。当我这样做时,我的测试从 chrome 开始,一切正常。我真的很确定我不应该手动单击开始测试:)
这是我的页面对象;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import page.objects.AbstractPageObject;
public class LoginPage extends AbstractPageObject {
@FindBy(xpath = "//input[@type='email']")
private WebElement email;
@FindBy(xpath = "//input[@type='password']")
private WebElement password;
@FindBy(xpath = "//button[@type='submit']")
private WebElement continueButton;
public void verifyAllElementsAreDisplaying() {
email.isDisplayed();
password.isDisplayed();
continueButton.isDisplayed();
}
public void fillEmail (String userEmail) {
email.clear();
email.sendKeys(userEmail);
}
public void fillPassword (String userPassword) {
password.clear();
password.sendKeys(userPassword);
}
public void login () {
this.continueButton.click();
}
}
这是我的测试;
import org.testng.annotations.Test;
import page.objects.Login.LoginPage;
public class VerifyLogin extends BaseTest {
@Test(description = "Verfifies Login Page Functionality")
public void verifyLogin() throws InterruptedException {
LoginPage loginPage = new LoginPage();
loginPage.verifyAllElementsAreDisplaying();
loginPage.fillEmail("email");
loginPage.fillPassword("***");
Thread.sleep(2000);
}
}
在 BaseTest 类中,我有 @BeforeSuit 和 @AfterSuite 注释来管理驱动程序。
解决方案
推荐阅读
- batch-file - 用于重命名小于当前日期的所有文件的批处理脚本
- scala - Kafka Akka Streams Consumer 在超时后因 WakeupException 而中断。消息:空
- c# - RDLC 报告 - 无数据
- mysql - 为什么这条 SQL 语句不起作用
- c++ - 当一个变量用于多个函数范围时,我应该在私有类中声明一个变量吗?
- android - 不能在 onResponse 中使用适配器
- python - 多标签分类中的精度计算
- c++ - 使用 boost Spirit 解析成 STL 向量
- postgresql - PostgreSQL - FATAL: Ident authentication failed for user
- java - 使用 MapReduce 视图查询 Couchbase Lite 问题