Gaia UI Tests Introduction

  • Revision slug: Mozilla/Firefox_OS/Platform/Testing/gaia-ui-tests
  • Revision title: Gaia UI Tests Guidelines
  • Revision id: 390123
  • Created:
  • Creator: ypwalter
  • Is current revision? No
  • Comment

Revision Content

This page has not yet finished. Your feed back to gaia-ui-automation@mozilla.org would be greatly appreciated.

Introduction

    Gaiatest is a Python package based on Marionette, which is designed specifically for writing tests against Gaia. It's like a mobile phone version of Selenium Webdriver in python version. Basically, it's using python to communicate with device/emulator, and it would execute javascript inside device/emulator

    The main repository is currently in github: Mozilla/gaia-ui-tests. Due to Taiwan's local test needs, we also have another repository synchronized with main repository: Mozilla-TWQA/gaia-ui-tests.

 

Installation

Basic Information

    Gaia UI tests will utilize marionette client to communicate with marionette server on device/emulator. We will elaborate about the different ways to install different components for gaia-ui-tests later. There are two different ways to install gaia-ui-tests depending on your needs.

Route 1 - for test executor
    If you only want to run the tests without developing anything, just the command below in command line. It should

easy_install gaiatest

Route 2 - for developers (suggested option)
    If you anticipate in modifying gaiatest, you can do this instead:

git clone git://github.com/mozilla/gaia-ui-tests.git

    If you do not want to install gaiatest and dependencies into system's site-packages, follow the Virtual Environment Setup section's steps below. Or, you can just setup gaiatest by the following command:

cd gaia-ui-tests
python setup.py develop

    Please do notice that there are different branches in gaia-ui-tests. Choose the branch best describe your current B2G status. For example, if you wish to do the test on desktop version B2G, you might want to switch branch to desktop branch.

    If you have no further plan on modifying marionette client or marionette server code, you can skip the rest of this section and virtual environment setup section to "Running Tests" section.

    However, if you wish to take control over marionette client or marionette server. You will need to install most-up-to date marionette client  or matching marionette client version since gaia-ui-tests is using marionette client to communicate  between marionette server inside device/emulator.

    You can either download marionette from marionette client official distribution website or marionette client would come with your B2G code from github after excuted "config.sh". After that, you can find marionette clientside code at {B2G HOME DIRECTORY}/gecko/testing/marionette/client) You can find marionette serverside code at {B2G HOME DIRECTORY}/gecko/testing/marionette/. Please notice that you must config you B2G as an engineer build, or you will fail to find these codes.

Virtual Environment Setup

    The virtualenv can let you install gaiatest and all package dependencies into the virtual environment without affecting your system's site-packages. You could find the tutorial on virtualenv official website, or you can reference the tutorial down below:

    First of all, get the virtualenv installed in Ubuntu:

sudo apt-get install python-virtualenv

Creating and Activating
    Then create your virtual environment for Python and activate it:

virtualenv <ENV_NAME>
source <ENV_NAME>/bin/activate
    After activating the virtual environment, the prompt will looks like this:
(<ENV_NAME>)user@host:~$  

    You can creating more than one virtual environment for your purpose.

Setup the gaiatest
    Usually, you just only need to follow the steps to install dependencies for gaiatest into virtual environment.

cd gaia-ui-tests
python setup.py develop
Deactivating
    When you want to leave current virtual environment, input the command to deactivate it:
deactivate

Go back to "Table of Contents"

Running Tests

    Basically, we can run gaia-ui-tests on a device with marionette server, emulators, and desktop B2G. However, please notice again that you should choose the right branch of gaia-ui-tests describing your B2G the best as we talked on previous section.

Testing on Devices

 

Testing on Emulator

Automatically launched emulator

 

Mannually launched emulator

 

Testing on Desktop B2G

 

 

Test Types

 

Test Variables

 

Test Data Prerequisites

 

How to Contribute

Get Github Account

 

Fork It and Clone It

 

Branch Out

 

Solve Issues

 

Send Pull Requests

 

Writing Tests

Tests Guidelines

 

Test Examples

 

Functions Reference

 

Formatting

 

Debugging

 

CSS and XPath Locators

 

Revision Source

