Browserstack两次加载Cookie策略窗口

问题描述 投票:0回答:1

我正在通过nightwatchjs在Browserstack中运行测试。

该测试在本地运行正常,但是当我运行然后在Browserstack中运行时,出现以下错误消息;

enter image description here

进一步研究,似乎该错误与以下事实有关:在浏览器堆栈中运行测试时,Cookie策略窗口实际上已加载两次(本地正确一次)。

因此,当我运行测试时,它单击的是第一个“全部接受”,但是随后再次加载了同一窗口。

我的Cookie政策被解雇看起来像这样;

```exports.command = function() {
    var cookiePolicy;
    this.element('css selector', '#sp_message_iframe_117586', function(result) {
        cookiePolicy = result.value;
        this.frame(cookiePolicy, function() {
            this.elements('css selector', 'button.message-component.message-button.no-children', function(cookie) {
                if (cookie.value.length != 0) {
                    this.click('button.message-component.message-button.no-children');
                    this.frameParent();
                } else {
                    console.log('cookie policy already agreed');
                }
            });
        });
    });
};

我只是想知道是否存在另一种方法来阻止cookie策略首先显示,或者另一种方法来关闭cookie策略窗口(两次!)或一种阻止Browserstack加载两次的方法?

任何帮助将不胜感激。谢谢。

node.js nightwatch.js browserstack
1个回答
0
投票

截至目前,硒中尚不具备接受所有cookie的功能或方法,您必须使用click方法处理相同的功能,在执行click之前,请确保您确认它是否在其他框架中。以下是一些硒饼干的方法:driver.manage()。getCookies(); //返回所有Cookie的列表driver.manage()。getCookieNamed(arg0); //根据名称返回特定的cookiedriver.manage()。addCookie(arg0); //创建并添加cookiedriver.manage()。deleteCookie(arg0); //删除特定的Cookiedriver.manage()。deleteCookieNamed(arg0); //根据名称删除特定的cookiedriver.manage()。deleteAllCookies(); //删除所有cookie

© www.soinside.com 2019 - 2024. All rights reserved.