README

Venom - Executor Web

Navigate in a web application

Use case: You have a web application and you want to check some behaviours? Venom allows you to navigate into it and execute actions.

Input

Web context allows you to configure the browser used for navigation. All parameters are optional:

  • width: Width of the browser page
  • height: Height of the browser page
  • driver: chrome, gecko or phantomjs (default: phantomjs)
  • args: List of arguments for chrome driver (see here)
  • prefs: List of user preferences for chrome driver, using dot notation (see here and here)
  • timeout: Timeout in seconds (default: 180)
  • debug: Boolean enabling the debug mode of the web driver (default: false)
name: TestSuite Web
testcases:
- name: TestCase Google search
  context:
    type: web
    width: 1920
    height: 1080
    driver: phantomjs
    args:
    - 'browser-test'
    prefs:
      profile.default_content_settings.popups: 0
      profile.default_content_setting_values.notifications: 1
    timeout: 60
    debug: true
  steps:
  - action:
      navigate:
        url: https://www.google.fr
    assertions:
    - result.title ShouldEqual Google
    - result.url ShouldEqual https://www.google.fr
  - action:
      find: input[name="q"]
    assertions:
     - result.find ShouldEqual 1
  - action:
      fill:
      - find: input[name="q"]
        text: "venom ovh"
  - action:
      click:
        find: input[value="Recherche Google"]
        wait: 1
    screenshot: googlesearch.jpg

Select frame and Select root frame actions help you to navigate into your differents frames. After the frame selection, you can manipulate web elements presents in a frame. Two statements:

  • SelectFrame: One find parameter to select the frame with CSS selector
  • SelectRootFrame: One boolean parameter, must be true to activate the statement Example:
name: TestSuite SelectFrame
testcases:
- name: TestCase SelectFrame 
  context:
    type: web
    driver: phantomjs
    debug: true
  steps:
  - action:
      navigate:
        url: https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_open
  - action:
      selectFrame:
        find: iframe[id='iframeResult']
  - action:
      find: body > button
    assertions:
    - result.find ShouldEqual 1
  - action:
      find: a#tryhome
    assertions:
    - result.find ShouldEqual 0
  - action:
      selectRootFrame: true
  - action:
      find: body > button
    assertions:
    - result.find ShouldEqual 0
  - action:
      find: a#tryhome
    assertions:
    - result.find ShouldEqual 1

Next Window action allow you to change the current window Next Window have one boolean parameter, this parameter must be true Example:

name: TestSuite NextWindow
testcases:
- name: TestCase NextWindow 
  context:
    type: web
    driver: chrome
    debug: true
  steps:
  - action:
      navigate:
        url: https://javascript.info/popup-windows
  - action:
      click:
        find: article > div:nth-child(3) > div:nth-child(17) a[data-action='run']
        wait: 4
    screenshot: beforeNextWindow.png
  - action:
      nextWindow: true
    screenshot: resultNextWindow.png
    assertions:
      - result.url ShouldStartWith https://www.google.com

Upload file actiow allow you to upload file with file input web component Example:

name: TestSuiteUploadFile
testcases:
- name: TestCaseUploadFile
  context:
    type: web
    driver: chrome
    debug: true
  steps:
  - action:
      navigate:
        url: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_file
  - action:
      selectFrame:
        find: iframe[id='iframeResult']
  - action:
      uploadFile:
        find: form:nth-child(3) input#myfile
        files:
        - myFile.png
    screenshot: "result.png"

Select statement allow to manipulate select web element Select statement have 3 parameters

  • find: CSS selector to identify the select web element
  • text: Text to use to selection the option
  • wait: optionnal parameter to wait after the statement (in seconds) Example
name: TestSuite Select
testcases:
- name: TestCase Select 
  context:
    type: web
    driver: phantomjs
    debug: true
  steps:
  - action:
      navigate:
        url: https://html.com/tags/select/
  - action:
      select:
        find: article[id='post-289'] select
        text: 'Andean flamingo'
        wait: 1
    screenshot: selectAndean.png
  - action:
      select:
        find: article[id='post-289'] select
        text: 'American flamingo'
    screenshot: selectAmerican.png

ConfirmPopup and CancelPopup actions allow you to manipulate modal dialog initialized by the alert and confirm javascript statement. These two actions have one boolean parameter and the parameter value must be true to activate the action. These actions are not compatible with PhantomJS driver.

