Undefined, Undefined in Chrome notification when it's triggered from Selenium
Asked Answered
W

1

1

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.

My scenario:

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

And my context:

/**
 * @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);
}

Working notification

Broken notification

And here is the video.

Watereddown answered 23/10, 2014 at 11:11 Comment(2)
I don't see the image of what it should look like. The information you given is very limited to understand where the problem might be. Provide code. Also, if it runs normally without Behat, it should run just as fine with Behat (using the same browser that is).Severini
I've updated the question, those are called notifications and not popups, that would confuse most people reading this.Severini
S
3

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.

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.

Severini answered 24/10, 2014 at 22:2 Comment(2)
Thanks for your help in formatting and answering the question. I tried the code above in the behat.yml and the extra_capabilities is not recognised [Symfony\Component\Config\Definition\Exception\InvalidConfigurationException] Unrecognized options "extra_capabilities" under "behat.extensions.behat_minkextension_extension.selenium2.capabilities" Do you have a working example?Watereddown
It is a working example. If you are using Behat 2, the syntax might differ, if it is supported at all. Googling doesn't return any promising results and I think you are out of luck. You should upgrade if you want to get the most out of it.Severini

© 2022 - 2024 — McMap. All rights reserved.