Selenium: Remote Control
Selenium: Remote Control
Remote Control
y
eor
Th
sic
Ba
Selenium Versions
• Three different versions (that matter)
• IDE: Firefox extension
• Core: JavaScript library
• RC: Java Proxy (can run in chrome://)
Core IDE RC
Browsers All Firefox Many
! e
Requires server access Yes No No
on
ht
rig
Multi-domain No Yes Yes
e
th
se
HTTPS Yes Yes No
U
Test-Driven Development
• Dogmatic:
• Tests are written before the code
• Only code is written for which tests already exist
• Pragmatic:
• Test are written before or with the code
• Only most frequent cases being tested
• All bug-fixes are being tested
it!
o
D
it!
o
D
Selenium Remote Control
• Requirements:
• Java Server
• Properly installed Firefox
• Selenium Protocol handling (e.g. pear Testing_Selenium)
• Looks easy:
$selenium = new Testing_Selenium("*chrome", "http://liip.ch");
$selenium->start();
$selenium->open("/");
rs
ne
rt
$page_title = $selenium->getTitle();
pa
r
if ($page_title == ‘Liip AG’) { echo “YALLAH!\n”; }
fo
ok
Lo
SimpleTest
• “Classic” Unit testing
• HTTP Requests
• It’s easy:
class TestValidations extends UnitTestCase {
function testValidate() {
$this->assertIdentical(true, hlprs_validation::validate(‘email’, ‘[email protected]’);
}
}
e!
pl
sim
a,
,y
hm
U
Selenium RC & SimpleTest
• Nice duo:
• Control the browser, while simpletest is doing the assert
work
• Get nice reports
E!
IC
N
Common Stuff
Commands:
• getTitle • getText • isVisible
Locators:
• identifier • name • xpath • css
• id • dom • link
Suffixes:
RC
• •
in
AndWait WaitFor
ns
tio
•
nc
Not (deprecated with simpletest)
fu
e
or
C
all
ot
N
Bamboo
• Blame the build breaker
• Get nice statistics
• Locate errors, when needed (e.g. backend) components fail
!
ne
hi
ac
m
y
m
n
so
ild
Bu
Social
• It's NOT a waste of time
• It's not much extra work when you do it right away
• Manual testing is reduced to a minimum
• You know a bug really is fixed (and will remain fixed)
• But: requires some initial effort
• Get the team on board
• For the local.ch frontend a bug is only fixed when a test exists
• Show the value (“I found this bug because of Selenium”)
?t
ar
st
u
yo
ill
w
n
he
W
Links
• http://openqa.org
• http://simpletest.org
• http://release.openqa.org/selenium-core/0.8.0/reference.html
• http://developer.local.ch/php/selenium_class
f
uf
st
ol
co
e
m
nd
Se
Thanks to Patrice Neff
He made me believe in Unit Testing and lend me some slides :)
Visit http://blog.patrice.ch