Skip to content

Best way to load parts of config from external sources and setting workspace available scripts. #6

@AlexMihailescu

Description

@AlexMihailescu

tl;dr:
load external code into config.js via $.getJSON/Script?
getting lo-dash loaded and running in workspace from within onLoadPage and setup?

Currently I'm trying to switch from Selenium based tests to this as the overhead seems much less and this should be much faster, however I'm trying to make the config to better suit my tests which were based around page objects but lack the understanding to do.
The first issue which I had was that that the config,js would become a pain to maintain due to various different information I need to have, so I thought that I could load parts of it by JSON or JavaScript. This I did via appending:

$.getJSON("test_assets/logins.json")
    .done(function(data){
        global.monkeytestjs.config.logins = data;
    });

in the config.js and it works fine. Is there a more appropriate way of doing this?
The larger issue I'm having is that I almost always need access to helper script functions in the workspace which use jQuery. With Selenium I just injected my own script before each test, however here I'm having trouble running such scripts in the workspace when their set in the config. For example I tried adding the following into the config,js:

fun: function(a) {
            $("#username").val(a);
        }

However when called from a test this seems to work only on the parent page, so how would I go about:

  1. giving the workspace a function/library before each tests with onLoadPage
  2. getting/setting a function/library and having them execute inside workspace when inside test code, more specifically from setup in a test
    e.g getting lo-dash loaded and running in workspace

Thanks for your time,
Alex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions