未定义,在Chrome通知不确定的,当它从硒触发 [英] Undefined, Undefined in Chrome notification when it's triggered from Selenium

查看:149
本文介绍了未定义,在Chrome通知不确定的,当它从硒触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的自动化,用Python编写的一个网站,那里有很多的确认通知,采用了棱角分明。我的问题是,贝哈特似乎并没有认识到这些通知,更不用说让我与他们进行互动。

I am working on automating a website written in Python and using Angular where there are many confirmation notifications. The issue I have is that Behat doesn't seem to recognise those notifications, let alone allow me to interact with them.

我的通知应该是什么样子和未定义附截图 - 未定义错误信息贝哈特产生,而不是

I have attached screenshots of what the notification should look like and the Undefined – Undefined error message Behat produces instead.

我的情况:

Then I select the Delete the Media Plan Line Checkbox
And I delete the Media Plan Line
And I select Yes to confirm the deletion
And I select No to confirm the deletion

我的背景:

/**
 * @Then /^I select the Delete the Media Plan Line Checkbox$/
 */
public function iDeleteMediaPlanLineCheckbox()
{
    /**
     * @var AddMediaPlan $addMediaPlan
     */
    $addMediaPlan= $this->getPage('AddMediaPlan');
    $addMediaPlan->deleteMediaPlanLineCheckbox();
}

/**
 * @Given /^I delete the Media Plan Line$/
 */
public function iDeleteTheMediaPlanLine()
{
    /**
     * @var AddMediaPlan $addMediaPlan
     */
    $addMediaPlan= $this->getPage('AddMediaPlan');
    $addMediaPlan->deleteMediaPlanLines();
}

public function deleteMediaPlanLineCheckbox ()
{
    $this->getElement('deleteMediaPlanLineArea')->click();
    $this->getSession()->wait(2000);
    $element = $this->getElement('deleteMediaPlanLineCheckbox');
    $this->scrollWindowToElement($element);
    $element->click();
    $this->getSession()->wait(4000);
}

public function deleteMediaPlanLines ()
{
    $this->getSession()->wait(2000);
    $this->getElement('deleteMediaPlanLines')->click();
    $this->getSession()->wait(800000);
}

public function deletePopUpYes ()
{
    $this->getElement('deletePopUpYes')->click();
    $this->getSession()->wait(2000);
}

public function deletePopUpNo ()
{
    $this->getElement('deletePopUpNo')->click();
    $this->getSession()->wait(2000);
}

工作的通知

破碎通知

这里是视频。

推荐答案

如果我没有理解错的一切,你所谈论的通知,而不是弹出窗口。通知直到今天仍然是pretty很多实验性的功能,有些浏览器不支持他们。我还以为那些支持他们的浏览器有不同的API调用它们,其中没有一个是的一部分的webdriver 的API,它用于通过贝哈特

If I understand everything correctly, you are talking about notifications, not popups. Notifications up to this day remain pretty much experimental features and some browsers don't support them. I also assume that the browsers that do support them have different APIs for invoking them, none of which are part of the Webdriver API, which is used by Behat.

我敢肯定,你可以找到一个办法让通知显示正确的细节,但你绝对无法与之交互。这里的另一个回答支持我的想法。

I'm sure you can find a way to make the notification display proper details, but you definitely won't be able to interact with it. Here's another answer supporting my thoughts.

我可以看到Chrome的视频抱怨的安全性,这可能是为什么你得到了一个未定义值的问题,解决这个问题的方法是通过此配置的硒会话(这是贝哈特3配置为例):

I can see that Chrome in the video complains about the security, this might be the problem why you get undefined values, the way to solve this is to pass this config to the selenium session (this is Behat 3 config example):

selenium2:
    browser: 'chrome'
    capabilities:
        browser: 'chrome'
        extra_capabilities:
            chromeOptions:
                args:
                    - '--test-type'

有趣的问题,虽然,它不应该被downvoted。

Nice question though, it shouldn't be downvoted.

这篇关于未定义,在Chrome通知不确定的,当它从硒触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