Skip to content

Latest commit

 

History

History
527 lines (419 loc) · 11.2 KB

Config.md

File metadata and controls

527 lines (419 loc) · 11.2 KB

Config

QApe will look for a configuration file at current working directory called qape.conf.js with following format.

module.exports = {
  url: 'https://www.seznamzpravy.cz'
}

Options

Options

actionsPerScenario

<number>

Maximal number of actions performed in a random scenario (if error occures, the scenario is ended)

Default:

100

afterActionScript

<Function>

Script executed after each action

Default:

(/* browser, page, pageErrorHandler */) => {}

afterActionWaitTime

<number>

Wait time after each action, there should be some delay so the javascript at your website is executed and an error is displayed before performing another action.

Default:

500

afterScenarioScript

<Function>

Script executed after each scenario

Default:

(/* { browser, page } */) => {}

beforeActionScript

<Function>

Script executed before each action

Default:

(/* browser, page, pageErrorHandler */) => {}

beforeScenarioScript

<Function>

Script executed before each scenario

Default:

(/* { browser, page } */) => {}

browserWebSocketEndpoint

<string>

A browser websocket endpoint to connect to (i.e. ws://5.5.5.5:3505)

Default:

null

customActions

<string[]>

List of paths to your custom actions, you can use glob patterns.

Default:

[]

debug

<boolean>

Enables debug mode with extra logging

Default:

false

defaultBrowserSettings

<Object>

Default browser settings passed to puppeteer.launch()

Default:

{
	"ignoreHTTPSErrors": true,
	"defaultViewport": {
		"width": 1280,
		"height": 720
	},
	"args": [
		"--start-maximized",
		"--user-agent=Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"
	]
}

defaultNavigationTimeout

<number>

Default navigation timeout set via page.setDefaultNavigationTimeout()

Default:

60000

elementSelector

<string>

XPath selector to gather all visible elements. There are also some extra filters, which remove elements with children (only elements without children are considered interactable), or zero size elements.

Default:

//body//*[not(self::script or self::noscript or self::path or self::style) and not(ancestor::*[self::script or self::noscript or self::path or self::style])]

files

<string[]>

File paths to regression tests generated by QApe file reporter. Glob patterns are allowed.

Default:

[]

getElementSelector

<Function>

Script executed in browser context, which should generate unique element selector

Default:

(input) => {
            function getTagSelector(tagName) {
                const tag = tagName.toLowerCase();

                // Some tag names cannot be simply selected by xpath
                if (['svg', 'path'].includes(tag)) {
                    return `*[local-name() = '${tag}']`;
                }

                return tag;
            }

            function getPathTo(element) {
                if (element === document.body) {
                    return '//' + element.tagName.toLowerCase();
                }

                if (!element.parentNode) {
                    return '/';
                }

                var siblings = element.parentNode.childNodes;
                var index = 0;

                for (var i = 0; i < siblings.length; i++) {
                    var sibling = siblings[i];

                    if (sibling === element) {
                        return (
                            getPathTo(element.parentNode) +
                            '/' +
                            getTagSelector(element.tagName) +
                            '[' +
                            (index + 1) +
                            ']'
                        );
                    }

                    if (sibling.nodeType === 1 && sibling.tagName === element.tagName) {
                        index++;
                    }
                }
            }

            return getPathTo(input);
        }

headlessModeDisabled

<boolean>

Disables chromium headless mode and will display browser GUI.

Default:

false

minifyUserDefinedScenarios

<boolean>

When user defined scenario recieves an error, it will try to minify the steps to reproduce this error.

Default:

true

numberOfActionFailuresToAbortRandomScenario

<number>

Number of execution errors of actions to abort the random scenario. This prevents from infinity loops, when qape is not able to perform any action on the page and keeps retrying.

Default:

20

numberOfAllowedActionsToReproduceErrorFromPreviousRun

<number>

After an error occured, qape will try to reproduce the error again and will retry up to this number of actions before giving up.

Default:

20

pageErrorHandler

<Function>

Page error handler, which should tell what is actually an error. Function is evaluated in the browser context via page.evaluateOnNewDocument() and has method "qapeError(error)" available.

Default:

() => {
            window.addEventListener('error', (event) => {
                qapeError(event.error.stack); // eslint-disable-line no-undef
            });
        }

parallelInstances

<number>

Number of parallel chrome instances initialized

Default:

1

previewMode

<boolean>

Preview mode will overwrite other config values to display the scenario on the local computer in non-headless mode. It will also run only user defined scenarios and will not try to minify them.

Default:

false

previewModePauseTime

<number>

Wait time (in ms) between actions in preview mode.

Default:

1500

randomScenariosDisabled

<boolean>

Disables random scenarios, only user defined scenarios will be executed

Default:

false

reportPath

<string>

Relative path for the report output

Default:

./report

reporters

<string[]|Class[]>

Define your reporters for the QApe run. You can pass a string for reporters in npm registry, i.e. if you pass 'super', QApe will look for reporter 'qape-reporter-super'. You can also pass Class.

Default:

[
	"console",
	"file",
	"spinner"
]

shouldRequestCauseError

<Function>

This method is called whenever any page request recieves a response. It recieves a puppeteer.Response and QApe config as arguments and should return a boolean value. If it returns true, then the recieved request response is considered a page error.

Default:

(response /* , config */) => response.status() >= 500

stopNewScenariosAfterTime

<number>

Time in ms, after which no more scenarios will be initialized, set to 0 to run forever

Default:

10000

testerTimeout

<number>

If a tester did not send any message for this period of time, it will be killed and replaced with a new one.

Default:

300000

typeActionDelay

<number>

Delay between key strokes for type action so it would seem more user-like.

Default:

20

typeActionTextTypes

<string[]>

Available text types from npm package "faker", which will generate string of the random type from this list.

Default:

[
	"name.firstName",
	"name.lastName",
	"name.findName",
	"name.prefix",
	"name.suffix",
	"address.zipCode",
	"address.city",
	"address.cityPrefix",
	"address.citySuffix",
	"address.streetName",
	"address.streetAddress",
	"address.streetSuffix",
	"address.secondaryAddress",
	"address.county",
	"address.country",
	"address.state",
	"address.stateAbbr",
	"address.latitude",
	"address.longitude",
	"phone.phoneNumber",
	"phone.phoneNumberFormat",
	"phone.phoneFormats",
	"internet.avatar",
	"internet.email",
	"internet.userName",
	"internet.domainName",
	"internet.domainSuffix",
	"internet.domainWord",
	"internet.ip",
	"internet.userAgent",
	"internet.color",
	"internet.password",
	"company.suffixes",
	"company.companyName",
	"company.companySuffix",
	"company.catchPhrase",
	"company.bs",
	"company.catchPhraseAdjective",
	"company.catchPhraseDescriptor",
	"company.catchPhraseNoun",
	"company.bsAdjective",
	"company.bsBuzz",
	"company.bsNoun",
	"image.image",
	"image.avatar",
	"image.imageUrl",
	"image.abstract",
	"image.animals",
	"image.business",
	"image.cats",
	"image.city",
	"image.food",
	"image.nightlife",
	"image.fashion",
	"image.people",
	"image.nature",
	"image.sports",
	"image.technics",
	"image.transport",
	"lorem.words",
	"lorem.sentence",
	"lorem.sentences",
	"lorem.paragraph",
	"lorem.paragraphs",
	"helpers.randomNumber",
	"helpers.randomize",
	"helpers.slugify",
	"helpers.replaceSymbolWithNumber",
	"helpers.shuffle",
	"helpers.mustache",
	"helpers.createCard",
	"helpers.contextualCard",
	"helpers.userCard",
	"helpers.createTransaction",
	"date.past",
	"date.future",
	"date.between",
	"date.recent",
	"random.number",
	"random.array_element",
	"random.object_element",
	"random.uuid",
	"finance.account",
	"finance.accountName",
	"finance.mask",
	"finance.amount",
	"finance.transactionType",
	"finance.currencyCode",
	"finance.currencyName",
	"finance.currencySymbol",
	"hacker.abbreviation",
	"hacker.adjective",
	"hacker.noun",
	"hacker.verb",
	"hacker.ingverb",
	"hacker.phrase"
]

url

<string>

Starting url for all random scenarios

Default:

http://localhost:4444

urlPaths

<string[]>

List of start url paths for random scenarios

Default:

[
	"/"
]