SlideShare a Scribd company logo
Controlling the browser through python and selenium
• Pat Viafore
•ADTRAN
•Past work at TOA Systems
•Python at home
• What is Selenium?
• How Do I Use It?
• Getting Information Off a Page
• Controlling Input
• Advanced Features
• Limitations
• Rejoicing
And what can it do for me?
Controlling the browser through python and selenium
• Allows scripts to take control of a web browser
• Supports multiple language bindings
• We’ll focus on Python today
• Windows/Linux/MacOS Support
• $> pip install selenium
• Licensed under Apache 2.0
• Easy to use
Selenium
Remote
Control
Selenium 2.0
Selenium IDE
Selenium
Grid
Selenium
Remote
Control
Selenium 2.0
Selenium IDE
Selenium
Grid
Controlling the browser through python and selenium
Controlling the browser through python and selenium
Controlling the browser through python and selenium
• I currently work on an internal web-app
• I use Selenium to drive acceptance tests – making sure
the web page operates as we expect it to
• Database interactions
• Error conditions
• External service tests (e-mail, LDAP, etc.)
• I use Python to “glue” web browser interaction with
system events
Controlling the browser through python and selenium
• We’re not just limited to acceptance tests
• Automate common tasks you use a web browser for
• Hook up Selenium to data feeds to control web pages
• Hulu
• Pandora
• YouTube
• Take care of things on a schedule
• Pay bills online
• Sign up for more Python Meetings 
Controlling the browser through python and selenium
Enough with the blah, blah, blah….Let’s Code!
Controlling the browser through python and selenium
Controlling the browser through python and selenium
Controlling the browser through python and selenium
Controlling the browser through python and selenium
Controlling the browser through python and selenium
Controlling the browser through python and selenium
• browser.find_element_by_css_selector
• browser.find_element_by_xpath
Because just getting things is boring
Controlling the browser through python and selenium
Controlling the browser through python and selenium
Controlling the browser through python and selenium
• Go to YouTube
• Search for Python programming
• Sort by Recent Date
• Click on a random video
Controlling the browser through python and selenium
Bring on the cool stuff
Controlling the browser through python and selenium
Controlling the browser through python and selenium
Controlling the browser through python and selenium
• Screenshotting
• Execute arbitrary Javascript code
• browser.execute_script(jsCode)
• Also an async version
• Browser Capabilities
• Proxying
• Navigate to Google Maps
• Move mouse to center of map
• Start scrolling north a bunch
• Move the mouse or press keys through chainable actions
• More options about ActionChains
http://selenium-python.readthedocs.org/en/latest/api.html
Controlling the browser through python and selenium
• We could use XVFB or something similar on certain
Linux distros
• Instead, we’ll use PhantomJS to create a headless
browser
• Separate JS installation
• We’ll create X threads that do a series of interactions and time
them
Controlling the browser through python and selenium
There is no such thing as a Silver Bullet
• Why Use Selenium?
• Why Not Mocha?
• Why Not Jasmine?
• Why Not GUI Recorders?
• RESTful Interactions
• Requests does a far better job
• User Interface (UI) testing
• Selenium does offer Location/Size/CSS, but you’ll
probably be rolling your own layer on top of Selenium
to handle UI testing
• Brittle UIs
• UIs change often (classes, ID changes, buttons
changes)
• Can mitigate by providing a wrapper around Selenium
to interact with your site – DRY (Don’t Repeat Yourself)
Principle
Pizza, pizza, pizza!
Controlling the browser through python and selenium
Controlling the browser through python and selenium

More Related Content

What's hot (20)

PDF
Selenium Testing on Chrome - Google DevFest Armenia 2015
Sargis Sargsyan
 
PDF
Automation Testing
RomSoft SRL
 
PPTX
Moving From a Selenium Grid to the Cloud - A Real Life Story
Sauce Labs
 
PPTX
Automated ui-testing
Slobodan Lohja
 
ODP
Mastering selenium for automated acceptance tests
Nick Belhomme
 
PPTX
QA Fest 2017. Александр Хотемской. Современные возможности в организации Prot...
QAFest
 
PPTX
Selenium
Satyam Pandey
 
PDF
APIs: A Better Alternative to Page Objects
Sauce Labs
 
PDF
Selenium WebDriver with C#
srivinayak
 
PDF
Basics of Selenium IDE,Core, Remote Control
usha kannappan
 
PDF
Selenoid: browsers in containers
Ivan Krutov
 
PPTX
Beyond the Release: CI That Transforms Organizations
Sauce Labs
 
PPTX
Smarter ways to do selenium automation @ work, Selenium, automation
RIA RUI Society
 
