Giter Site home page Giter Site logo

maui's Introduction

MAUI

maui is a wrapper framework for Selenium Webdriver with the aim of providing an easier way of automating and executing tests. The key features that maui offers are: Modularization and Element Type definition, as well as an automated retry mechanism for interacting with elements.

Quick Start

check out the demo projects that are using maui:

Features:

PageObjects Definition

To define a page object you must annotate your page class with a human readable name and a relative url, and add the elements that are found on the page

...
import org.testmonkeys.maui.pageobjects.AbstractPage;
import org.testmonkeys.maui.pageobjects.ElementAccessor;
import org.testmonkeys.maui.pageobjects.PageAccessor;
import org.testmonkeys.maui.pageobjects.elements.Button;
import org.testmonkeys.maui.pageobjects.elements.Input;

@Getter
@PageAccessor(name = "Landing Page", url = "/")
public class LandingPage extends AbstractPage {

    @ElementAccessor(elementName = "Submit button", byXPath = "//div[@id='submitDiv']//button")
    private Button submit;
    
    @ElementAccessor(elementName = "Username", byId = "username")
    private Input username;
...

The types available to use are:

  • Button
  • CheckBox
  • Hyperlink
  • Input
  • Label
  • RadioButton
  • Select

And you can define your custom elements to extend the list or alter the interaction.

Retrieving the instance of a Page Object in your tests:

To get the instance of the page object you need to first initialize the Browser and PageFactory:

WebDriver driver = new ChromeDriver();
Browser browser= new Browser(driver, TimeUnit.SECONDS, 10, 20);
PageFactory pageFactory=new PageFactory(browser, new PageScanner("com.yourProject.pageObjects.package"),"https://yourTestedSiteHere.com");

after intialisation you can retrieve the pageOjbect objects either by class name or by their name defined in the page accessor:

LandingPage page= pageFactory.createPage(LandingPage.class);

or

LandingPage page= pageFactory.createPage("Landing Page");

Opening the page in the browser

To open a specific page in the browser you can use the open method, defined in the AbstractPage class, it will take the web site's url from page factory, add the relative url defined for the page and open that in browser:

page.open();

Interacting with page elements

The web elements have methods for the interactions that are possible with their type and can be used directly:

page.getUsername().type("admin");
loginPage.getSubmit().click();

Defining modules

If you have a set of elements that you want to group, either because they are repeated on multiple pages, or they are part of a list you can define them as a custom module:

public class MessageRow extends AbstractModule {

    @ElementAccessor(elementName = "Email", byXPath = ".//div[1]/p")
    private Label email;

    @ElementAccessor(elementName = "Subject", byXPath = ".//div[2]/p")
    private Label subject;

    public void click() {
        new ClickAction(subject).execute();
    }

}

Working with Lists of elements

To define web element lists use GroupComponent<> class in your pageObject, annotate it with a standard @ElementAccessor, setting the locator that would find the elements in the list. This can be used with both web element components like inputs, labels or with custom defined modules:

@PageAccessor(name = "Messages Page", url = "/messages")
public class MessagesPage extends AbstractPage {

    @ElementAccessor(elementName = "Messages", byXPath = "//div[@class='messages']//div[contains(@class,'row detail')]")
    private GroupComponent<MessageRow> messageList;

and in your tests you can get all the elements:

List<MessageRow> messageElements= page.getMessageList().getAll();

Compatibilities

maui is compatible with any java framework, and gives access to the underlying WebElement objects, it was also tested with BrowserStack

BrowserStack

maui's People

Contributors

costea32 avatar monofrei avatar dependabot[bot] avatar steti93 avatar

Stargazers

Dumitru Chicu avatar promt bvb avatar mni avatar

Watchers

James Cloos avatar  avatar  avatar Mariia avatar mni avatar promt bvb avatar

maui's Issues

Refactor Group Component into Module

Since Group Component is a collection of Abstract Components - it does not fit into the Abstract Component. as it doesn't have an underlying WebElement. Thus needs to be separated from Abstract Component.

Old chromedriver used

Due to chromedriver version hardcoding in the circle ci yaml, the old version of the chromedriver is used against latest version of chrome, thus resulting in test failures.

Implement scenario environment

A scenario may require to have multiple browser instance and for this a centralized environment manager/handler is required

Add multi site support

Add the support for multiple sites within one project.

  1. Set the base url per site
  2. Add 'site' property per page object
  3. Add multi-tab support

Throw exception when trying to use functionality not supported by browser

In situations where the browser doesn't support some functionality, a special Exception should be thrown to inform the automator that this is a browser issue. And save precious time.

Example: Headless browsers usually don't support pop-up alerts - in this case, if a test is trying to access the alerts - a special error should be thrown.

GenericActions implementation

As part of the framework, a generic set of actions should be implemented that work based on element and page names. This will allow generic steps implementation for different frameworks.

Usage Examples

There should be usage examples using the most popular testing frameworks

JBehave platform usage example

Create module to show platform usage using jBehave.

Should contain generic steps and show how framework can search pages and elements by page object element name.

Enhance GroupComponent to be able to handle directly Elements

Instead of having GroupItem that wraps an element, to use in GroupComponent - we need to enchance GroupdComponent to be able to handle directly elements.

To do this - locator needs to be updated so that it contains an index, used in searches from lists.

Element Attributes

Provide possibility to get attributes and their values from an element.

Add getAttribute value for element

To avoid overloading abstract component with functionality - getAttribute method can be declared on HtmlElement as it suits that context better. currently you can get all attributes from an element, but using the native selenium method should be faster

Dynamic wait times external configuration

Configuration for waits should be done in an external property file, most useful would be to hold this properties in the same file that configures browser, as most probably this will be browser specific.

new properties to add:
browser.wait.page.load
browser.wait.popup.load
browser.wait.page.element.load

Add missing state methods to Component

Add:

  • isDisplayed
  • isEnabled
  • isClickable
  • isSelectable
    Must be implemented using fluent wait with corresponding Expected Conditions
    Add possibility, using lambda, to inject custom predicate at project level.

Cucumber platform usage example

Create module to show platform usage using cucumber-jvm.

Should contain generic steps and show how framework can search pages and elements by page object element name.

Element outerHTML

provide means to get and set outerHTML for an element. Although in experimental, it seems to be supported by all browsers.

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.