GithubHelp home page GithubHelp logo

kejkz / elemental Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 11 KB

Capybara based elements container object. Write tests or STFU

License: MIT License

Ruby 100.00%
automation capybara development ruby testing selenium ui pageobject-pattern

elemental's Introduction

Elemental

Introduction

Elemental gem is a simple wrapper around Capybara that gives you a straight-forward way to work with web page elements. Its main purpose is to make using page elements sharing easier between different tests and test suites, because feature tests can be quite complex and use an arrays of combinations of html accessors to drive to the proper test coverage. This gem just streamlines that task and gives you a way to define and reuse html elements. And you can add a method or two if you need to.

Installation

Just add elemental to your test section in bundle:

gem elemental

Usage

Just create a new object for your elements and start testing.

class MyElements < Elemental
  button :my_button1, '.my-button-class', text: 'My Button', match: :first
  field :my_field1, '#my_field'
  link :my_link1, '#my_link1', text: 'Some Text'
  element :my_element, '.my-selector'
  elements :my_shiny_elements, '.my-shiny-selector-2'
end

This gives you two new methods for each of these selectors:

my_elements = MyElements.new
my_elements.my_button1 # => 'My Button'
my_elements.my_button1_element # => Capybara::Node

Methods for creating an element take a name of the element as first parameter, and locator as second. You can also pass Capybara parameters as you would do in a test.

You can freely combine different element classes to create a complex object by using Ruby classes.

class MyComplexPage < Elemental
  def my_elements
    @my_element ||= MyElements.new
  end
end

elemental's People

Contributors

kejkz avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.