保持量角器浏览器会话活着 [英] keep protractor browser session alive

查看:196
本文介绍了保持量角器浏览器会话活着的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我到处找,但它看起来像我只问这个人。

I have looked everywhere but it looks like I am only person asking this.

如何让浏览器会话中量角器活着,不要有登陆我每次运行测试。我已经把登录逻辑在上prepare ,以避免为每个测试功能记录

How to keep browser session in protractor alive, not to have to login everytime I run a test. I have put login logics in onPrepare to avoid logging for every test function

onPrepare: function() {
    var mymodule = require("./e2e/mymodule");
    mymodule.login();
    mymodule.switchToProject("someproject");
}

但还是登录需要3-4秒,每次运行量角器,我想跳过的时间。任何想法的?

But still logging in takes 3-4 seconds for every time I run protractor which I would like to skip. Any idea's ?

我preFER的解决方案为 chromeOnly:真正的设置但是对于单独的硒服务器的解决方案将是罚款,以及

I prefer a solution for chromeOnly: true setting but a solution for seperate selenium server would be fine as well

推荐答案

量角器创建每次运行时一个全新的Chrome配置文件。与此搞乱之前,你需要知道,这提供了可靠性,你的测试:他们将运行同样的方式,每次因为它们是从一张白纸开始。如果您决定使用已记录在一个持续配置,那么你的量角器测试开始后尽快登录到期,该配置文件被删除,失败或尝试在不同的计算机上运行它们。

Protractor creates a brand new Chrome profile every time it runs. Before messing with this, you need to be aware that this provides reliability for your tests: they will run the same way every time because they are starting from a blank slate. If you decide to use a persistent profile that is already logged in, then your Protractor tests will start failing as soon as the login expires, the profile gets deleted, or you try to run them on a different computer.

这是说,还有一个办法让Chrome浏览器重复使用相同的配置文件(包括饼干和所有设置)为量角器测试每次运行。在你的 protractor.conf.js 你会做这样的事情:

That said, there is a way to ask Chrome to reuse the same profile (including cookies and all settings) for each run of Protractor tests. In your protractor.conf.js you'll do something like this:

capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
        'args': ['--user-data-dir=/a/random/path']
    }
}

ARGS这里是执行部分。它可以让你通过命令行参数来量角器的Chrome版本在启动时(例如,​​你可以在通 - 启动最大化最大化启动浏览器)。

The 'args' here is the operative part. It lets you pass command-line arguments to Protractor's version of Chrome when it starts up (for example, you could pass in '--start-maximized' to maximize Chrome on startup).

与您的系统上的任何文件路径(从根开始)替换 / A /随机/路径。只要确保已创建了您要引用的文件夹。你并不需要使用自己的Chrome个人资料路径 - 这只是不必要的麻烦。地方创建一个文件夹并使用它。

Replace /a/random/path with any file path (starting from root) on your system. Just make sure the folders you're referencing have been created. You don't need to use your own Chrome profile path--that's just unnecessary hassle. Create a folder somewhere and use it.

在量角器启动浏览器,其配置文件将在您指定的位置,它会继续,只要用它作为你的路径保持不变。

When Protractor starts Chrome, its profile will be in the location you specified, and it will continue to use it as long as your path remains unchanged.

请,这是一个的浏览器操作的,一点都没有涉及到什么硒或量角器在做什么。我不知道是否有一种方法与Firefox或其他浏览器要做到这一点,因为每一个表面上有它自己的存储用户配置文件的方式。

Keep in mind that this is a browser operation, not at all related to what Selenium or Protractor is doing. I don't know if there is a way to do this with Firefox or other browsers, since each one ostensibly has its own way of storing user profiles.

这篇关于保持量角器浏览器会话活着的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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