如何在黃瓜JVM的兩步之間傳遞值?<Cucumber-JVM>在黃瓜步驟之間傳遞值
在下面的情況下,我想訪問提供的用戶名當在步驟中的步驟。 如何在黃瓜JVM的兩個步驟之間傳遞值?目前我通過將該值保存到公共變量中來訪問這些值。該方法是否正確(或)我可以通過其他方式訪問這些步驟之間的方法?
場景:
鑑於用戶 當用戶輸入用戶名爲user1和密碼PASS1 登錄頁面並點擊登錄按鈕 然後登錄後頁面顯示
@When("^user enters username as ([^\"]*) and password as ([^\"]*)$")
public void enterLoginDetails(String username,String password){
driver.findElement(By.id("username")).sendKeys(username);
driver.findElement(By.id("password")).sendKeys(password);
}
在下面步驟定義,我想從上一步定義訪問用戶名
@Then("^post login page is displayed$")
public void postLoginValidation(){
// i would like access username and verify username is displayed
}
預先感謝
尋找一個回答這個問題。你能找出除了以下答案 –
以外的任何可能的重複:https://stackoverflow.com/questions/26422470/good-practice-to-pass-variables-between-cucumber-jvm-steps – Marit
可能的重複[在cucumber-jvm步驟之間傳遞變量的最佳做法](https://stackoverflow.com/questions/26422470/good-practice-to-pass-variables-between-cucumber-jvm-steps) – Marit