PPTX
Selenium
Andrew Krug
 
PPT
Selenium By Pravin Mishra
Pravin Mishra
 
PDF
Automatic Functional Testing with Selenium and SauceLabs
Joseph Chiang
 
PDF
Selenium IDE and Beyond
Samit Badle
 
KEY
Testing with Jenkins, Selenium and Continuous Deployment
Max Klymyshyn
 
DOCX
Selenium webdriver course content rakesh hansalia
Rakesh Hansalia
 
PDF
Selenium webdriver
sean_todd
 
Selenium Testing on Chrome - Google DevFest Armenia 2015
Sargis Sargsyan
 
Automation Testing
RomSoft SRL
 
Moving From a Selenium Grid to the Cloud - A Real Life Story
Sauce Labs
 
Automated ui-testing
Slobodan Lohja
 
Mastering selenium for automated acceptance tests
Nick Belhomme
 
QA Fest 2017. Александр Хотемской. Современные возможности в организации Prot...
QAFest
 
Selenium
Satyam Pandey
 
APIs: A Better Alternative to Page Objects
Sauce Labs
 
Selenium WebDriver with C#
srivinayak
 
Basics of Selenium IDE,Core, Remote Control
usha kannappan
 
Selenoid: browsers in containers
Ivan Krutov
 
Beyond the Release: CI That Transforms Organizations
Sauce Labs
 
Smarter ways to do selenium automation @ work, Selenium, automation
RIA RUI Society
 
Selenium
Andrew Krug
 
Selenium By Pravin Mishra
Pravin Mishra
 
Automatic Functional Testing with Selenium and SauceLabs
Joseph Chiang
 
Selenium IDE and Beyond
Samit Badle
 
Testing with Jenkins, Selenium and Continuous Deployment
Max Klymyshyn
 
Selenium webdriver course content rakesh hansalia
Rakesh Hansalia
 
Selenium webdriver
sean_todd
 

Similar to Controlling the browser through python and selenium (20)

PDF
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
PPT
Selenium
conect2krish
 
PPTX
automation with python and selenium
Manish Kumar
 
PPTX
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
irpycon
 
DOC
Selenium Automation Using Ruby
Kumari Warsha Goel
 
PDF
Selenium documentation 1.0
Bharath Marrivada
 
PDF
Selenium for pythonistas
Santiago Suarez Ordoñez
 
PPTX
Python selenium
Ducat
 
PPTX
One to rule them all
Antonio Robres Turon
 
PPTX
Selenium Basics and Overview topics.pptx
sountharyaravi010
 
PPTX
Selenium Basics and Overview1233444.pptx
sountharyaravi010
 
PPTX
Lesson2-Selenium installation 2-6-25.pptx
131881omarfernandez1
 
PPT
Selenium Basics by Quontra Solutions
QUONTRASOLUTIONS
 
PPTX
Selenium- A Software Testing Tool
Zeba Tahseen
 
PDF
Introduction to Selenium Webdriver - SpringPeople
SpringPeople
 
PPT
QSpiders - Automation using Selenium
Qspiders - Software Testing Training Institute
 
PPT
Intro Of Selenium
Kai Feng Zhang
 
PPTX
Selenium.pptx
Pandiya Rajan
 
PPTX
Open Source Automation Tools That Really Work V2
An Doan
 
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
Selenium
conect2krish
 
automation with python and selenium
Manish Kumar
 
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
irpycon
 
Selenium Automation Using Ruby
Kumari Warsha Goel
 
Selenium documentation 1.0
Bharath Marrivada
 
Selenium for pythonistas
Santiago Suarez Ordoñez
 
Python selenium
Ducat
 
One to rule them all
Antonio Robres Turon
 
Selenium Basics and Overview topics.pptx
sountharyaravi010
 
Selenium Basics and Overview1233444.pptx
sountharyaravi010
 
Lesson2-Selenium installation 2-6-25.pptx
131881omarfernandez1
 
Selenium Basics by Quontra Solutions
QUONTRASOLUTIONS
 
Selenium- A Software Testing Tool
Zeba Tahseen
 
Introduction to Selenium Webdriver - SpringPeople
SpringPeople
 
QSpiders - Automation using Selenium
Qspiders - Software Testing Training Institute
 
Intro Of Selenium
Kai Feng Zhang
 
Selenium.pptx
Pandiya Rajan
 
Open Source Automation Tools That Really Work V2
An Doan
 
Ad

More from Patrick Viafore (13)

PPTX
Extensible Python: Robustness through Addition - PyCon 2024
Patrick Viafore
 