<p><em><strong><span style="background-color:#ffff00;">This page has not yet finished. Your feed back to gaia-ui-automation@mozilla.org would be greatly appreciated.</span></strong></em></p>
<h2 id="Introduction">Introduction</h2>
<p>&nbsp;&nbsp;&nbsp; Gaiatest is a Python package based on <a href="https://developer.mozilla.org/en-US/docs/Marionette" title="https://developer.mozilla.org/en-US/docs/Marionette">Marionette</a>, which is designed specifically for writing tests against <a href="https://github.com/mozilla-b2g/gaia" title="https://github.com/mozilla-b2g/gaia">Gaia</a>. It's like a mobile phone version of <a href="http://docs.seleniumhq.org/projects/webdriver/" title="http://docs.seleniumhq.org/projects/webdriver/">Selenium Webdriver</a> in python version. Basically, it's using python to communicate with device/emulator, and it would execute javascript inside device/emulator</p>
<p>&nbsp;&nbsp;&nbsp; The main repository is currently in github:<a href="https://github.com/mozilla/gaia-ui-tests" title="https://github.com/mozilla/gaia-ui-tests"> Mozilla/gaia-ui-tests</a>. Due to Taiwan's local test needs, we also have another repository synchronized with main repository: <a href="https://github.com/Mozilla-TWQA/gaia-ui-tests" title="/Mozilla-TWQA/gaia-ui-tests">Mozilla-TWQA/gaia-ui-tests</a>.</p>
<p>&nbsp;</p>
<h2 id="Installation">Installation</h2>
<h3 id="Basic_information">Basic Information</h3>
<p>&nbsp;&nbsp;&nbsp; Gaia UI tests will utilize marionette client to communicate with marionette server on device/emulator. We will elaborate about the different ways to install different components for gaia-ui-tests later. There are two different ways to install gaia-ui-tests depending on your needs.</p>
<p><strong>Route 1 - for test executor</strong><br />
  &nbsp;&nbsp;&nbsp; If you only want to run the tests without developing anything, just the command below in command line. It should</p>
<pre>
<code>easy_install gaiatest
</code></pre>
<p><strong>Route 2 - for developers (suggested option)</strong><br />
  &nbsp;&nbsp;&nbsp; If you anticipate in modifying gaiatest, you can do this instead:</p>
<pre>
<code>git clone git://github.com/mozilla/gaia-ui-tests.git
</code></pre>
<p>&nbsp;&nbsp;&nbsp; If you do not want to install gaiatest and dependencies into system's site-packages, follow the <a href="#Virtual_Environment_Setup" title="#Virtual_Environment_Setup"><strong>Virtual Environment Setup</strong></a> section's steps below. Or, you can just setup gaiatest by the following command:</p>
<pre style="font-size: 14px;">
<code style="font-size: 14px;">cd gaia-ui-tests
python setup.py develop</code></pre>
<p>&nbsp;&nbsp;&nbsp; Please do notice that there are different branches in gaia-ui-tests. Choose the branch best describe your current B2G status. For example, if you wish to do the test on desktop version B2G, you might want to switch branch to desktop branch.<br />
  <br />
  &nbsp;&nbsp;&nbsp;<strong> <span style="background-color:#ffff00;">If you have no further plan on modifying marionette client or marionette server code, you can skip the rest of this section and virtual environment setup section to <a href="#Running_Tests" title="#Running_Tests">"Running Tests" section</a>.</span></strong></p>
<p>&nbsp;&nbsp;&nbsp; However, if you wish to take control over marionette client or marionette server. You will need to install most-up-to date <a href="https://pypi.python.org/pypi/marionette_client/" title="https://pypi.python.org/pypi/marionette_client/">marionette client</a>&nbsp; or matching marionette client version since gaia-ui-tests is using marionette client to communicate&nbsp; between marionette server inside device/emulator.<br />
  <br />
  &nbsp;&nbsp;&nbsp; You can either download marionette from <a href="https://pypi.python.org/pypi/marionette_client/" title="https://pypi.python.org/pypi/marionette_client/">marionette client official distribution website</a> or marionette client would come with your<a href="https://github.com/mozilla-b2g/B2G" title="https://github.com/mozilla-b2g/B2G"> B2G code from github</a> after excuted "config.sh". After that, you can find marionette clientside code at {B2G HOME DIRECTORY}/gecko/testing/marionette/client) You can find marionette serverside code at {B2G HOME DIRECTORY}/gecko/testing/marionette/. Please notice that you must config you B2G as an engineer build, or you will fail to find these codes.</p>
