browsersteps

package module
v0.0.0-...-8b233fa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

BrowserSteps

Build Status

This package provides Cucumber steps for Browser automation.

Installation

go get github.com/monde/browsersteps

Usage

  1. Create cucumber features in your project's /features folder.
  2. Use this repository example/example_tests.go file as main_test.go in your project.
  3. Execute Selenium Server.
  4. Run godog or go test.

Testing (this project/module)

Examples assumes local Selenium server is running and chromedriver is installed your milage may vary.

OSX brew installation.

  • brew install selenium-server-standalone
  • brew install chromedriver

Run Selenium in one shell.

$ selenium-server -port 4444

Run the tests in another shell.

$ SELENIUM_URL="http://127.0.0.1:4444/wd/hub" go test -v

Acknowledgements

History

The monde/browsersteps package is cleaned up for go modules. It is a fork of tjipbv/jumba-browsersteps which is a fork of llonchj/browsersteps.

Documentation

Overview

Package browsersteps provides browser automation Cucumber Steps using https://github.com/cucumber/godog and https://github.com/tebeka/selenium.

Provided Steps

The following steps are provided:

I am an anonymous user

This step deletes all cookies from the browser

Index

Constants

View Source
const ByOption = `(id|xpath|link text|partial link text|name|tag name|class name|css selector)`

ByOption is the regular expression for allowed selenium.By* in step definitions

Variables

This section is empty.

Functions

This section is empty.

Types

type BrowserSteps

type BrowserSteps struct {
	Capabilities   selenium.Capabilities
	DefaultURL     string
	URL            *url.URL
	ScreenshotPath string
	// contains filtered or unexported fields
}

BrowserSteps represents a WebDriver context to run the Scenarios

func NewBrowserSteps

func NewBrowserSteps(ctx *godog.ScenarioContext, cap selenium.Capabilities, defaultURL string) *BrowserSteps

NewBrowserSteps starts a new BrowserSteps instance.

func (*BrowserSteps) AfterScenario

func (b *BrowserSteps) AfterScenario(sc *messages.Pickle, err error)

AfterScenario is executed after each scenario

func (*BrowserSteps) BeforeScenario

func (b *BrowserSteps) BeforeScenario(sc *messages.Pickle)

BeforeScenario is executed before each scenario

func (*BrowserSteps) GetCurrentWindowInnerSize

func (b *BrowserSteps) GetCurrentWindowInnerSize() (*selenium.Size, error)

GetCurrentWindowInnerSize returns window inner size

func (*BrowserSteps) GetCurrentWindowScroll

func (b *BrowserSteps) GetCurrentWindowScroll() (*selenium.Point, error)

GetCurrentWindowScroll returns window scroll

func (*BrowserSteps) GetCurrentWindowViewport

func (b *BrowserSteps) GetCurrentWindowViewport() (image.Rectangle, error)

GetCurrentWindowViewport returns window scroll

func (*BrowserSteps) GetElementRect

func (b *BrowserSteps) GetElementRect(element selenium.WebElement) (image.Rectangle, error)

GetElementRect returns the element rectangle

func (*BrowserSteps) GetURL

func (b *BrowserSteps) GetURL(URL string) (*url.URL, error)

GetURL returns a absolute url given a absolute or relative URL

func (*BrowserSteps) GetWebDriver

func (b *BrowserSteps) GetWebDriver() selenium.WebDriver

GetWebDriver returns the webdriver

func (*BrowserSteps) SetBaseURL

func (b *BrowserSteps) SetBaseURL(url *url.URL) error

SetBaseURL sets the absolute URL used to complete relative URLs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL