From bf44ab6a957ae132bc3f42e2965ed2e714dcd57f Mon Sep 17 00:00:00 2001 From: Kevin RAMAGE Date: Fri, 6 Mar 2020 16:13:48 +0100 Subject: [PATCH 1/3] Add gecko web driver --- context/webctx/context.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/context/webctx/context.go b/context/webctx/context.go index 5f071bda..8b83dfca 100644 --- a/context/webctx/context.go +++ b/context/webctx/context.go @@ -16,7 +16,7 @@ const Name = "web" const ( Width = "width" Height = "height" - Driver = "driver" + Driver = "driver" // Possible values: chrome, phantomjs, gecko Args = "args" Timeout = "timeout" Debug = "debug" @@ -64,6 +64,8 @@ func (tcc *WebTestCaseContext) Init() error { "args": args, }, })) + case "gecko": + tcc.wd = agouti.GeckoDriver() default: tcc.wd = agouti.PhantomJS() } From 384107157082542bde5ce801fe0a3b285ebf6de7 Mon Sep 17 00:00:00 2001 From: Kevin RAMAGE Date: Sat, 7 Mar 2020 18:34:19 +0100 Subject: [PATCH 2/3] Add new feature to upload file --- executors/web/types.go | 10 ++++++++++ executors/web/web.go | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/executors/web/types.go b/executors/web/types.go index 9eb796b9..c5c5044d 100644 --- a/executors/web/types.go +++ b/executors/web/types.go @@ -7,6 +7,7 @@ type Action struct { Find string `yaml:"find,omitempty"` Navigate *Navigate `yaml:"navigate,omitempty"` Wait int64 `yaml:"wait,omitempty"` + UploadFile *UploadFile `yaml:"uploadFile,omitempty"` } // Fill represents informations needed to fill input/textarea @@ -16,12 +17,21 @@ type Fill struct { Key *string `yaml:"key,omitempty"` } +// Click represents informations needed to click on web components type Click struct { Find string `yaml:"find,omitempty"` Wait int64 `yaml:"wait"` } +// Navigate represents informations needed to navigate on defined url type Navigate struct { Url string `yaml:"url,omitempty"` Reset bool `yaml:"reset,omitempty"` } + +// UploadFile represents informations needed to upload files +type UploadFile struct { + Find string `yaml:"find,omitempty"` + Files []string `yaml:"files,omitempty"` + Wait int64 `yaml:"wait,omitempty"` +} \ No newline at end of file diff --git a/executors/web/web.go b/executors/web/web.go index bf9185c5..c95417b8 100644 --- a/executors/web/web.go +++ b/executors/web/web.go @@ -110,6 +110,21 @@ func (Executor) Run(testCaseContext venom.TestCaseContext, l venom.Logger, step } } else if e.Action.Wait != 0 { time.Sleep(time.Duration(e.Action.Wait) * time.Second) + + // Upload files + } else if e.Action.UploadFile != nil { + s, err := find(ctx.Page, e.Action.UploadFile.Find, r) + if err != nil { + return nil, err + } + for _, f := range e.Action.UploadFile.Files { + if err := s.UploadFile(f); err != nil { + return nil, err + } + } + if e.Action.UploadFile.Wait != 0 { + time.Sleep(time.Duration(e.Action.UploadFile.Wait) * time.Second) + } } // take a screenshot From 09374d1b7521b226b81f2e36d259202b86161d15 Mon Sep 17 00:00:00 2001 From: Kevin RAMAGE Date: Sun, 15 Mar 2020 23:16:07 +0100 Subject: [PATCH 3/3] Add documentation and example --- executors/web/README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/executors/web/README.md b/executors/web/README.md index 40852ea1..44dcf3b7 100644 --- a/executors/web/README.md +++ b/executors/web/README.md @@ -46,6 +46,32 @@ testcases: ``` +Upload file actiow allow you to upload file with file input web component +Example: + +```yaml +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" +``` + ## Output * result.url