<h3>Virtual Environment Setup</h3>
<p>&nbsp;&nbsp;&nbsp; The virtualenv can let you install gaiatest and all package dependencies into the virtual environment without affecting your system's site-packages.&nbsp;You could find the tutorial on <a href="https://pypi.python.org/pypi/virtualenv" title="https://pypi.python.org/pypi/virtualenv">virtualenv official website</a>, or you can reference the tutorial down below:</p>
<p>&nbsp;&nbsp;&nbsp; First of all, get the virtualenv installed in Ubuntu:</p>
<pre style="font-size: 14px;">
sudo apt-get install python-virtualenv</pre>
<p><strong>Creating and Activating</strong><br />
  &nbsp;&nbsp;&nbsp; Then create your virtual environment for Python&nbsp;and activate it:</p>
<pre style="font-size: 14px;">
virtualenv &lt;ENV_NAME&gt;
source &lt;ENV_NAME&gt;/bin/activate</pre>
<div>
  &nbsp; &nbsp; After activating the virtual environment, the prompt will looks like this:</div>
<div>
  <pre style="font-size: 14px;">
(&lt;ENV_NAME&gt;)user@host:~$ &nbsp;</pre>
  <p>&nbsp; &nbsp; You can creating more than one virtual environment for your&nbsp;purpose.<br />
    <br />
    <strong>Setup the gaiatest</strong><br />
    <span style="line-height: 1.572;">&nbsp;&nbsp;&nbsp; Usually, you just only need to follow the steps to install&nbsp;</span><span style="line-height: 1.572;">dependencies for gaiatest into virtual environment.</span></p>
  <pre style="font-size: 14px;">
cd gaia-ui-tests
python setup.py develop</pre>
  <strong>Deactivating</strong><br />
  <div>
    &nbsp; &nbsp; When you want to leave current virtual environment, input&nbsp;the command to deactivate it:</div>
  <div>
    <pre style="font-size: 14px;">
deactivate</pre>
  </div>
</div>
<p style="text-align: center;">Go back to <a href="#Introduction" title="#Introduction">"Table of Contents"</a></p>
<h2 id="Running_Tests">Running Tests</h2>
<p>&nbsp;&nbsp;&nbsp; Basically, we can run gaia-ui-tests on a device with marionette server, emulators, and desktop B2G. However, please notice again that you should choose the right branch of gaia-ui-tests describing your B2G the best as we talked on previous section.</p>
<h3 id="Testing_on_a_device">Testing on Devices</h3>
<p>&nbsp;</p>
<h3 id="Testing_on_emulator">Testing on Emulator</h3>
<p><strong>Automatically launched emulator</strong></p>
<p>&nbsp;</p>
<p><strong>Mannually launched emulator</strong></p>
<p>&nbsp;</p>
<h3 id="Testing_on_desktop_B2G">Testing on Desktop B2G</h3>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2 id="Test_Types">Test Types</h2>
<p>&nbsp;</p>
<h2 id="Test_Variables">Test Variables</h2>
<p>&nbsp;</p>
<h2 id="Test_Data_Prerequisites">Test Data Prerequisites</h2>
<p>&nbsp;</p>
<h2 id="How_to_Contribute">How to Contribute</h2>
<h3 id="Get_your_github_account">Get Github Account</h3>
<p>&nbsp;</p>
<h3 id="Fork_it_and_clone_it">Fork It and Clone It</h3>
<p>&nbsp;</p>
<h3 id="Branch_out">Branch Out</h3>
<p>&nbsp;</p>
<h3>Solve Issues</h3>
<p>&nbsp;</p>
<h3>Send Pull Requests</h3>
<p>&nbsp;</p>
<h2 id="Writing_Tests">Writing Tests</h2>
<h3 id="Test_guidelines_and_examples">Tests Guidelines</h3>
<p>&nbsp;</p>
<h3>Test Examples</h3>
<p>&nbsp;</p>
<h3 id="Functions_reference">Functions Reference</h3>
<p>&nbsp;</p>
<h3 id="Formatting">Formatting</h3>
<p>&nbsp;</p>
<h3 id="Debugging">Debugging</h3>
<p>&nbsp;</p>
<h3 id="CSS_Locators_and_XPath_Locators_Resources">CSS and XPath Locators</h3>
<p>&nbsp;</p>
Revert to this revision