Modelizer/Selenium

View on GitHub
stubs/views/about.blade.php

Summary

Maintainability
A
0 mins
Test Coverage
<!DOCTYPE html>
<html>
<head>
    <title>Selenium Test HTML File</title>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <!-- Custom CSS -->
    <style>
        body {
            padding-top: 70px;
            /* Required padding for .navbar-fixed-top. Remove if using .navbar-static-top. Change if height of navigation changes. */
        }
    </style>
</head>
<body>
@include('partial.nav')

<!-- Page Content -->
<div class="container">

    <div class="row">
        <div class="col-lg-12 text-center">
            <h1>About this project</h1>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <article class="markdown-body entry-content" itemprop="text">

                <p><a href="https://styleci.io/repos/57591685"><img src="https://camo.githubusercontent.com/12735d51a61e5485ec005eb9a18455f576ec1340/68747470733a2f2f7374796c6563692e696f2f7265706f732f35373539313638352f736869656c64" alt="StyleCI" data-canonical-src="https://styleci.io/repos/57591685/shield" style="max-width:100%;"></a>
                    <a href="https://packagist.org/packages/modelizer/selenium?format=flat-square"><img src="https://camo.githubusercontent.com/2f4de1042ba1893a5e49b446a575ea4172d6460b/68747470733a2f2f706f7365722e707567782e6f72672f6d6f64656c697a65722f73656c656e69756d2f762f737461626c65" alt="Latest Stable Version" data-canonical-src="https://poser.pugx.org/modelizer/selenium/v/stable" style="max-width:100%;"></a>
                    <a href="https://packagist.org/packages/modelizer/selenium?format=flat-square"><img src="https://camo.githubusercontent.com/26e0e1729b4c5211f490643ea8ce469073ee12fb/68747470733a2f2f706f7365722e707567782e6f72672f6d6f64656c697a65722f73656c656e69756d2f646f776e6c6f616473" alt="Total Downloads" data-canonical-src="https://poser.pugx.org/modelizer/selenium/downloads" style="max-width:100%;"></a>
                    <a href="https://packagist.org/packages/modelizer/selenium?format=flat-square"><img src="https://camo.githubusercontent.com/0b1f8160259e7dda45de38b8ecb8f1b2352d9ae1/68747470733a2f2f706f7365722e707567782e6f72672f6d6f64656c697a65722f73656c656e69756d2f762f756e737461626c65" alt="Latest Unstable Version" data-canonical-src="https://poser.pugx.org/modelizer/selenium/v/unstable" style="max-width:100%;"></a>
                    <a href="https://packagist.org/packages/modelizer/selenium?format=flat-square"><img src="https://camo.githubusercontent.com/75e49ae0495fea9f4b23e1dc0f418dbcfe5f8d22/68747470733a2f2f706f7365722e707567782e6f72672f6d6f64656c697a65722f73656c656e69756d2f6c6963656e7365" alt="License" data-canonical-src="https://poser.pugx.org/modelizer/selenium/license" style="max-width:100%;"></a>
                    <a href="https://packagist.org/packages/modelizer/selenium?format=flat-square"><img src="https://camo.githubusercontent.com/e7fdf27cc57b59217ced6f6b41a9f6f9f4a5cf2f/68747470733a2f2f706f7365722e707567782e6f72672f6d6f64656c697a65722f73656c656e69756d2f636f6d706f7365726c6f636b" alt="composer.lock" data-canonical-src="https://poser.pugx.org/modelizer/selenium/composerlock" style="max-width:100%;"></a></p>

                <p><a href="/Modelizer/Selenium/blob/master/images/laravel-plus-selenium.gif" target="_blank"><img src="/Modelizer/Selenium/raw/master/images/laravel-plus-selenium.gif" style="max-width:100%;"></a></p>

                <h2><a id="user-content-requirements" class="anchor" href="#requirements" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Requirements:</h2>

                <ol>
                    <li>Java should be installed on local machine.</li>
                    <li>You should have at least basic understanding of phpunit.</li>
                </ol>

                <h2><a id="user-content-installation-guide" class="anchor" href="#installation-guide" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Installation guide:</h2>

                <p>First get the package on your laravel instance</p>

                <div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">composer</span> <span class="pl-k">require</span> <span class="pl-c1">modelizer</span><span class="pl-k">/</span><span class="pl-c1">selenium</span> <span class="pl-s"><span class="pl-pds">"</span>~0.2<span class="pl-pds">"</span></span></span></pre></div>

                <p>Set configuration to your .env file.</p>

                <div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">APP_URL</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">"</span>http://example.dev/<span class="pl-pds">"</span></span>   <span class="pl-c"># If not set in .env file then http://localhost will be use as default</span></span>
