usil / seleniumjs4all

1 stars 0 forks source link

Selenium4all

Description

Framework that encapsulates the complexity of browser, driver and selenium configurations. Also adds some useful features like:

Requirements

This will give a your a report like this

image

Or a web report

image

Demo

Clone this repository https://github.com/usil/seleniumjs4all-demo and follow its readme.md

Settings

This file centralize the configurations for all your tests and the framework. Also you can use secrets with envrionment variables

Global configurations

{
  "filterByTestName": [],
  "virtualUserMultiplier": 1,
  "reportWeb": false,
  "reportMode": "staticDeep",
  "columnNames": ["enterprise", "feature", "scenario"]
}
name Description Default Value Required
filterByTestName The files or directory that you want to test, setting it to an empty array will test all files [] false
filterByRegexTestName Same of filterByTestName but with regex [] false
reportWeb Generate report on Web(HTML) false true
reportMode Change the type of report keeping its default structure or adjusting the report columns staticDeep true
columnNames The name of the columns that will be related to the directory structure [] true
virtualUserMultiplier If you want to execute more users. It multiplies the virtualUserSuites. 1 false

browserOptions

In this section you can pass custom options to the browser that will be used by selenium. Most of those variables should not be touched unless you know what you are doing. The --headless option can be removed to not run in it a non headless mode or "see as human" how automation moves your browser

"browserSettings": {
  "options" : {
    "addArguments": [
      "--log-level=1",
      "--no-sandbox",
      "--disable-gpu",
      "--disable-dev-shm-usage",
      "--headless",
      "--window-size=2200,1600"
    ]
  }
}
name Description Sample Value Required
browserSettings.options.addArguments Wellknown parameters to customize your browser. Full details here [] false
browserSettings.useLocalBrowser Will use the default browser in the os and will infer the driver true false
browserSettings.browserBinaryCustomLocation Full location of the browser (chrome or firefox) executable. C:\Program Files\Google\Chrome\Application\chrome.exe false
browserSettings.browserDriverCustomLocation Full location of the driver (chrome or firefox) executable. /opt/driver/geckodriver false

If you have problems with the chrome binary or chrome driver location, check:

virtualUserSuite

In this section you can add variables to be used at the unit test level.

name Description Default Value Required
virtualUserSuites The number of whole test suites you want to simulate and its specific configurations and variables, each test virtual user suite represents 1 user. virtualUserSuite array true
virtualUserSuites[0].identifier An identifier for this test suite Will default to the position in the array true
virtualUserSuites[0].skip The app will skip this test suite false false
virtualUserSuites[0].variables Global variables for all of the test of this suite
virtualUserSuites[0].filterByTestName The files or directory that you want to test null false null false
{
  "virtualUserSuites": [
    {
      "skip": false,
      "identifier": "first-test",
      "filterByTestName": [],
      "variables": {
        "acmeBaseUrl": "https://acme.com"
      }
    }
  ]
}

Mail settings

Useful if you want to enable an email generation with the html report attached.

{
  "smtp": {
    "enableSmtpNotification": "true",
    "disableMailNotificationOnSuccess": "true",
    "smtpHost": "10.10.20.30",
    "smtpPort": "587",
    "smtpUser": "admin",
    "smtpPassword": "changeme",
    "smtpSecure": "true",
    "smtpTlsCiphers": "SSLv3",
    "smtpSenderDisplayname": "a custom alias of sender",
    "smtpRecipients": "jane@acme.com"
  }
}
Variable Description Default Value
enableSmtpNotification If you want to send mail with report, this variable should be equals to true
disableMailNotificationOnSuccess If the test result is successful and this parameter is equal to true, the report will not be mailed.
smtpHost Sender identifier
smtpPort Communication endpoint that defines the routing of email transactions
smtpUser User of your mail server
smtpPassword Password of your mail server
smtpSecure Encrypt.
If your host is for gmail, your value should be true.
If your host is for office 365, your value should be false
true
smtpTlsCiphers Are algorithms that help secure network connections that use Transport Layer Security SSLv3
smtpSenderDisplayname It is the alias of the transmitter
smtpRecipients Recipient report for mail, It can be multiple and separated by '', ''

Shell variables

You can overwrite the files option adding FILTERED_FILES to your environment variables, separating the files or directories by an space.

In an .env file:

FILTERED_FILES = test1.test.js test2.test.js

In linux:

export FILTERED_FILES="test1.test.js test2.test.js"

In windows:

set FILTERED_FILES="test1.test.js test2.test.js"

External settings

You can have a settings.json outside of the workspace. Check this

More settings

Check the wiki https://github.com/usil/seleniumjs4all/wiki


Contributors


JRichardsz

Diego Ramos