-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91bb2c6
commit c643d46
Showing
11 changed files
with
500 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*.MD | ||
README2.MD | ||
/*.html | ||
bin | ||
twist | ||
twist | ||
twist2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,257 @@ | ||
# Twist (Simple UI testing tool) | ||
|
||
<img align="right" width="209px" src="./logo/twistLogo.png"> | ||
|
||
Twist is a simple UI testing CLI tool written in Go (Golang). 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. (I built this tool to test my personal projects. Use it in your own cautious) | ||
|
||
This tool is not like selenium or its alternatives, it's less advanced (has only two assertions!). It is built over [chromedp](https://github.com/chromedp/chromedp) which built over DevTools Protocol (can not test firefox). | ||
|
||
## Contents | ||
|
||
- [Twist](#twist-simple-ui-testing-tool) | ||
- [Contents](#contents) | ||
- [Installation](#installation) | ||
- [Quick start](#quick-start) | ||
- [The Structure](#the-structure) | ||
- [Config file options](#config-file-options) | ||
- [execute](#execute) | ||
- [timeout](#timeout) | ||
- [output](#output) | ||
- [order](#order) | ||
- [Story file options](#story-file-options) | ||
- [start](#start) | ||
- [timeout](#timeout) | ||
- [headless](#headless) | ||
- [instructions](#instructions) | ||
- [instructions](#instructions) | ||
- [assertions](#assertions) | ||
|
||
## Installation | ||
|
||
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) | ||
|
||
1. The first need [Go](https://golang.org/) installed (**version 1.13+ is required**), then you can use the below Go command to install Twist. | ||
|
||
```sh | ||
$ git clone https://github.com/youssefsiam38/twist.git | ||
``` | ||
|
||
2. make it available everywhere in your machine: | ||
|
||
```sh | ||
$ cd twist | ||
$ go install | ||
``` | ||
|
||
## Quick start | ||
|
||
```sh | ||
# this will make a twist folder for you in the current directory with config file and stories folder with the initial values | ||
$ twist init | ||
``` | ||
```sh | ||
$ twist | ||
``` | ||
|
||
## The Structure | ||
|
||
The tool read from two types of yml files and writes only to the `twist/report`. 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 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 | ||
|
||
## Config file options | ||
|
||
### execute | ||
|
||
```yaml | ||
execute: in order # in parallel support will be added soon | ||
``` | ||
### timeout | ||
```yaml | ||
timeout: 30m # the timeout of the context of all stories | ||
``` | ||
### output | ||
```yaml | ||
output: stdout # file reporting will be added soon | ||
``` | ||
### order | ||
```yaml | ||
# 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 | ||
``` | ||
## Story file options | ||
### start | ||
```yaml | ||
start: https://youssefsiam.me # the url that the story will begin from | ||
``` | ||
### timeout | ||
```yaml | ||
timeout: 2m # the timeout of the this specific story | ||
``` | ||
### headless | ||
```yaml | ||
headless: false # choose the mode of the user story test (default: false) | ||
``` | ||
### instructions | ||
```yaml | ||
# The list of instructions and assertions in order | ||
instructions: | ||
- waitFor: | ||
selector: "#about" | ||
- click: "#about" | ||
- asserPathIs: /about | ||
``` | ||
## instructions | ||
### **click** | ||
```yaml | ||
instructions: | ||
- click: | ||
selector: "#about" | ||
``` | ||
or, since *selector* is the only paramater | ||
```yaml | ||
instructions: | ||
- click: "#about" | ||
``` | ||
### **doubleClick** | ||
```yaml | ||
instructions: | ||
- doubleClick: | ||
selector: "#home" | ||
``` | ||
or | ||
```yaml | ||
instructions: | ||
- doubleClick: "#home" | ||
``` | ||
### **rightClick** | ||
```yaml | ||
instructions: | ||
- rightClick: | ||
selector: "#home" | ||
``` | ||
or | ||
```yaml | ||
instructions: | ||
- rightClick: "#home" | ||
``` | ||
### **navigate** | ||
```yaml | ||
instructions: | ||
- navigate: "https://youssefsiam.me" | ||
- assertPathIs: "https://youssefsiam.me/" | ||
``` | ||
### **refresh** | ||
```yaml | ||
instructions: | ||
- do: "refresh" | ||
``` | ||
### **saveScreenshotTo** | ||
```yaml | ||
instructions: | ||
# give it the name of the file that you like to save to in the twist/report folder | ||
- saveScreenshotTo: about | ||
``` | ||
### **submit** | ||
```yaml | ||
instructions: | ||
- submit: | ||
selector: "#home" | ||
``` | ||
or | ||
```yaml | ||
instructions: | ||
- submit: "#home" | ||
``` | ||
### **type** | ||
```yaml | ||
instructions: | ||
- type: | ||
selector: "input[type=\"email\"]" | ||
text: [email protected] | ||
- submit: "input[type=\"email\"]" | ||
``` | ||
### **waitFor** | ||
```yaml | ||
instructions: | ||
- waitFor: | ||
selector: "#about" | ||
``` | ||
or, since *selector* is the only paramater | ||
```yaml | ||
instructions: | ||
- waitFor: "#about" | ||
``` | ||
### **waitUntilMissing** | ||
```yaml | ||
instructions: | ||
- waitUntilMissing: | ||
selector: "#about" | ||
``` | ||
or, since *selector* is the only paramater | ||
```yaml | ||
instructions: | ||
- waitUntilMissing: "#about" | ||
``` | ||
## assertions | ||
### **assertPathIs** | ||
```yaml | ||
instructions: | ||
- assertPathis: | ||
name: "Blog home page assertion" | ||
expect: "https://youssefsiam.me" | ||
``` | ||
or | ||
```yaml | ||
instructions: | ||
- assertPathis: "https://youssefsiam.me" | ||
``` | ||
this way the assertion name will be assertPathIs | ||
### **assertText** | ||
```yaml | ||
instructions: | ||
- assertText: | ||
name: "The text is `about` assertion" | ||
expect: "about" | ||
selector: "button#about" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var authorCmd = &cobra.Command{ | ||
Use: "author", | ||
Short: "Prints the author name", | ||
// Long: ``, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Println("© Youssef Siam (https://github.com/youssefsiam38)") | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/youssefsiam38/twist/src/utils" | ||
) | ||
|
||
var initCmd = &cobra.Command{ | ||
Use: "init", | ||
Short: "Creates the twist folder with the defaults", | ||
Long: `Creates the twist folder with the default values for you`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if utils.FolderExist("twist") { | ||
fmt.Println("twist folder is already exist") | ||
} else { | ||
err := os.Mkdir("twist", 0755) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
err = os.Mkdir("twist/stories", 0755) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
configBuf := []byte("execute: in order # or in parallel, if in parallel no need to specify the order\ntimeout: 70m\noutput: stdout # or filename\norder: \n- blog") | ||
|
||
|
||
err = ioutil.WriteFile("twist/config.yml", configBuf, 0755) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
storyBuf := []byte(`execute: in order # or in parallel, if in parallel no need to specify the order | ||
timeout: 70m | ||
output: stdout # or filename | ||
order: | ||
- blog | ||
`) | ||
|
||
err = ioutil.WriteFile("twist/stories/blog.story.yml", storyBuf, 0755) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.