<span class="pl-s1"><span class="pl-c1">SELENIUM_WIDTH</span><span class="pl-k">=</span><span class="pl-c1">1024</span> <span class="pl-c"># If not set in the .env file, the default window width will be used</span></span>
<span class="pl-s1"><span class="pl-c1">SELENIUM_HEIGHT</span><span class="pl-k">=</span><span class="pl-c1">768</span> <span class="pl-c"># If not set in the .env file, then the default window height will be used</span></span></pre></div>

                <p>Register Service provider in <code>app.php</code></p>

                <div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">Modelizer\Selenium\</span><span class="pl-c1">SeleniumServiceProvider</span><span class="pl-k">::</span><span class="pl-c1">class</span> </span></pre></div>

                <p>Start Selenium Server </p>

                <div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">php</span> <span class="pl-c1">artisan</span> <span class="pl-c1">selenium</span>:<span class="pl-c1">start</span></span></pre></div>

                <h2><a id="user-content-start-testing" class="anchor" href="#start-testing" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Start Testing</h2>

                <ol>
                    <li>Create a dummy <code>SeleniumExampleTest.php</code> file in <code>tests</code> directory.</li>
                    <li>Add this code to <code>SeleniumExampleTest.php</code> file and run phpunit <code>vendor/bin/phpunit tests/SeleniumExampleTest.php</code></li>
                </ol>

                <div class="highlight highlight-text-html-php"><pre><span class="pl-pse">&lt;?php</span><span class="pl-s1"></span>
