Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automation in Go Lang - How to use browser automation like Selenium?

I am new to Go lang. And I am looking for automating signup, login processes in a web app. Please suggest a good tool like Selenium and how can I implement it in go language.

I want to do the following process automatically using Go Lang:

  1. Start a browser. Currently, I'm using https://github.com/skratchdot/open-golang
  2. Auto entry in signup page and auto submit a form.
  3. Login check for the registered user. Everything needs to be done automatically for more users.
like image 721
gopinath Avatar asked Jan 11 '16 05:01

gopinath


2 Answers

If you are going to use GO for web automation testing - Selenium is a good option. Still it's nothing more than a library that allows you to interact with browsers. So you are going to need to develop your own framework or reuse someone already implemented.

My advice is to consider Agouti, since it supports Ginkgo BDD and xUnit Gomega. Everything else is pretty much the same from architectural perspective. You can design it like any other language binding. There are common patterns that appear over and over again in browser automation frameworks, like

  • PageObjects: A simple abstraction of the UI of your web app.
  • LoadableComponent: Modeling PageObjects as components.
  • BotStyleTests: command-based approach

Another good resource for building your Test framework is the xunitpatterns guide. It gives a great content overview of the patterns, smells and refactoring strategies you can use. Also look at this test frameworks tutorial. It'll help you choose the most proper solution for your case.

My guess is that you are going to need some CI server support for

everything needs to be done auto for more users.

Here is a good article how-to achieve this with TravisCI.

like image 92
ekostadinov Avatar answered Oct 11 '22 18:10

ekostadinov


You can also use Playwright for Go, which is a wrapper for the Playwright project. Playwright provides a single API to automate Chromium, Firefox, and WebKit to automate browsers which was created by Microsoft. With it you interact with the sites, record videos, make screenshots, and emulate other browser specific behaviour.

like image 31
Max Schmitt Avatar answered Oct 11 '22 18:10

Max Schmitt