Coder Social home page Coder Social logo

simflow's Introduction

simflow

Simply define and run your flows in Chrome.

NPM Version Build Test Coverage

Install

npm i -g simflow

Usage

simflow <flows...> [options...]

Flows are defined in JSON config file.

Example

This example demonstrates a simple flow of searching GitHub project and take a sreenshot of search results.

  • Create example-gh-simflow.json:

    {
      "url": "https://github.com",
      "references": {
        "searchField": "[name='q']",
        "searchButton": "[type='submit']"
      },
      "flows": {
        "search": [
          "Goto '/search'",
          "See searchField",
          "Type in searchField 'simflow'",
          "See searchButton",
          "Click searchButton",
          "Wait page { to: 'reload' }",
          "Save screenshot as 'search-results.png'",
          "Save page as 'search-results.html'"
        ]
      }
    } 
  • Run search flow from example-gh-simflow.json config file:

    simflow search -c ./example-gh-simflow.json
    

Config

This is under heavy development and structure may changes.

Key Type Description
url string Required. Base URL. New page opens this URL. Defined path (i.e., Goto /path) in steps section uses this base URL.
references object List of references to be used in steps of a flow.
flows objects Required. Flow names mapped to array of steps. Named flows are passed to simflow as args.

Step

Step is a string with grammar defined in a PEG file lib/step.pegjs.

Some example of steps:

// Use reference.
Click namedSelector
Click namedSelector@frameName

// Use literal string for selector.
Click '.header h1'@'frameName'

Type into namedSelector "hello world"

Press 'Enter'

// Step arguments.
Press 'Enter' { delay: 1000 }
Save screenshot as './screenshots/filename.png' { fullPage: true }
Save page as './pages/index.pdf' { output: 'pdf' }

simflow's People

Contributors

gedex avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

simflow's Issues

Remember thing

Proposed step definition:

"steps": {
  "Remember text in selectorName as variableName", // store variableName as reference
  "See selectorName(variableName)" // assert reference later with dynamic selector (#7)
}

Support dynamic selector and XPath selector

By dynamic, it allows us to define named selector which accepts arguments and replaced with dynamic value during running-flow.

Proposed solution for XPath support

"frames": {
  "sidebar": "sidebarFrame__.*"
},
"selectors": {
  "selectorName": {
    "type": "xpath", // default to "css".
    "selector": "//button[text()=\"Submit\"]"
  }
}

and use it in steps as usual:

"steps": [
  "See selectorName", 
  "See selectorName@sidebar", // With frame
  "Click selectorName"
]

Proposed solution for dynamic selector

"frames": {
  "sidebar": "sidebarFrame__.*"
},
"selectors": {
  "selectorName1": "#posts-list $1[@title='$2']", // default to "css".
  "selectorName2": {
    "type": "xpath",
    "selector": "//button[text()=\"$1\"]"
  }
},

and use it in steps:

"steps": [
  "See selectorName1('a.title', 'title to pass')]", 
  "See selectorName1@sidebar('a.title', 'title to pass')", // With frame
  "Click selectorName2('Submit')"
]

Allow to check text in selector in a step definition

Proposed step:

"See selectorName with text equal to blabla", // use `===` (trimmed on input)
"See selectorName with text like blabla", // use `.match()`
"See selectorName with text includes blabla", // use `.includes()`
"Click selectorName with text like blabla", 

Add frames in config

This would allow looking for selectors in frames other than main frame.

Proposed frames config:

frames: {
  "frameName": "regex pattern"
}

Specifying selector in specific iframe inside steps:

"steps": [
  "See button@frameName",
]

if no @frameName it defaults to main frame.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.