<span class="pl-s1"></span>
<span class="pl-s1"><span class="pl-k">use</span> <span class="pl-c1">Modelizer\Selenium\SeleniumTestCase</span>;</span>
<span class="pl-s1"></span>
<span class="pl-s1"><span class="pl-k">class</span> <span class="pl-en">SeleniumExampleTest</span> <span class="pl-k">extends</span> <span class="pl-e">SeleniumTestCase</span></span>
<span class="pl-s1">{</span>
<span class="pl-s1">    <span class="pl-c">/**</span></span>
<span class="pl-s1"><span class="pl-c">     * A basic functional test example.</span></span>
<span class="pl-s1"><span class="pl-c">     *</span></span>
<span class="pl-s1"><span class="pl-c">     * <span class="pl-k">@return</span> void</span></span>
<span class="pl-s1"><span class="pl-c">     */</span></span>
<span class="pl-s1">    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">testBasicExample</span>()</span>
<span class="pl-s1">    {</span>
<span class="pl-s1">        <span class="pl-c">// This is a sample code you can change as per your current scenario</span></span>
<span class="pl-s1">        <span class="pl-smi">$this</span><span class="pl-k">-&gt;</span>visit(<span class="pl-s"><span class="pl-pds">'</span>/<span class="pl-pds">'</span></span>)</span>
<span class="pl-s1">             <span class="pl-k">-&gt;</span>see(<span class="pl-s"><span class="pl-pds">'</span>Laravel<span class="pl-pds">'</span></span>)</span>
<span class="pl-s1">             <span class="pl-k">-&gt;</span>hold(<span class="pl-c1">3</span>);</span>
<span class="pl-s1">    }</span>
<span class="pl-s1"></span>
<span class="pl-s1">    <span class="pl-c">/**</span></span>
<span class="pl-s1"><span class="pl-c">     * A basic submission test example.</span></span>
<span class="pl-s1"><span class="pl-c">     *</span></span>
<span class="pl-s1"><span class="pl-c">     * <span class="pl-k">@return</span> void</span></span>
<span class="pl-s1"><span class="pl-c">     */</span></span>
<span class="pl-s1">    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">testLoginFormExample</span>()</span>
<span class="pl-s1">    {</span>
<span class="pl-s1">        <span class="pl-smi">$loginInput</span> <span class="pl-k">=</span> [</span>
<span class="pl-s1">            <span class="pl-s"><span class="pl-pds">'</span>username<span class="pl-pds">'</span></span> <span class="pl-k">=&gt;</span> <span class="pl-s"><span class="pl-pds">'</span>dummy-name<span class="pl-pds">'</span></span>,</span>
<span class="pl-s1">            <span class="pl-s"><span class="pl-pds">'</span>password<span class="pl-pds">'</span></span> <span class="pl-k">=&gt;</span> <span class="pl-s"><span class="pl-pds">'</span>dummy-password<span class="pl-pds">'</span></span></span>
<span class="pl-s1">        ];</span>
<span class="pl-s1"></span>
<span class="pl-s1">        <span class="pl-c">// Login form test case scenario</span></span>
<span class="pl-s1">        <span class="pl-smi">$this</span><span class="pl-k">-&gt;</span>visit(<span class="pl-s"><span class="pl-pds">'</span>/login<span class="pl-pds">'</span></span>)</span>
<span class="pl-s1">             <span class="pl-k">-&gt;</span>submitForm(<span class="pl-smi">$loginInput</span>, <span class="pl-s"><span class="pl-pds">'</span>#login-form<span class="pl-pds">'</span></span>)</span>
<span class="pl-s1">             <span class="pl-k">-&gt;</span>see(<span class="pl-s"><span class="pl-pds">'</span>Welcome<span class="pl-pds">'</span></span>);  <span class="pl-c">// Expected Result</span></span>
<span class="pl-s1">    }</span>
<span class="pl-s1">}</span></pre></div>

                <h2><a id="user-content-api-added-in-02-release" class="anchor" href="#api-added-in-02-release" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Api Added in 0.2 release:</h2>

                <ol>
                    <li><code>scroll</code>, <code>notSee</code>, <code>seePageIs</code>, <code>type</code>, <code>typeInformation</code>, <code>press</code>, <code>click</code>, <code>findElement</code> and much more.</li>
                    <li>To know more about this API you can checkout <a href="https://github.com/laracasts/Integrated/wiki/Learn-the-API">Integrated Package API</a></li>
                    <li>Database related APIs is also available such as <code>seeInDatabae</code> and <code>missingFromDatabase</code>, <code>dontSeeInDatabase</code></li>
                    <li>Full API documentation will be available soon.</li>
                </ol>

                <h2><a id="user-content-notes" class="anchor" href="#notes" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Notes:</h2>

                <ol>
                    <li>Mac and windows support is available.</li>
                    <li>Currently only support chrome browser.</li>
                    <li>Selenium 2.53.1 and ChromeDriver 2.24 is been used.</li>
                    <li>Feel free to contribute or create an issue.</li>
                    <li>The user will not be able to swap between PHPUnit and Selenium who are below Laravel 5.3.</li>
                </ol>

                <h2><a id="user-content-roadmap" class="anchor" href="#roadmap" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Roadmap:</h2>

                <ol>
                    <li>Firefox support needs to be added.</li>
                    <li><del>Windows</del> and Linux support needs to be added.</li>
                    <li>Drivers file and selenium standalone package need to be compressed.</li>
                    <li>API Docs need to be created.</li>
                </ol>

                <h2><a id="user-content-summary" class="anchor" href="#summary" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Summary:</h2>

                <p>Many APIs such as <code>see</code>, <code>wait</code>, <code>submitForm</code> 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 <code>Modelizer\Selenium\SeleniumTestCase</code> in his test case or if he wants to do PHPUnit testing then he will be able to do it by extending <code>TestCase</code> 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.</p>
            </article>
            <p>Developed by:</p>
            <ul class="list-unstyled">
                <li>Mohammed Mudasir (https://github.com/Modelizer)</li>
                <li>John Hoopes (https://github.com/jhoopes)</li>
            </ul>
        </div>
    </div>
    <!-- /.row -->

</div>

<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>
</html>