Coder Social home page Coder Social logo

selenium's Introduction

Selenium Testing made easy on Laravel 5.

StyleCI Latest Stable Version Total Downloads Latest Unstable Version License composer.lock

Requirements:

  1. Java should be installed on local machine.
  2. You should have at least basic understanding of phpunit.

Installation guide:

First get the package on your laravel instance

composer require modelizer/selenium "~0.1"

Set configuration to your .env file.

APP_URL="http://example.dev/"   # If not set in .env file then http://localhost will be use as default

Register Service provider in app.php

Modelizer\Selenium\SeleniumServiceProvider::class 

Start Selenium Server

php artisan selenium:start

Start Testing

  1. Create a dummy SeleniumExampleTest.php file in tests directory.
  2. Add this code to SeleniumExampleTest.php file and run phpunit vendor/bin/phpunit tests/SeleniumExampleTest.php
<?php

use Modelizer\Selenium\SeleniumTestCase;

class SeleniumExampleTest extends SeleniumTestCase
{
    /**
     * A basic functional test example.
     *
     * @return void
     */
    public function testBasicExample()
    {
        // This is a sample code you can change as per your current scenario
        $this->visit('/')
             ->see('Laravel')
             ->hold(3);
    }
    
    /**
     * A basic submission test example.
     *
     * @return void
     */
    public function testLoginFormExample()
    {
        $loginInput = [
            'username' => 'dummy-name',
            'password' => 'dummy-password'
        ];
    
        // Login form test case scenario
        $this->visit('/login')
             ->submitForm($loginInput, '#login-form')
             ->see('Welcome');  // Expected Result
    }
}

Notes:

  1. Not all APIs in Laracasts Package is integrated in this package, but soon will be.
  2. Mac and windows support is available.
  3. Currently only support chrome browser.
  4. Selenium 2.53.1 and ChromeDriver 2.24 is been used.
  5. Feel free to contribute or create an issue.
  6. The user will not be able to swap between PHPUnit and Selenium who are below Laravel 5.3.

Roadmap:

  1. Firefox support needs to be added.
  2. Windows and Linux support needs to be added.
  3. Few APIs like in Integrated package such as press, wait and much more need to be added.
  4. Drivers file and selenium standalone package need to be compressed.
  5. API Docs need to be created.

Summary:

Many APIs such as see, wait, submitForm etc are been implemented in Laravel 5.3, and the whole goal of this package is to make it easier for the user to swap testing type anytime. Eg: If a user wants to test by selenium then he only need to extend Modelizer\Selenium\SeleniumTestCase in his test case or if he wants to do PHPUnit testing then he will be able to do it by extending TestCase which Laravel 5.3 provide by default. This will help the user to test a case in many different testing types without doing any changes with API.

Inspired by Integrated Package and credit goes to:

  1. Jeffery Way for teaching us.
  2. Mohammed Mudasir
  3. John Hoopes

selenium's People

Contributors

jhoopes avatar modelizer avatar

Watchers

 avatar  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.