微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决使用给定的搜索参数,无法在页面上找到元素 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 举报,一经查实,本站将立刻删除。