我有此功能文件:
Feature: Smoke test of Gmail
@GmailSignin
Scenario Outline: Click on Sign in
Given Open chrome
When I go to gmail and click on Sign in
When I enter "<emailid>" and "<password>"
Then I click on next
Examples:
| emailid | | password |
| sarveshsingh.03 | | ssssss.sssssss |
这是我的映射代码:
public class Gmail{
Gmailsignin endtoend =new Gmailsignin();
@Given("^Open chrome$")
public void Open_chrome() throws Throwable {
endtoend.Open_chrome();
}
@When("^I go to gmail and click on Sign in$")
public void I_go_to_gmail_and_click_on_Sign_in() throws Throwable {
endtoend.I_go_to_gmail_and_click_on_Sign_in();
}
@When("^I enter \"([^\"]*)\" and \"([^\"]*)\"$")
public void i_enter_emailidand(String emailid, String password) throws Throwable {
endtoend.I_enter_emailid_and_password(emailid, password);
}
@Then("^I click on next$")
public void i_click_on_next() throws Throwable {
endtoend.i_click_on_next();
}
这是我定义所有功能的功能代码:
public class Gmailsignin {
public static WebDriver driver;
public void Open_chrome(){
// Create a new instance of the Chromedriver
System.setProperty("webdriver.chrome.driver","D:\\chromedriver_win32\\chromedriver.exe");
driver=new ChromeDriver();
//Maximize the window.
driver.manage().window().maximize();
//could take the time the implicit wait is set for before throwing exception
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
public void I_go_to_gmail_and_click_on_Sign_in()
{
driver.get("https://www.google.com/gmail/about/#");
driver.findElement(By.xpath("/html/body/nav/div/a[2]")).click();
}
public void I_enter_emailid_and_password(String emailid, String password)
{
driver.findElement(By.id("identifierId")).sendKeys(emailid);
driver.findElement(By.id("identifierNext")).click();
driver.findElement(By.id("password")).sendKeys(password);
}
public void i_click_on_next(){
driver.findElement(By.id("passwordNext")).click();
}
当我运行运行程序文件时,它输入电子邮件ID,然后单击“下一步”,但没有输入密码,它给了我并出现错误“无法专注于元素”
在传递两个字符串之间是否可能无法执行单击操作?