selenose Documentation

Similar documents
django-selenium Documentation

django-jenkins Documentation

But before understanding the Selenium WebDriver concept, we need to know about the Selenium first.

gocept.selenium Release 3.0

SELENIUM TRAINING COURSE CONTENT

webtest-selenium Documentation

Selenium. Duration: 50 hrs. Introduction to Automation. o Automating web application. o Automation challenges. o Automation life cycle

Class 1 Introduction to Selenium, Software Test Life Cycle.

Selenium Training. Training Topics

Django MFA Documentation

Selenium Course Content

Chrome if I want to. What that should do, is have my specifications run against four different instances of Chrome, in parallel.

SELENIUM. Courses Offered. Ph: / Course Coverage:- Date:..Timings.. Duration Fees. Testing Tools QTP Load Runner Hadoop

WebDriver: Controlling your Web Browser

SELENIUM. SELENIUM COMPONENTS Selenium IDE Selenium RC Selenium Web Driver Selenium Grid

Selenium Webdriver Github

Graphene Documentation

Configure Eclipse with Selenium Webdriver

Web scraping and social media scraping handling JS

The age of automation is going to be the age of 'do it yourself. - Marshall McLuhan

Selenium Testing Course Content

Building a Django Twilio Programmable Chat Application

Selenium with Java Syllabus

Django Standalone Apps

@AfterMethod

Selenium Online Training Brochure

django-embed-video Documentation

django-embed-video Documentation

g-pypi Documentation Release 0.3 Domen Kožar

Selenium IDE. Steve Kwon, Raphael Huang, Amad Hussain, Mubasil Shamim

STQA Mini Project No. 2

django-cron Documentation

Relevancy Workbench Module. 1.0 Documentation

TESTING WEB SERVICES WITH WEBDRIVER AND QUICKCHECK

Release Clearcode < and associates (see AUTHORS)

Java Programming Basics

Getting Started with Appium

CSE 101 Introduction to Computers Development / Tutorial / Lab Environment Setup

behave-webdriver Documentation

Learning Objectives of CP-SAT v 1.3

Instructor s Notes Web Data Management Web Client/Server Concepts. Web Data Management Web Client/Server Concepts

ActiveNET Enterprise Solution Company

Gargoyle Documentation

EXPERT TRAINING PROGRAM [Selenium 2.0 / WebDriver]

Mind Q Systems Private Limited

Getting Django Set Up Using a Functional Test

Learning Objectives of CP-SAT v 1.31

django-sticky-uploads Documentation

django-dajax Documentation

Selenium Testing web applications

Tangent MicroServices Documentation

Automated Security Scanning in Payment Industry

C# 2013 Express Web WebDriver Automation. Introduction tutorial

django simple pagination Documentation

django-embed-video Documentation

Signals Documentation

What is the Selendroid?

Django Wordpress API Documentation

Lotus IT Hub. Module-1: Python Foundation (Mandatory)

django-messages Documentation

webdriver selenium 08FE064A22BF82F5A04B63153DCF68BB Webdriver Selenium 1 / 6

Koenig Solutions Pvt. Ltd. Selenium with C#

Django File Picker Documentation

Scraping Sites that Don t Want to be Scraped/ Scraping Sites that Use Search Forms

Django-frontend-notification Documentation

turbo-hipster Documentation

This is one of the common interview questions in any Automation testing job.

Installing SeisComP3

(Complete Package) We are ready to serve Latest Testing Trends, Are you ready to learn? New Batches Info

Topic 16: Validation. CITS3403 Agile Web Development. Express, Angular and Node, Chapter 11

SELENIUM - REMOTE CONTROL

Data Management CS 4720 Mobile Application Development

(Complete Package) We are ready to serve Latest Testing Trends, Are you ready to learn? New Batches Info

Open Source Test Automation: Riding the Second Wave

Setting Up the Development Environment

Signicat Connector for Java Version 2.6. Document version 3

Package wdman. January 23, 2017

Golem Documentation. Luciano Puccio

django-allauth-2fa Documentation

Toolium Documentation

*** Any Query *** Mail : 1. Introduction to Selenium. What is Selenium? Different automations tools. Selenium Automation Tools

django-precise-bbcode Documentation

Solar Plant Data Acquisition Maintenance

End-to-End Test and Build

The Chrome or Firefox browsers are alternatives to Internet Explorer 11.

JSN ImageShow Configuration Manual Introduction

Django File Picker Documentation

Flask-Testing Documentation

Garment Documentation

webdriverplus Release 0.1

Approach to development in OTM projects

MIT AITI Python Software Development Lab DJ1:

ganetimgr Documentation

CHICAGO. How to Tackle Open Source Test Automation in Incredible Ways. Renaissance Hotel 1 West Wacker Drive Chicago IL April 18th April 22th

Tomasz Szumlak WFiIS AGH 23/10/2017, Kraków

alphafilter Documentation

POM Documentation. Release Sergei Chipiga

Plumeria Documentation

1. Go to the URL Click on JDK download option