Example:

name: TestSuite Popup
testcases:
- name: TestCase Popup 
  context:
    type: web
    driver: chrome
    debug: true
  steps:
  - action:
      navigate:
        url: https://javascript.info/alert-prompt-confirm
  - action:
      click:
        find: article > div:nth-child(3) > div:nth-child(8) a[data-action='run']
        wait: 1
  - action:
      ConfirmPopup: true
  - action:
      click:
        find: article > div:nth-child(3) > div:nth-child(26) a[data-action='run']
        wait: 1
  - action:
      ConfirmPopup: true
  - action:
      ConfirmPopup: true
  - action:
      click:
        find: article > div:nth-child(3) > div:nth-child(26) a[data-action='run']
        wait: 1
  - action:
      CancelPopup: true
  - action:
      ConfirmPopup: true

History actions allow you to manipulate browser history actions. The following action are available:

  • back
  • refresh
  • forward

Example:

name: TestSuiteNavigationHistory
testcases:
- name: TestCaseNavigationHistory
  context:
    type: web
    driver: chrome
    debug: true
  steps:
  - action:
      navigate:
        url: https://www.google.com
  - action:
        fill:
        - find: input[name='q']
          text: ovh venom github
    screenshot: search.png
  - action:
        click:
            find: div[jsname='VlcLAe'] input[name='btnK']
            wait: 2
  - action:
        historyAction: back
  - action:
        historyAction: refresh
  - action:
        historyAction: forward

Output

  • result.url
  • result.timeseconds
  • result.timehuman
  • result.title
  • result.find
Expand ▾ Collapse ▴

Documentation

Index

Constants

