jeudi 3 septembre 2020

An element could not be located on the page using the given search parameters. (WebDriver\Exception\NoSuchElement) in behat

I am trying to build a scenario for app testing in which I put in a wrong activation code and get to the "activation failed screen". However, I get the stated Problem. The scenario:

  • Given I am an invited employee
  • And that I am in the start screen
  • When I click on "¡Empieza ya!"
  • Then I should be in the DNI screen
  • When I enter my DNI
  • And I click on "Continuar"
  • Then I should be in the activation code screen
  • When I enter a wrong activation code
  • Then I should see the wrong activation code modal

All works but the last step. Here is the code for the activation screen page:

class ActivationCodeScreen extends Page { /** * @var string $path */ protected $path = '/';

public function enterCode($code)
{
    $this->getDriver()->getWebDriverSession()
        ->element('xpath', "//*[@class='android.widget.EditText' or @type='XCUIElementTypeTextField']")->click();
    sleep(1);
    $this->getDriver()->getWebDriverSession()
        ->element('xpath', "//*[@class='android.widget.EditText' or @type='XCUIElementTypeTextField']")->postValue(
            array("value" => str_split($code))
        );
}

public function isOpen(array $urlParameters = array())
{
    if (!$this->getDriver()->isVisible("//*[@text='Código de invitación enviado a tu email' or @label='Código de invitación enviado a tu email']")){
        throw new \Exception("Activation code screen not loading");
    }

    return true;
}


    public function isWrongActivationCodeModal()
{
    if (!$this->getDriver()->isVisible("//*[contains(@text,'¡Algo ha fallado!') or contains(@label,'¡Algo ha fallado!')]"))
    {
        throw new \Exception("Wrong Activation Code modal not visible");
    }

    return true;
}

}

Aucun commentaire:

Enregistrer un commentaire