8000 Suites for authenticated pages · Issue #799 · gemini-testing/gemini · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Suites for authenticated pages #799

Open

Description

@zouxuoz

Hey, guys. I'm starting writing regression tests for my application and gemini is awesome, but I have some problems with protected pages.

I want to authenticate user before the start gemini suite, but it's not working because functions executed in browser context.

gemini.suite('As authenticated user, I can see dasboard', (suite) => {
  suite.setUrl('/dasboard')
    .before(function(actions) {
      actions.executeJS(function(window) {
        helpers.asUser({ authenticated: true }).then(function({ token }) {
          setCookie(window.document, TOKEN_COOKIE_NAME, token, {
            expires: 7,
            domain: TOKEN_COOKIE_DOMAIN,
          });

          window.authenticated = true;
        });
      });

      actions.waitForJSCondition(function(window) {
        return window.authenticated;
      }, 120000);
    })
    .setCaptureElements('body')
    .capture('1440x1024', function(actions) {
      actions.setWindowSize(1440, 1024);
    })
  ;
});

How I can pass some variables and functions to browser context with gemini or may be exist another way to resolve my case?

Activity

  1. nbasov commented on Jul 23, 2017

    @nbasov

    .before will be applied after specified url loading (before you set cookie). To handle that, you need to call this url once again. Here is working example (but for localStorage in my case):

    gemini.suite('login', (suite) => {
        suite.setUrl('/login')
            .setCaptureElements('body')
            .capture('plain', function (actions, elements) {
                actions.executeJS(function (window) {
                    // set token for next suite
                    window.localStorage.setItem("token", "secret")
                })
            })
    })
    
    gemini.suite('main', (suite) => {
        suite.setUrl('/')
            .setCaptureElements('html')
            .capture('plain')
    });
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0