【发布时间】:2015-08-19 19:37:23
【问题描述】:
步骤:
- 转到 gmail.com - 好的
2.填写有效邮箱-OK
3按下一步 - 确定
4 通过id="Passwd" FAIL 查找元素
由于有效的输入字段id= "Passwd",测试失败。
但是我检查了 gmail.com 并且该字段具有 id="Passwd" 和
Name="Passwd"。我尝试使用 CSS 定位器并再次测试失败。
我试图在单击“下一步”和在字段中填写密码之间设置一个时间间隔。没用。
可能是因为当您将电子邮件放入字段并单击“下一步”时,会有一些脚本将“电子邮件输入表单”转换为“密码输入表单” 我该如何解决这个问题?
import org.junit.After;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class GmailSIgnInTest {
WebDriver driver = new FirefoxDriver();
@Test
public void loginShouldBeSuccessfull() {
driver.get("http://gmail.com");
WebElement userNameTextBox = driver.findElement(By.id("Email"));
userNameTextBox.clear();
userNameTextBox.sendKeys("MY EMAIL HERE");
WebElement userNextButtonClick = driver.findElement(By.id("next"));
userNextButtonClick.click();
WebElement userPasswordTextBox = driver.findElement(By.id("Passwd")); // TEST FAIL
userPasswordTextBox.clear();
userPasswordTextBox.sendKeys("MY PASSWORD HERE")
;
【问题讨论】:
标签: java selenium testing automation qa