Learning Objectives of CP-SAT v 1.31 (C#)

Transcription:

selenose Documentation Release 1.3 ShiningPanda October 20, 2014

Contents 1 Installation 3 2 Nose 5 2.1 Selenium Server Plugin......................................... 5 2.2 Selenium Driver Plugin......................................... 6 2.3 Combining Server & Driver....................................... 8 3 Django Jenkins 9 3.1 Selenium Server Task.......................................... 9 3.2 Selenium Driver Task.......................................... 10 3.3 Combining Server & Driver....................................... 11 4 Tips 13 i

ii

Selenose provides a set of Selenium related plugins/tasks for nose/django-jenkins developed by ShiningPanda. The use of these plugins/tasks is detailed bellow, but let s have a look on the installation process first. Contents 1

2 Contents

CHAPTER 1 Installation On most UNIX-like systems, you ll probably need to run these commands as root or using sudo. Install selenose using setuptools/distribute: $ easy_install selenose Or pip: $ pip install selenose It can take a while as Selenium server s jar is downloaded on the fly during installation. If you plan to use django-jenkins, note that Django 1.4+ is required (support for in-browser testing frameworks). 3

4 Chapter 1. Installation

CHAPTER 2 Nose Selenose provides two Selenium related plugins for nose: Selenium Server Plugin starts a Selenium Server before running tests, and stops it at the end of the tests. Selenium Driver Plugin provides a Selenium Web Driver to the tests. 2.1 Selenium Server Plugin This plugin starts a Selenium Server before running tests, and stops it at the end of the tests. To enable it, add --with-selenium-server to the nose command line: $ nose --with-selenium-server You can also add the with-selenium-server option under the nosetests section of the configuration file (setup.cfg, ~/.noserc or ~/nose.cfg): [nosetests] with-selenium-server = true Options for Selenium Server can be found by downloading its jar and typing: $ java -jar /path/to/seleniumserver/libs/selenium-server-standalone-x.x.x.jar -h Most common options are: -port <nnnn>: the port number the Selenium Server should use (default 4444), -log <logfilename>: writes lots of debug information out to a log file, -debug: enable debug mode. To set the server options, add a selenium-server section to the configuration file (setup.cfg, ~/.noserc or ~/nose.cfg). Option names are obtained by removing the initial dash, for instance to run: $ java -jar selenium-server-standalone-x.x.x.jar -debug -log selenium-server.log Add the following options to the configuration: [selenium-server] debug = true log = selenium-server.log In your test, just create a new Remote Web Driver calling the server and that s it: 5

import nose import unittest from selenium import webdriver class TestCase(unittest.TestCase): def test(self): driver = webdriver.remote(desired_capabilities=webdriver.desiredcapabilities.firefox) try: driver.get( http://www.google.com ) # Your test here... finally: driver.quit() if name == main : nose.main() 2.2 Selenium Driver Plugin This plugin provides a Selenium Web Driver to Selenium tests. 2.2.1 Flag Selenium tests This plugin only provides Web Drivers to Selenium test. To declare a Selenium test: Either make your test case inherit from selenose.cases.seleniumtestcase, Or set a enable_selenium_driver flag to True: class TestCase(unittest.TestCase): enable_selenium_driver = True 2.2.2 Enable the plugin To enable this plugin, add --with-selenium-driver on the nose command line: $ nose --with-selenium-driver You can also add the with-selenium-driver option under the nosetests section to the configuration file (setup.cfg, ~/.noserc or ~/nose.cfg): [nosetests] with-selenium-driver = true But enabling it is not enough, a Web Driver environment is also required. 2.2.3 Web Driver environment An environment declares all the necessary parameters to create a new Web Driver. To create a new environment sample, add a selenium-driver:sample section to the configuration file (setup.cfg, ~/.noserc or ~/nose.cfg) with at least a webdriver option: 6 Chapter 2. Nose

[selenium-driver:sample] webdriver = firefox This webdriver option defines the Web Driver to use. Here are the available values: chrome for Chrome, allowing the following options in configuration: executable_path (optional): path to chromedriver executable, port (optional), desired_capabilities (optional), firefox for Firefox, allowing the following options in configuration: timeout (optional), ie for Internet Explorer, allowing the following options in configuration: port (optional), timeout (optional), remote to delegate to a Selenium Server (started by Selenium Server Plugin?), allowing the following options in configura command_executor (required): url of the server (http://127.0.0.1:4444/wd/hub by default), desired_capabilities (required): the desired browser, it could be the lower case field name of selenium.webdriver.desiredcapabilities such as firefox, htmlunitwithjs... or a comma separated key/value list such as browsername=firefox,platform=any. To enable an environment, add --selenium-driver on the nose command line: $ nose --with-selenium-driver --selenium-driver=sample You can also add the selenium-driver option under the nosetests section to the configuration file (setup.cfg, ~/.noserc or ~/nose.cfg): [nosetests] with-selenium-driver = true selenium-driver = sample [selenium-driver:sample] webdriver = firefox Selenose also provides a set of predefined but overridable environments: [selenium-driver:chrome] webdriver = chrome [selenium-driver:ie] webdriver = ie [selenium-driver:firefox] webdriver = firefox [selenium-driver:remote-htmlunit] webdriver = remote desired_capabilities = htmlunit [selenium-driver:remote-htmlunitwithjs] 2.2. Selenium Driver Plugin 7

webdriver = remote desired_capabilities = htmlunitwithjs [selenium-driver:remote-opera] webdriver = remote desired_capabilities = opera [selenium-driver:remote-...] webdriver = remote desired_capabilities =... 2.2.4 Writing tests The Web Driver is directly available with self.driver and there is no need to cleanup after use, selenose will do it for you: import nose from selenose.cases import SeleniumTestCase class TestCase(SeleniumTestCase): def test(self): self.driver.get( http://www.google.com ) # Your test here... if name == main : nose.main() 2.3 Combining Server & Driver To combine a Selenium Server and a Selenium Driver plugin, just enable them both: the command_executor option of the remote Web Driver will know the correct value to reach the Selenium Server. 8 Chapter 2. Nose

CHAPTER 3 Django Jenkins Selenose provides two Selenium related tasks for django-jenkins: Selenium Server Task starts a Selenium Server before running tests, and stops it at the end of the tests. Selenium Driver Task provides a Selenium Web Driver to the tests. Note that Django 1.4+ support for in-browser testing frameworks is required. 3.1 Selenium Server Task This task starts a Selenium Server before running tests, and stops it at the end of the tests. To enable it, edit your settings.py and append selenose.tasks.selenium_server to JENKINS_TASKS: JENKINS_TASKS = [ # Other tasks... selenose.tasks.selenium_server, ] If this setting does not exist yet, do not forget to create it with the default tasks: JENKINS_TASKS = [ django_jenkins.tasks.run_pylint, django_jenkins.tasks.with_coverage, django_jenkins.tasks.django_tests, selenose.tasks.selenium_server, ] Options for Selenium Server are the same than for the nose Selenium Server Plugin. Set them in a setup.cfg located in the current working directory, for instance: [selenium-server] debug = true log = selenium-server.log You can also specify the path to the configuration file with the --selenose-config option on the manage.py jenkins command line: $ python manage.py jenkins --help [...] selenose.tasks.selenium_server: --selenose-config=selenose_configs 9

Load selenose configuration from config file(s). May be specified multiple times; in that case, all config files will be loaded and combined. In your tests, just create a new Remote Web Driver calling the server and that s it: from django.test import LiveServerTestCase from selenium import webdriver class TestCase(LiveServerTestCase): @classmethod def setupclass(cls): cls.driver = webdriver.remote(desired_capabilities=webdriver.desiredcapabilities.firefox) super(basetestcase, cls).setupclass() @classmethod def teardownclass(cls): super(basetestcase, cls).teardownclass() cls.driver.quit() def test(self): driver.get(self.live_server_url) 3.2 Selenium Driver Task This task provides a Selenium Web Driver to Selenium tests. To enable it, edit your settings.py and append selenose.tasks.selenium_driver to JENKINS_TASKS: JENKINS_TASKS = [ # Other tasks... selenose.tasks.selenium_server, ] If this setting does not exist yet, do not forget to create it with the default tasks: JENKINS_TASKS = [ django_jenkins.tasks.run_pylint, django_jenkins.tasks.with_coverage, django_jenkins.tasks.django_tests, selenose.tasks.selenium_driver, ] But enabling this task is not enough, a Web Driver environment is also required. The Web Driver environment are defined in a setup.cfg located in the current working directory, for instance: [selenium-driver:sample] webdriver = firefox You can also specify the path to the configuration file containing the environments with the --selenose-config option on the manage.py jenkins command line: $ python manage.py jenkins --help [...] 10 Chapter 3. Django Jenkins

selenose.tasks.selenium_driver: --selenose-config=selenose_configs Load selenose configuration from config file(s). May be specified multiple times; in that case, all config files will be loaded and combined. --selenium-driver=selenium_driver Enable the provided environment. To enable an environment, use the --selenium-driver option on the manage.py jenkins command line: $ python manage.py jenkins --selenium-driver=sample Then the Web Driver is directly available in you tests with self.driver and there is no need to cleanup after use, selenose will do it for you: from selenose.cases import LiveServerTestCase class TestCase(LiveServerTestCase): def test(self): self.driver.get(self.live_server_url) # Your test here... 3.3 Combining Server & Driver To combine a Selenium Server and a Selenium Driver task, just enable them both in the settings: the command_executor option of the remote Web Driver will know the correct value to reach the Selenium Server. JENKINS_TASKS = [ # Other tasks... selenose.tasks.selenium_server, selenose.tasks.selenium_driver, ] 3.3. Combining Server & Driver 11

12 Chapter 3. Django Jenkins

CHAPTER 4 Tips When writing tests, it s convenient to start a Selenium Server manually to reduce setup time when running tests. To do so, execute: $ selenium-server Starting... done! Quit the server with CONTROL-C. Then type CONTROL-C or CTRL-BREAK to stop the server. In this case, run your tests neither with the Selenium Server Plugin not with the Selenium Server Task. 13