PDF
User-Defined Types.pdf
Patrick Viafore
 
PDF
The Most Misunderstood Line In Zen Of Python.pdf
Patrick Viafore
 
PPTX
Robust Python.pptx
Patrick Viafore
 
PDF
Tip Top Typing - A Look at Python Typing
Patrick Viafore
 
PPTX
RunC, Docker, RunC
Patrick Viafore
 
PDF
DevSpace 2018 - Practical Computer Science: What You Need To Know Without Th...
Patrick Viafore
 
PPTX
Controlling Raspberry Pis With Your Phone Using Python
Patrick Viafore
 
PDF
C++17 not your father’s c++
Patrick Viafore
 
PPTX
Building a development community within your workplace
Patrick Viafore
 
PPTX
Lambda Expressions in C++
Patrick Viafore
 
PPTX
BDD to the Bone: Using Behave and Selenium to Test-Drive Web Applications
Patrick Viafore
 
PPTX
Hsv.py Lightning Talk - Bottle
Patrick Viafore
 
Extensible Python: Robustness through Addition - PyCon 2024
Patrick Viafore
 
User-Defined Types.pdf
Patrick Viafore
 
The Most Misunderstood Line In Zen Of Python.pdf
Patrick Viafore
 
Robust Python.pptx
Patrick Viafore
 
Tip Top Typing - A Look at Python Typing
Patrick Viafore
 
RunC, Docker, RunC
Patrick Viafore
 
DevSpace 2018 - Practical Computer Science: What You Need To Know Without Th...
Patrick Viafore
 
Controlling Raspberry Pis With Your Phone Using Python
Patrick Viafore
 
C++17 not your father’s c++
Patrick Viafore
 
Building a development community within your workplace
Patrick Viafore
 
Lambda Expressions in C++
Patrick Viafore
 
BDD to the Bone: Using Behave and Selenium to Test-Drive Web Applications
Patrick Viafore
 
Hsv.py Lightning Talk - Bottle
Patrick Viafore
 
Ad

Recently uploaded (20)

PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PPTX
How Cloud Computing is Reinventing Financial Services
Isla Pandora
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
How Cloud Computing is Reinventing Financial Services
Isla Pandora
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 

Controlling the browser through python and selenium

  • 2. • Pat Viafore •ADTRAN •Past work at TOA Systems •Python at home
  • 3. • What is Selenium? • How Do I Use It? • Getting Information Off a Page • Controlling Input • Advanced Features • Limitations • Rejoicing
  • 4. And what can it do for me?
  • 6. • Allows scripts to take control of a web browser • Supports multiple language bindings • We’ll focus on Python today • Windows/Linux/MacOS Support • $> pip install selenium • Licensed under Apache 2.0 • Easy to use
  • 12. • I currently work on an internal web-app • I use Selenium to drive acceptance tests – making sure the web page operates as we expect it to • Database interactions • Error conditions • External service tests (e-mail, LDAP, etc.) • I use Python to “glue” web browser interaction with system events
  • 14. • We’re not just limited to acceptance tests • Automate common tasks you use a web browser for
  • 15. • Hook up Selenium to data feeds to control web pages • Hulu • Pandora • YouTube • Take care of things on a schedule • Pay bills online • Sign up for more Python Meetings 
  • 17. Enough with the blah, blah, blah….Let’s Code!
  • 25. Because just getting things is boring
  • 29. • Go to YouTube • Search for Python programming • Sort by Recent Date • Click on a random video
  • 31. Bring on the cool stuff
  • 35. • Screenshotting • Execute arbitrary Javascript code • browser.execute_script(jsCode) • Also an async version • Browser Capabilities • Proxying
  • 36. • Navigate to Google Maps • Move mouse to center of map • Start scrolling north a bunch • Move the mouse or press keys through chainable actions • More options about ActionChains http://selenium-python.readthedocs.org/en/latest/api.html
  • 38. • We could use XVFB or something similar on certain Linux distros • Instead, we’ll use PhantomJS to create a headless browser • Separate JS installation • We’ll create X threads that do a series of interactions and time them
  • 40. There is no such thing as a Silver Bullet
  • 41. • Why Use Selenium? • Why Not Mocha? • Why Not Jasmine? • Why Not GUI Recorders?
  • 42. • RESTful Interactions • Requests does a far better job • User Interface (UI) testing • Selenium does offer Location/Size/CSS, but you’ll probably be rolling your own layer on top of Selenium to handle UI testing • Brittle UIs • UIs change often (classes, ID changes, buttons changes) • Can mitigate by providing a wrapper around Selenium to interact with your site – DRY (Don’t Repeat Yourself) Principle