Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
A good tool for testing is the ability to be part of Selenium-Grid allows the Selenium RC solution to scale for large test
suites and for test suites that must be run in multiple environments.
automation and its capabilities to enhance the testing
performance. This paper will explain on how Selenium tool III. PYTESTFRAMEWORK
will accelerate the test execution process and cut the cost of In this section, we will focus on details how we use the framework [3] that
the whole test execution process. In this paper, we will we developed by ourselves by combining all the selenium models and provide
emphasize test as early as possible with less cost and the focus the additional following features.
should be against integration which is the main ingredients in
agile. Automated testing can be made to be cost-effective, 1. consolidates all selenium 2.0 python test case and run them using a
however, if some common sense is applied to the process. nosetests against a configurable parameters
o Browsers type – IE and Firefox and Chrome etc
Keywords-component: Agile Testing, functional testing, o Selenium Hub Server
automation script, Selenium, cost-effective. o Selenium Hub Server Port
o Base URL
I. INTRODUCTION – AGILE TESTING o Test Report filename in Junit xml format
2. Running all test cases in parallel per browser using nosetests
Agile testing is a software testing practice that follows the principles of multiprocessing feature. *Note there is a work in progress to fix
agile software development [1]. Agile testing involves testing from the running test cases in parallel regardless of browser type, as of now
customer perspective as early as possible, testing early and often as code the implementation is - test cases will run in parallel for one type
becomes available and stable enough, since working increments of the of browser first i.e. Firefox before moving to the next browser type
software are released often in agile software development. This is commonly or version.
done by using automated script to accelerate the test execution process and 3. Provide a Junit xml report.
cut the cost of the whole test execution process.
217
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
import unittest 1-Launch Jenkins and Click at “New Job”.Choose a free-style software
#You need to import functionR.py file as at least setUp function is project option.
located there. 2- Fill in the the Job name. In this example PythonTestFramework1.0-
import function Example is specified in the field.
3- Click on OK button.
#Specify Your pre-Test Case title as part of the class
class GoogleSearchJohnLennon(unittest.TestCase):
def setUp(self):
functionR.setUp(self) #This is where setUP function from function.py
is called.
def test_google_search_john_lennon(self):
driver = self.driver
driver.get("http://www.google.com.my/")
driver.find_element_by_id("lst-ib").clear()
driver.find_element_by_id("lst-ib").send_keys("John Lennon") Figure4. Step 4 and 5
driver.find_element_by_css_selector("#imagebox_bigimages > h3.r >
a > em").click() 4-If you need to run on a specific Jenkins node here is (in "Restrict
where this project can be run") where you specify the node name/IP
5- Depending on your source code management, you need to specify you
def is_element_present(self, how, what): code’s location ,in my case I am using subversion.
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException, e: return False
return True
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
#Test Case completed#
if __name__ == "__main__":
unittest.main()
Figure2. An example of test cases
4- Runx.py
This is the runner that initiates a nosetests module to run against the available
test cases in the current folder and generate a test reports. There report will be Figure5. Step 6, 7, 8
generated against per browser type in Junit xml forma
6- I also want it to be run periodically, in this example "Build periodically" is
B. Integrate with Continous Integration server ticked and add it to run everyday once at 0005
7. At Build->Execute Shell or in windows environment you may be able to
choose Build->Execute Windows command.
In our environment, we tend to integrate with Continuous Integration tool i.e.
Jenkins so it can be set to be auto run continuously in an effort to test
integration as early as possible with less cost [4]. You need to execute the run script - Runx.py
Example:
`python Runx.py`
8-Finally, for test report, "Publish Junit test result report" is ticked and
specifies the related xml file .In my case below I want all report in .xml
format to be displayed in Jenkins. The important thing which is important in
agile is the report is accessible to everyone hence give a transparent result and
management should have a same amount of information against others.
218
Generate Code Library (“driver”)
Python NA
support
Generate Code Library (“driver”)
Ruby NA
support
Testing Frameworks
Selenium Selenium
Framework Selenium RC
IDE Core
Comes
Manipulate browser,
with
Bromine check assertions via NA
template to
custom driver
add to IDE
Out-of-the- Manipulate browser,
JUnit box code check assertions via NA
generation Java driver
Out-of-the- Manipulate browser,
NUnit box code check assertions via NA
generation .NET driver
Out-of-the- Manipulate browser,
RSpec (Ruby) box code check assertions via NA
Figure6. Example of Test Report generation Ruby driver
Out-of-the- Manipulate browser,
Test::Unit(Ruby) box code check assertions via NA
generation Ruby driver
Out-of-the- Manipulate browser,
IV. TESTING SUPPORTED TestNG (Java) box code check assertions via NA
generation Java driver
Browsers Out-of-the- Manipulate browser,
Browser Selenium IDE Selenium RC Selenium Core unittest (Python) box code check assertions via NA
Record & Start browser, run generation Python driver
Firefox 3 Run tests
Playback Tests tests
Record & Start browser, run
Firefox 2 Run tests V.
Playback Tests tests CONCLUSIONS
Start browser, run We have no doubts about the positive effect of automated testing. It is
IE 8 Not supported Run tests
tests clear to us that creating a good and comprehensive automated test with
Start browser, run integration of good testing tool are a demanding time-consuming process. It is
IE 7 Not supported Run tests
tests cost effective when you need to perform a certain amount of testing in limited
Start browser, run time but with automate testing tools, the time wastage can be reduce. The
Safari 3 Not supported Run tests evolution of automate tools from code-based record/playback to data-driven
tests
Start browser, run and key/action word frameworks reflects the realization that the less code there
Safari 2 Not supported Run tests is to be developed and maintained the more efficient and effective test
tests
Start browser, run automation becomes[5].
Opera 9 Not supported Run tests
tests
REFERENCES
Start browser, run
Opera 8 Not supported Run tests [1] Michael Bolton,”Rapid Software Testing”,Agile Conference ,Berlin
tests
,Germany, March ,2010.
Programming Languages [2] http://seleniumhq.org/docs/01_introducing_selenium.html
Language Selenium IDE Selenium RC Selenium Core [3] https://github.com/fairul82/PythonTestFramework1.0/wiki
Library (“driver”) [4] Titus Brown,”Agile Development and Testing in
C# Generate Code NA
support Python”,PythonConference Addison,Texas,2006.
Generate Code Library (“driver”)
Java NA [5] Titus Brown ,Grig Gheorghiu, “Practical Applications of Agile Web
support
Testing Tools”,Python Conference Chicago,2008.
Generate Code Library (“driver”)
Perl NA
support
Generate Code Library (“driver”)
PHP NA
support
219