SlideShare a Scribd company logo
Selenium for OPS
Admins Anonymous meetup #5
Lukasz Proszek
lukasz@proszek.info
2014-06-17
Background
You’re a BOFH at GlobalFskcup Ltd.
Everyday you deal with numerous incidends.
You have to seek approval and/or log every change made.
The Head of IT has his favorite tool for that
MacroHard PointShare form
Rich editor filled form, with sparkling format choosers.
Bells and whistles included
The soft problem
Filling the form takes 5-20 minutes each time
No PFY available to do the job
Keeping templates in a text document... sooooo 1990
Browser plugins - does not recognize all of provided inputs
curl - yeah right, like I have time for that
Selenium - basics
1 from selenium import webdriver
2 driver = webdriver.Firefox ()
3 driver.get("http :// google.com")
4 driver. find_element_by_id ("...")
how to identify element → inspect element
Selenium - interact with webelement
1 from selenium import webdriver
2 driver = webdriver.Firefox ()
3 driver.get("http :// google.com")
4 fld=driver. find_element_by_id (’gbqfq ’)
5 fld.send_keys(’Anonimowi Admini ’)
badumm tsss
Something more complicated
Show me the code
What the fsck?
Problem? HTML injection
the id is a hash of something... different everytime
Let’s get the RichEditor’s class
1 e = "table.ms -formtable > tbody >
2 tr:nth -of -type (7) > td.ms -formbody >
3 span[dir=’none ’] > div >
4 div:nth -of -type (2)"
5 c=driver. find_element_by_css_selector (e)
6 .get_attribute("class")
Problem? HTML injection
We can not use webdriver.send keys() on that... it’s
inside the html code
We have to inject HTML with javascript
1 JS="document. getElementsByClassName ({0})[{1}]
2 .innerHTML =’{2}’".format(
3 CLASS_NAME , INDEX ,
4 "<marquee > WTF </marquee >"
5 )
6 driver.execute_script(JS)
Clicking a radio button
1 driver. find_element_by_css_selector (
2 "input[type=’radio ’][ value =’{0}’]".format(
3 "Approved by the CEO"
4 )
5 ). click ()
Selecting a dropdown option
1 driver. find_element_by_css_selector (
2 "option[value =’{0}’]".format(value)
3 ). click ()
Sending the form
1 driver. find_elements_by_css_selector (
2 "input[value=’Save ’][type=’button ’]"
3 ). click ()
Many python, such win
208 lines of Python
virtualenv
selenium for browser automation (pip install selenium)
click for easy commandline (pip install click)
path.py just because (pip install path.py)
YAML for templates (pip instal pyYaML)
keepass for credentials (pip install keepass)
outcome, further plans, other uses
Outcome
It took 3hrs to write
It eared it’s keep after one day
Further plans
webdriver.PhantomJS() for headless operation
ansible integration
Other uses
e.g. testing how long it takes the user to perform some action
Thank You
wiki2beamer - latex-beamer made easy
impressive - pdf presentations with sugar added
http://github.com/frogu/presentations

More Related Content

PDF
Getting Information through HTML Forms
PDF
Introduction to jQuery Mobile - Web Deliver for All
PPT
IE8 Dev Overview_pp2003
PDF
BDD - Writing better scenario
ODP
SlideShare Instant
PPT
SlideShare Instant
PDF
Web Projects: From Theory To Practice
KEY
Intro to html5 Boilerplate
Getting Information through HTML Forms
Introduction to jQuery Mobile - Web Deliver for All
IE8 Dev Overview_pp2003
BDD - Writing better scenario
SlideShare Instant
SlideShare Instant
Web Projects: From Theory To Practice
Intro to html5 Boilerplate

What's hot (20)

