Domanda

Mi chiedo se è possibile eseguire una funzione di cetriolo da un'altra funzione?Ad esempio:

@When("^I am at the User list page$")
public void I_am_at_the_User_list_page() throws InterruptedException {
    if(!driver.findElement(By.xpath("//a[contains(text(), 'User List')]")).isDisplayed()){
        driver.findElement(By.xpath("//td[contains(text(), 'Management')]")).click();
    }
    driver.findElement(By.xpath("//a[contains(text(), 'User List')]")).click();
    Assert.assertTrue("User list is showing", driver.getTitle().equals("Admin Portal -User list"));
    if(driver.findElements(By.xpath("//td[text()='\" + loginNewUserUsername() + \"']")).isEmpty()){
        //run.cucumber.feature(deleteuser.feature);//
    }
    driver.findElement(By.xpath("//a[contains(text(), 'Add User')]")).click();
    Assert.assertTrue("Entered Add User site", driver.findElement(By.id("editUserForm:changePasswordCheckBox")).isDisplayed());
}
.

È stato utile?

Soluzione

Mentre non lo farei mentre diventa disordinato, aggrovigliato, l'effetto può essere ottenuto indirettamente chiamando i passaggi (metodi).

if(...).isEmpty()){

  //call the methods/steps that makes up your feature/scenarios

  I_am_at_the_User_list_page();
  I_enter_username_as("blah");    
}
.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top