Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Ui testing with splinter - Fri, 30 May 2014

2.440 visualizaciones

Publicado el

The Introduction of Useful UI Testing Tool - Splinter

Publicado en: Software, Tecnología
  • Inicia sesión para ver los comentarios

Ui testing with splinter - Fri, 30 May 2014

  1. 1. UI Testing with Splinter Taizo Ito <taizo.ito@hde.co.jp> HDE, Inc.
  2. 2. What’s Splinter? UI Testing tool for web applications - Open source software (BSD-like License) - Implemented by Python As of this writing, there seems to be no other python-implemented tools like this. - It helps you control actions on web browser
  3. 3. Features - Easy to install/setup - Support popular browsers - Easy to use Simple and intuitive API
  4. 4. Installation Simply run the following command. That’s all! $ sudo pip install splinter As an additional requirement, a web client such as Chrome, Firefox and PhantomJS must be installed.
  5. 5. Supported Browsers Splinter provides multiple web drivers: Browser based Chrome, Firefox, (Remote) Headless PhantomJS, zope.testbrowser, django client, Flask client Remote Uses Selenium RC to automate browser actions on a remote machine such as Sauce Labs.
  6. 6. Web Driver Splinter is an abstraction layer The same test code covers actions of any browser A P I Browser-based Selenium Headless PhantomJS zope.testbrowser Chrome Firefox RemoteTest Code Remote Webdriver Server Sauce Labs (IE) HTTP Splinter
  7. 7. APIs Each method is so intuitive; It’s easy to use. - visit() Go to the specified URL. e.g. browser.visit(‘http://www.hde.co.jp’) # then you can see html text from browser.html. - fill() Fill an input form with the specified text. e.g. browser.find_by_id(‘your_name’).fill(‘taizo’) - click() Click an element such as button or link text. e.g. browser.find_by_id(‘search_button’).click() and more…
  8. 8. Example: Login with Single Sign On(1) Login to App using Google Apps Federated Login 1 browser = Browser(“phantomjs”) 2 3 browser.visit(“https://foobar.example.com/login”) 4 5 browser.find_by_id(“Email”).fill(“foobar@example.com”) 6 browser.find_by_id(“Passwd”).fill(“secret_password”) 7 browser.find_by_id(“signIn”).click() 8 time.sleep(1) 9 10 if browser.title == “Request for Permission”: 11 browser.find_by_id(“submit_approve_access”).click() 12 time.sleep(1) 13 14 assert browser.title == “This is a title of App”, “Failed to login”
  9. 9. Example: Login with Single Sign On(2) Login to App using Microsoft WAAD SAML 1 browser = Browser(“phantomjs”) 2 3 browser.visit(“https://foobar.example.com/login”) 4 5 browser.find_by_id(“cred_userid_inputtext”).fill(“foobar@example.com”) 6 browser.find_by_id(“cred_password_inputtext”).fill(“secret_password”) 7 browser.find_by_id(“cred_keep_me_signed_in_checkbox”).check() 8 time.sleep(1) 9 browser.find_by_id(“cred_sign_in_button”).click() 10 time.sleep(1) 11 12 assert browser.title == “This is a title of App”, “Failed to login”
  10. 10. Other features Cookie Manager ● browser.cookies.all() ● browser.cookies.add() ● browser.cookies.delete()
  11. 11. Features not implemented We are not allowed to: - Get contents of downloaded data by using Splinter. We have to use requests module to get it instead of Splinter. - Customize HTTP Request headers when using headless web driver. Therefore, we can’t check if the multi-language feature of web apps works well. Accept-Language: en-US,en;q=0.8,ja;q=0.6
  12. 12. Tips - Use Google Chrome’s Developer Console to get the XPath of an element. It is easy to identify the element using find_by_xpath(). - To customize HTTP Request headers in PhantomJS driver, get the latest vesion from Github, which supports custom headers. My PR was accepted ;-) https://github.com/cobrateam/splinter/pull/316 - Use Splinter with behave. http://pythonhosted.org/behave/ You can easily practice BDD(Behavior-Driven Development) for web apps with Python.
  13. 13. Thank you Taizo Ito <taizo.ito@hde.co.jp> HDE, Inc.

×