Loading presentation...

Present Remotely

Send the link below via email or IM


Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.


Automated Testing With Selenium

Testing with Selenium locally and in Amazon EC2

Sasa Ivetic

on 10 January 2013

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Automated Testing With Selenium

Automated Testing
With Selenium Demonstration Installation (Python) Search Google for 'Protegra' Selenium 2 (WebDriver) vs Selenium 1 (RC) Development Environment Selenium IDE (FireFox Plugin) Visit blog for full installation details from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
q = driver.find_element_by_name('q')

q.send_keys(Keys.RETURN) Supported Browsers Internet Explorer, Chrome, FireFox, Opera, Android, iOS, HtmlUnit Simple Installation
- Python + pip (Python Installs Packages)
- Selenium
- Chromedriver (if Chrome capability desired) Locating Elements By ID HTML:
<div id="exampleId">...</div>

el = driver.find_element_by_id("exampleId") By Class Name HTML:
<div class="exampleClass">...</div>

els = driver.find_elements_by_class("exampleClass") By Name HTML:
<input name="firstName">...</div>

el = driver.find_element_by_name("firstName") By Link Text HTML:
<a href="http://protegra.com">Protegra</div>

el = driver.find_element_by_link_text("Protegra") By CSS HTML:
<div id="outer"><span class="inner">...</span></div>

el = driver.find_element_by_css_selector("#outer span.inner") By XPath HTML:
<li id="about"><a href="/about/">About</a></li>
<li id="support"><a href="/support/">Support</a></li>
<li id="contact"><a href="/documentation/">Contact</a></li>

els = driver.find_element_by_xpath("//ul/li[@id='about'/a") Language Bindings (C#, Java, Python, Ruby, etc.) Demo Click on first search result
on google.com Dealing With Delay-loaded Elements (AJAX) Implicit Waits driver = webdriver.Firefox()
driver.implicitly_wait(10) Explicit Waits def explicit_wait(driver, id):
wdw = WebDriverWait(driver, 10)
return wdw.until(lambda driver : driver.find_element_by_id(id))

driver = webdriver.Firefox()
el = explicit_wait(driver, 'element_id') Load Testing
With Selenium Not Designed For
Performance and
Load Testing! ...but necessary in some cases What Is Required? Selenium Server Threaded Controller VMs (Amazon EC2) Tip: Use Linux instead of Windows VMs for lightweight headless (no GUI) operation Selenium Server Uses RemoteDriver instead of WebDriver to send commands Communication via HTTP on specified port DEMO - Basic Search using Server driver = webdriver.Remote("http://localhost:8080/wd/hub",
webdriver.DesiredCapabilities.FIREFOX) Concurrent Controller Even easier with Python! Create the threads:

hosts = ['localhost:8080']
queries = ['Protegra', 'Winnipeg']

threads = [threading.Thread(target=run, args=[h, q]) for h in hosts for q in queries]

for t in threads:
for t in threads:
t.join() Thread run method:

def run(url, query):
url = str.format('http://{0}/wd/hub', host)
driver = webdriver.Remote(url, webdriver.DesiredCapabilities.FIREFOX)
.... EC2 Instances CPU:
m1.small (1 core/1 compute unit)
m3.double-xlarge (8 cores/3.25 compute units) Memory:
m1.small (1.7GB)
high memory quad-XL (68.4GB) High I/O:
high i/o (35 compute units, 60.5GB RAM, 2x1024 GB SSD-based local storage, 10Gbps Ethernet) Note: 1 compute unit is approximately equivalent to a 1.0-1.2GHz 2007 Opteron/2007 Xeon processor Amazon Machine Images
(AMIs) Save current state of machine and local data Suspend operation (avoid incurring run costs) Duplicate machine (spawn more instances) Note: Storage costs associated with storing AMIs Pricing On Demand Standard Small - $0.065/Hr Linux, $0.115/Hr Windows
CPU Extra Large - $0.660/Hr Linux, $1.140/Hr Windows
CPU Double XL - $1.160/Hr Linux, $1.960/Hr Windows
I/O Quad XL - $3.10/Hr Linux, $3.580/Windows Spot Instances (price fluctuates) Standard Small - $0.007/Hr Linux, $0.017/Hr Windows
CPU Extra Large - $0.07/Hr Linux, $0.20/Hr Windows
CPU Double XL - $0.115/Hr Linux, $0.275/Hr Windows
I/O Quad XL - Not Available
Full transcript