PDF
Intro Open Social and Dashboards
PDF
HTML5 Essentials
KEY
关于 Html5 那点事
PDF
Intro to html 5
PDF
PDF
Usability in the GeoWeb
PDF
#3 HTML & CSS [know-how]
PDF
Node.js Authentication and Data Security
PPTX
Css, xhtml, javascript
PDF
Front End Development: The Important Parts
PDF
Accessibility - A feature you can build
PDF
&lt;img src="../i/r_14.png" />
PDF
HTML5 and the web of tomorrow!
PPTX
Introduction to HTML5 & CSS3
PPTX
計算機概論20161205
KEY
Html5的应用与推行
PDF
tut0000021-hevery
PDF
Web Component
PDF
Web Standards: Fueling Innovation [Web Design World Boston '08]
PPTX
計算機概論20161212
Intro Open Social and Dashboards
HTML5 Essentials
关于 Html5 那点事
Intro to html 5
Usability in the GeoWeb
#3 HTML & CSS [know-how]
Node.js Authentication and Data Security
Css, xhtml, javascript
Front End Development: The Important Parts
Accessibility - A feature you can build
&lt;img src="../i/r_14.png" />
HTML5 and the web of tomorrow!
Introduction to HTML5 & CSS3
計算機概論20161205
Html5的应用与推行
tut0000021-hevery
Web Component
Web Standards: Fueling Innovation [Web Design World Boston '08]
計算機概論20161212
Ad

Viewers also liked (19)

PDF
DevOps meetup - Ansible and Docker for your VPS
PDF
Application Deployment Using Ansible
PPTX
Jak tworzyć bezpieczne aplikacje?
PDF
Fluent integration-tests
PDF
Mindtree IMS Offerings
PPTX
Southeast Asia Technology Investment Landscape
PPT
Presentation on Talent Development
PDF
e-conomy SEA by Google and Temasek
PPTX
Quantum computing
PDF
Great Talks Start with Great Proposals: An IA Summit Virtual Webinar
PDF
Designing a Culture of Design
PDF
Mobile Trends 2012 - MDAYS by Torsten Schollmayer, SapientNitro
PPT
Entrepreneurshit. The Truth About Building Starutps
PDF
Subscribed 2015: CEO's Keynote
PDF
Does Living Near An NFL Stadium Boost Your Home Value?
PDF
PPTX
Just a Room Full of Stuff? Why Libraries are Great / Katie Birkwood
PDF
Bcg Consultants Love Life
PPTX
College Disrupted - Ryan Craig
DevOps meetup - Ansible and Docker for your VPS
Application Deployment Using Ansible
Jak tworzyć bezpieczne aplikacje?
Fluent integration-tests
Mindtree IMS Offerings
Southeast Asia Technology Investment Landscape
Presentation on Talent Development
e-conomy SEA by Google and Temasek
Quantum computing
Great Talks Start with Great Proposals: An IA Summit Virtual Webinar
Designing a Culture of Design
Mobile Trends 2012 - MDAYS by Torsten Schollmayer, SapientNitro
Entrepreneurshit. The Truth About Building Starutps
Subscribed 2015: CEO's Keynote
Does Living Near An NFL Stadium Boost Your Home Value?
Just a Room Full of Stuff? Why Libraries are Great / Katie Birkwood
Bcg Consultants Love Life
College Disrupted - Ryan Craig
Ad

Similar to Selenium for-ops (20)

ODP
HTML5 e CSS3 (slides della sessione tenuta al DIMI di Udine)
ODP
Developing new feature in Joomla - Joomladay UK 2016
PDF
Working With The Symfony Admin Generator
PPTX
JavaScript DOM - Dynamic interactive Code
ODP
The why and how of moving to php 5.4
PDF
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
PDF
Top100summit 谷歌-scott-improve your automated web application testing
PPT
WordPress basic fundamental of plugin development and creating shortcode
PDF
Selenium Introduction by Sandeep Sharda
PDF
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
DOCX
Salesforce Admin's guide : the data loader from the command line
PPTX
Android Data Binding
PPS
Simplify your professional web development with symfony
PPTX
End-to-end testing with geb
KEY
Workshop quality assurance for php projects tek12
PDF
Practical JavaScript Programming - Session 4/8
DOCX
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
PPTX
Rapid application development using Akeeba FOF and Joomla 3.2
PPTX
Rapid application development using Akeeba FOF and Joomla 3.2
PDF
L2. Function in JS, CSE 202, BN11.p1df documents
HTML5 e CSS3 (slides della sessione tenuta al DIMI di Udine)
Developing new feature in Joomla - Joomladay UK 2016
Working With The Symfony Admin Generator
JavaScript DOM - Dynamic interactive Code
The why and how of moving to php 5.4
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Top100summit 谷歌-scott-improve your automated web application testing
WordPress basic fundamental of plugin development and creating shortcode
Selenium Introduction by Sandeep Sharda
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
Salesforce Admin's guide : the data loader from the command line
Android Data Binding
Simplify your professional web development with symfony
End-to-end testing with geb
Workshop quality assurance for php projects tek12
Practical JavaScript Programming - Session 4/8
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Rapid application development using Akeeba FOF and Joomla 3.2
Rapid application development using Akeeba FOF and Joomla 3.2
L2. Function in JS, CSE 202, BN11.p1df documents

Recently uploaded (20)

PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
KodekX | Application Modernization Development
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Dropbox Q2 2025 Financial Results & Investor Presentation
Mobile App Security Testing_ A Comprehensive Guide.pdf
Electronic commerce courselecture one. Pdf
Unlocking AI with Model Context Protocol (MCP)
“AI and Expert System Decision Support & Business Intelligence Systems”
NewMind AI Weekly Chronicles - August'25 Week I
Machine learning based COVID-19 study performance prediction
Understanding_Digital_Forensics_Presentation.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The Rise and Fall of 3GPP – Time for a Sabbatical?
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Digital-Transformation-Roadmap-for-Companies.pptx
KodekX | Application Modernization Development
Network Security Unit 5.pdf for BCA BBA.
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Advanced methodologies resolving dimensionality complications for autism neur...
Reach Out and Touch Someone: Haptics and Empathic Computing
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

Selenium for-ops

  • 1. Selenium for OPS Admins Anonymous meetup #5 Lukasz Proszek lukasz@proszek.info 2014-06-17
  • 2. Background You’re a BOFH at GlobalFskcup Ltd. Everyday you deal with numerous incidends. You have to seek approval and/or log every change made. The Head of IT has his favorite tool for that MacroHard PointShare form Rich editor filled form, with sparkling format choosers. Bells and whistles included
  • 3. The soft problem Filling the form takes 5-20 minutes each time No PFY available to do the job Keeping templates in a text document... sooooo 1990 Browser plugins - does not recognize all of provided inputs curl - yeah right, like I have time for that
  • 4. Selenium - basics 1 from selenium import webdriver 2 driver = webdriver.Firefox () 3 driver.get("http :// google.com") 4 driver. find_element_by_id ("...")
  • 5. how to identify element → inspect element
  • 6. Selenium - interact with webelement 1 from selenium import webdriver 2 driver = webdriver.Firefox () 3 driver.get("http :// google.com") 4 fld=driver. find_element_by_id (’gbqfq ’) 5 fld.send_keys(’Anonimowi Admini ’)
  • 9. Show me the code
  • 11. Problem? HTML injection the id is a hash of something... different everytime Let’s get the RichEditor’s class 1 e = "table.ms -formtable > tbody > 2 tr:nth -of -type (7) > td.ms -formbody > 3 span[dir=’none ’] > div > 4 div:nth -of -type (2)" 5 c=driver. find_element_by_css_selector (e) 6 .get_attribute("class")
  • 12. Problem? HTML injection We can not use webdriver.send keys() on that... it’s inside the html code We have to inject HTML with javascript 1 JS="document. getElementsByClassName ({0})[{1}] 2 .innerHTML =’{2}’".format( 3 CLASS_NAME , INDEX , 4 "<marquee > WTF </marquee >" 5 ) 6 driver.execute_script(JS)
  • 13. Clicking a radio button 1 driver. find_element_by_css_selector ( 2 "input[type=’radio ’][ value =’{0}’]".format( 3 "Approved by the CEO" 4 ) 5 ). click ()
  • 14. Selecting a dropdown option 1 driver. find_element_by_css_selector ( 2 "option[value =’{0}’]".format(value) 3 ). click ()
  • 15. Sending the form 1 driver. find_elements_by_css_selector ( 2 "input[value=’Save ’][type=’button ’]" 3 ). click ()
  • 16. Many python, such win 208 lines of Python virtualenv selenium for browser automation (pip install selenium) click for easy commandline (pip install click) path.py just because (pip install path.py) YAML for templates (pip instal pyYaML) keepass for credentials (pip install keepass)
  • 17. outcome, further plans, other uses Outcome It took 3hrs to write It eared it’s keep after one day Further plans webdriver.PhantomJS() for headless operation ansible integration Other uses e.g. testing how long it takes the user to perform some action
  • 18. Thank You wiki2beamer - latex-beamer made easy impressive - pdf presentations with sugar added http://github.com/frogu/presentations