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

PDF
Selenium testing
PPTX
Parallel Testing with Python with Selenium and Sauce Labs
PDF
Testing Code.org's Interactive CS Curriculum
PPTX
Selenium Automation at Incapsula
PDF
Selenium and Sauce Labs
PPTX
Selenium for Jobseekers
PDF
Jenkins & Selenium
PDF
How To Use Selenium Successfully (Java Edition)
Selenium testing
Parallel Testing with Python with Selenium and Sauce Labs
Testing Code.org's Interactive CS Curriculum
Selenium Automation at Incapsula
Selenium and Sauce Labs
Selenium for Jobseekers
Jenkins & Selenium
How To Use Selenium Successfully (Java Edition)

What's hot (20)

PDF
Selenium Testing on Chrome - Google DevFest Armenia 2015
PDF
Automation Testing
PPTX
Moving From a Selenium Grid to the Cloud - A Real Life Story
PPTX
Automated ui-testing
ODP
Mastering selenium for automated acceptance tests
PPTX
QA Fest 2017. Александр Хотемской. Современные возможности в организации Prot...
PPTX
Selenium
PDF
APIs: A Better Alternative to Page Objects
PDF
Selenium WebDriver with C#
PDF
Basics of Selenium IDE,Core, Remote Control
PDF
Selenoid: browsers in containers
PPTX
Beyond the Release: CI That Transforms Organizations
PPTX
Smarter ways to do selenium automation @ work, Selenium, automation
PPTX
Selenium
PPT
Selenium By Pravin Mishra
PDF
Automatic Functional Testing with Selenium and SauceLabs
PDF
Selenium IDE and Beyond
KEY
Testing with Jenkins, Selenium and Continuous Deployment
DOCX
Selenium webdriver course content rakesh hansalia
PDF
Selenium webdriver
Selenium Testing on Chrome - Google DevFest Armenia 2015
Automation Testing
Moving From a Selenium Grid to the Cloud - A Real Life Story
Automated ui-testing
Mastering selenium for automated acceptance tests
QA Fest 2017. Александр Хотемской. Современные возможности в организации Prot...
Selenium
APIs: A Better Alternative to Page Objects
Selenium WebDriver with C#
Basics of Selenium IDE,Core, Remote Control
Selenoid: browsers in containers
Beyond the Release: CI That Transforms Organizations
Smarter ways to do selenium automation @ work, Selenium, automation
Selenium
Selenium By Pravin Mishra
Automatic Functional Testing with Selenium and SauceLabs
Selenium IDE and Beyond
Testing with Jenkins, Selenium and Continuous Deployment
Selenium webdriver course content rakesh hansalia
Selenium webdriver
Ad

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

PPTX
Automated Acceptance Testing from Scratch
PPTX
Open Source Automation Tools That Really Work V2
PPTX
QA Challenge Accepted 4.0 - Cypress vs. Selenium
PPT
Selenium for everyone
PDF
[Rakuten TechConf2014] [Osaka] Introducing Selenium 2 WebDriver
PPTX
Selenium practical
PDF
Build Fail-Proof Tests in Any Browser with Selenium
PDF
Intro to SharePoint 2010 development for .NET developers
PDF
Modern websites in 2020 and Joomla
PPTX
External JavaScript Widget Development Best Practices
PDF
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
PPTX
Selenium – Web Browser Automation
PDF
Introduction to Robot Framework
PDF
Getting started with dev tools (atl)
PPTX
Java scriptwidgetdevelopmentjstanbul2012
PPTX
Scaling and Managing Selenium Grid
PDF
Modern Web Framework : Play framework
PDF
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
PPTX
Introduction to selenium
PPTX
ОЛЕКСІЙ ОСТАПОВ «Найкрутіші особливості автоматизації на Playwright Python» K...
Automated Acceptance Testing from Scratch
Open Source Automation Tools That Really Work V2
QA Challenge Accepted 4.0 - Cypress vs. Selenium
Selenium for everyone
[Rakuten TechConf2014] [Osaka] Introducing Selenium 2 WebDriver
Selenium practical
Build Fail-Proof Tests in Any Browser with Selenium
Intro to SharePoint 2010 development for .NET developers
Modern websites in 2020 and Joomla
External JavaScript Widget Development Best Practices
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
Selenium – Web Browser Automation
Introduction to Robot Framework
Getting started with dev tools (atl)
Java scriptwidgetdevelopmentjstanbul2012
Scaling and Managing Selenium Grid
Modern Web Framework : Play framework
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Introduction to selenium
ОЛЕКСІЙ ОСТАПОВ «Найкрутіші особливості автоматизації на Playwright Python» K...
Ad

More from Patrick Viafore (13)

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

Recently uploaded (20)

PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
medical staffing services at VALiNTRY
PDF
Digital Strategies for Manufacturing Companies
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
System and Network Administraation Chapter 3
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
ai tools demonstartion for schools and inter college
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
How Creative Agencies Leverage Project Management Software.pdf
medical staffing services at VALiNTRY
Digital Strategies for Manufacturing Companies
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
System and Network Administraation Chapter 3
CHAPTER 2 - PM Management and IT Context
ai tools demonstartion for schools and inter college
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Odoo Companies in India – Driving Business Transformation.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Softaken Excel to vCard Converter Software.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Internet Downloader Manager (IDM) Crack 6.42 Build 41
ISO 45001 Occupational Health and Safety Management System
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf

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