使用给定的搜索参数,无法在页面上找到元素 WebDriver \ Exception \ NoSuchElement在Behat中

问题描述

我正在尝试构建用于应用程序测试的方案,在该方案中,我输入了错误的激活码并进入“激活失败屏幕”。但是,我得到了陈述的问题。 情况:

  • 鉴于我是受邀员工
  • 我在开始屏幕上
  • 当我单击“¡Empieza ya!”时
  • 然后我应该在DNI屏幕中
  • 当我输入DNI时
  • 然后我点击“继续”
  • 然后我应该在激活码屏幕中
  • 输入错误的激活码
  • 然后我应该看到错误的激活码模式

除最后一步外,所有方法均有效。这是激活屏幕页面代码

类ActivationCodeScreen扩展了Page { / ** * @var字符串$ path * / 保护的$ 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;
}

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)