Twist is a simple UI testing CLI tool written in Go. Its main purpose is to help developers write simple and easy read & write YAML-based instructions and assertions to drive the browser in no time. (It still under development. Use it in your own cautious)
This tool is not like selenium or its alternatives, it's less advanced. It is built over chromedp which is built over DevTools Protocol (can not test firefox).
To install Twist package, you need to install Go and set your Go workspace first. (the compiled binaries will be added to this repo later)
- The first need Go installed (version 1.13+ is required), then you can use the below Go command to install Twist.
$ git clone https://github.com/youssefsiam38/twist.git
- make it available everywhere in your machine:
$ cd twist
$ go install
twist is available as downloadable binaries from the releases page.
# this will make a twist folder for you in the current directory with config file and stories folder with the initial values
$ twist init
$ twist
The tool reads from config.yml
and {your story name}.story.yml
then writes to the twist/report
(currently screenshots only). The twist/config.yml
file which you can provide configurations about the entire flow of the tests (e.g timeout of the flow and the order of the user stories in which twist should follow), and the twist/stories/{your story name}.story.yml
include configurations, instructions and assertions for each user story in your application
execute: in order # in parallel support will be added soon
timeout: 30m # the timeout of the context of all stories
output: stdout # file reporting will be added soon
# The order in which the tests will be executed, the name you put here is the first level extention of the file in the stories folder. e.g blog here will execute {blog}.story.yml
order:
- blog
- documentation
start: https://youssefsiam.me # the url that the story will begin from
timeout: 2m # the timeout of the this specific story
headless: false # choose the mode of the user story test (default: false)
# The list of instructions and assertions in order
instructions:
- waitFor:
selector: "#about"
- click: "#about"
- asserPathIs: /about
instructions:
- click:
selector: "#about"
or, since selector is the only paramater
instructions:
- click: "#about"
instructions:
- doubleClick:
selector: "#home"
or
instructions:
- doubleClick: "#home"
instructions:
- rightClick:
selector: "#home"
or
instructions:
- rightClick: "#home"
instructions:
- navigate: "https://youssefsiam.me"
- assertPathIs: "https://youssefsiam.me/"
instructions:
- do: "refresh"
instructions:
# give it the name of the file that you like to save to in the twist/report folder
- saveScreenshotTo: about
instructions:
- submit:
selector: "#home"
or
instructions:
- submit: "#home"
instructions:
- type:
selector: "input[type=\"email\"]"
text: [email protected]
- submit: "input[type=\"email\"]"
instructions:
- waitFor:
selector: "#about"
or, since selector is the only paramater
instructions:
- waitFor: "#about"
instructions:
- waitUntilMissing:
selector: "#about"
or, since selector is the only paramater
instructions:
- waitUntilMissing: "#about"
instructions:
- assertPathis:
name: "Blog home page assertion"
expect: "https://youssefsiam.me"
or
instructions:
- assertPathis: "https://youssefsiam.me"
this way the assertion name will be assertPathIs
instructions:
- assertText:
name: "The text is `about` assertion"
expect: "about"
selector: "button#about"