View Source
const Name = "web"

    Name of executor

    Variables

    View Source
    var Keys = map[string]string{
    	"NULL":            "\uE000",
    	"CANCEL":          "\uE001",
    	"HELP":            "\uE002",
    	"BACK_SPACE":      "\uE003",
    	"TAB":             "\uE004",
    	"CLEAR":           "\uE005",
    	"RETURN":          "\uE006",
    	"ENTER":           "\uE007",
    	"SHIFT":           "\uE008",
    	"LEFT_SHIFT":      "\uE008",
    	"CONTROL":         "\uE009",
    	"LEFT_CONTROL":    "\uE009",
    	"ALT":             "\uE00A",
    	"LEFT_ALT":        "\uE00A",
    	"PAUSE":           "\uE00B",
    	"ESCAPE":          "\uE00C",
    	"SPACE":           "\uE00D",
    	"PAGE_UP":         "\uE00E",
    	"PAGE_DOWN":       "\uE00F",
    	"END":             "\uE010",
    	"HOME":            "\uE011",
    	"LEFT":            "\uE012",
    	"ARROW_LEFT":      "\uE012",
    	"UP":              "\uE013",
    	"ARROW_UP":        "\uE013",
    	"RIGHT":           "\uE014",
    	"ARROW_RIGHT":     "\uE014",
    	"DOWN":            "\uE015",
    	"ARROW_DOWN":      "\uE015",
    	"INSERT":          "\uE016",
    	"DELETE":          "\uE017",
    	"SEMICOLON":       "\uE018",
    	"EQUALS":          "\uE019",
    	"NUMPAD0":         "\uE01A",
    	"NUMPAD1":         "\uE01B",
    	"NUMPAD2":         "\uE01C",
    	"NUMPAD3":         "\uE01D",
    	"NUMPAD4":         "\uE01E",
    	"NUMPAD5":         "\uE01F",
    	"NUMPAD6":         "\uE020",
    	"NUMPAD7":         "\uE021",
    	"NUMPAD8":         "\uE022",
    	"NUMPAD9":         "\uE023",
    	"MULTIPLY":        "\uE024",
    	"ADD":             "\uE025",
    	"SEPARATOR":       "\uE026",
    	"SUBTRACT":        "\uE027",
    	"DECIMAL":         "\uE028",
    	"DIVIDE":          "\uE029",
    	"F1":              "\uE031",
    	"F2":              "\uE032",
    	"F3":              "\uE033",
    	"F4":              "\uE034",
    	"F5":              "\uE035",
    	"F6":              "\uE036",
    	"F7":              "\uE037",
    	"F8":              "\uE038",
    	"F9":              "\uE039",
    	"F10":             "\uE03A",
    	"F11":             "\uE03B",
    	"F12":             "\uE03C",
    	"META":            "\uE03D",
    	"COMMAND":         "\uE03D",
    	"ZENKAKU_HANKAKU": "\uE040",
    }

      Keys map returning key code by its name

      Functions

      func New

      func New() venom.Executor

        New returns a new Executor

        Types

        type Action

        type Action struct {
        	Click           *Click       `yaml:"click,omitempty"`
        	Fill            []Fill       `yaml:"fill,omitempty"`
        	Find            string       `yaml:"find,omitempty"`
        	Navigate        *Navigate    `yaml:"navigate,omitempty"`
        	Wait            int64        `yaml:"wait,omitempty"`
        	ConfirmPopup    bool         `yaml:"confirmPopup,omitempty"`
        	CancelPopup     bool         `yaml:"cancelPopup,omitempty"`
        	Select          *Select      `yaml:"select,omitempty"`
        	UploadFile      *UploadFile  `yaml:"uploadFile,omitempty"`
        	SelectFrame     *SelectFrame `yaml:"selectFrame,omitempty"`
        	SelectRootFrame bool         `yaml:"selectRootFrame,omitempty"`
        	NextWindow      bool         `yaml:"nextWindow,omitempty"`
        	HistoryAction   string       `yaml:"historyAction,omitempy"`
        }

          Action represents what can be done with web executor

          type Click

          type Click struct {
          	Find string `yaml:"find,omitempty"`
          	Wait int64  `yaml:"wait"`
          }

            Click represents informations needed to click on web components

            type Executor

            type Executor struct {
            	Action     Action `json:"action,omitempty" yaml:"action"`
            	Screenshot string `json:"screenshot,omitempty" yaml:"screenshot"`
            }

              Executor struct

              func (Executor) Run

              func (Executor) Run(testCaseContext venom.TestCaseContext, l venom.Logger, step venom.TestStep, workdir string) (venom.ExecutorResult, error)

                Run execute TestStep

                func (Executor) ZeroValueResult

                func (Executor) ZeroValueResult() venom.ExecutorResult

                  ZeroValueResult return an empty implemtation of this executor result

                  type Fill

                  type Fill struct {
                  	Find string  `yaml:"find,omitempty"`
                  	Text string  `yaml:"text,omitempty"`
                  	Key  *string `yaml:"key,omitempty"`
                  }

                    Fill represents informations needed to fill input/textarea

                    type Navigate struct {
                    	Url   string `yaml:"url,omitempty"`
                    	Reset bool   `yaml:"reset,omitempty"`
                    }

                      Navigate represents informations needed to navigate on defined url

                      type Result

                      type Result struct {
                      	Executor    Executor `json:"executor,omitempty" yaml:"executor,omitempty"`
                      	Find        int      `json:"find,omitempty" yaml:"find,omitempty"`
                      	HTML        string   `json:"html,omitempty" yaml:"html,omitempty"`
                      	TimeSeconds float64  `json:"timeseconds,omitempty" yaml:"timeseconds,omitempty"`
                      	TimeHuman   string   `json:"timehuman,omitempty" yaml:"timehuman,omitempty"`
                      	Title       string   `json:"title,omitempty" yaml:"title,omitempty"`
                      	URL         string   `json:"url,omitempty" yaml:"url,omitempty"`
                      	Text        string   `json:"text,omitempty" yaml:"text,omitempty"`
                      	Value       string   `json:"value,omitempty" yaml:"value,omitempty"`
                      }

                        Result represents a step result

                        type Select

                        type Select struct {
                        	Find string `yaml:"find,omitempty"`
                        	Text string `yaml:"text,omitempty"`
                        	Wait int64  `yaml:"wait,omitempty"`
                        }

                          Select represents informations needed to select an option

                          type SelectFrame

                          type SelectFrame struct {
                          	Find string `yaml:"find,omitempty"`
                          }

                            SelectFrame represents informations needed to select the frame

                            type UploadFile

                            type UploadFile struct {
                            	Find  string   `yaml:"find,omitempty"`
                            	Files []string `yaml:"files,omitempty"`
                            	Wait  int64    `yaml:"wait,omitempty"`
                            }

                              UploadFile represents informations needed to upload files