未定义,从 Selenium 触发时在 Chrome 通知中未定义 [英] Undefined, Undefined in Chrome notification when it's triggered from Selenium

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

问题描述

我正在致力于自动化一个用 Python 编写的网站,并在有许多确认通知的地方使用 Angular.我遇到的问题是 Behat 似乎无法识别这些通知,更不用说允许我与它们交互了.

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.

我附上了通知应该是什么样子的屏幕截图,以及 Behat 产生的 Undefined – Undefined 错误消息.

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);
}

工作通知

中断通知

这里是视频.

推荐答案

如果我理解正确的话,你说的是通知,而不是弹出窗口.直到今天,通知仍然几乎是实验性的功能,有些浏览器不支持它们.我还假设支持它们的浏览器有不同的 API 来调用它们,它们都不属于 Webdriver API,由 Behat 使用.

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 抱怨安全性,这可能是您获得未定义值的问题,解决此问题的方法是将此配置传递给 selenium 会话(这是 Behat 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'

虽然这个问题很好,但不应该被否决.

Nice question though, it shouldn't be downvoted.

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

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