【发布时间】:2021-01-25 21:59:32
【问题描述】:
我正在使用硒 3.6.0。我运行了一些基本测试(登录到 Stackoverflow 页面)。但是,当我发送电子邮件时,字符“@”没有传递。而不是它,在我看来,它从缓冲区中放入了一些值。
package Cucumerframework.steps;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.junit.Assert;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class StepsClass {
WebDriver driver;
@Before()
public void setup() {
System.setProperty("webdriver.chrome.driver",
"C:\\Users\\WCodeKemalK\\Cucumber\\Cucumerframework\\target\\test-classes\\Resources\\chromedriver.exe");
this.driver = new ChromeDriver();
this.driver.manage().window().maximize();
this.driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
}
@Given("^User navigates to stackoverflow website$")
public void user_navigates_to_stackoverflow_website() throws Throwable {
driver.get("https://stackoverflow.com/");
}
@Given("^User clicks on the login button on homepage$")
public void user_clicks_on_the_login_button_on_homepage() throws Throwable {
driver.findElement(By.xpath("/html/body/header/div/ol[2]/li[2]/a[1]")).click();
}
@Given("^User enters a valid username$")
public void user_enters_a_valid_username() throws Throwable {
driver.findElement(By.xpath("//*[@id=\"email\"]")).sendKeys("testmail@gmail.com");
}
@Given("^User enters a valid password$")
public void user_enters_a_valid_password() throws Throwable {
driver.findElement(By.xpath("//*[@id=\"password\"]")).sendKeys("xxxxxxx");
}
@When("^User clicks on the login button$")
public void user_clicks_on_the_login_button() throws Throwable {
driver.findElement(By.xpath("//*[@id=\"submit-button\"]")).click();
}
@Then("^User should be taken to the successful login page$")
public void user_should_be_taken_to_the_successful_login_page() throws Throwable {
Thread.sleep(3000);
WebElement askQuestionsButton = driver.findElement(By.xpath("//a[contains (text(), )]"));
Assert.assertEquals(true, askQuestionsButton.isDisplayed());
}
}
这是我得到的: https://ibb.co/k35WL3N
【问题讨论】:
-
您是否在启动测试的计算机上使用英文键盘布局?如果没有,那么“@”可能会触发另一个键(在 enligh 键盘上位于 @ 位置的那个键)
-
@LaurentBristiel 我正在使用标准键盘
标签: automated-tests selenium-chromedriver qa