Selenium

Ubuntu: Install Selenium & ChromeDriver

 

Install required packages

sudo apt-get update
sudo apt-get install -y unzip xvfb libxi6 libgconf-2-4

 

Install Chrome

sudo curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add
sudo echo "deb [arch=amd64]  http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
sudo apt-get -y update
sudo apt-get -y install google-chrome-stable

 

Install ChromeDriver

wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip
unzip chromedriver_linux64.zip

 

PHPUnit-Webdriver: 09 - PhantomJS ( GhostDriver )

  • https://github.com/detro/ghostdriver
  • PhantomJS has ghostdriver embedded so it is an all-in-one package
  • PhantomJS has crashes periodically, so have some concerns about using it.
  • As of 2018.11.28:
    • [FOR PHP] I currently prefer to use chromedriver with the --headless CLI spec for CI/CD use
      • if only to ensure consistent runtime & capability support
    • There are good reasons to implement other drivers - but I'd lean towards implementing other webdrivers AFTER a chromedriver solution is build & stable.
      • Then FireFox & IE headful
      • Then these two in headless
    • FireFox PHP driver currently has issues with the php-webdriver(Facebook WebDriver), so have not implemented FF in my latest PHPUnit-php-webdriver framework.

 


 

PHPUnit-Webdriver: 10 - PageObjectModel Framework

  • When testing web applications ( or any complex product ) modeling the application is critical for reducing maintenance overhead.
  • Tests should be abstracted away from interacting with the DOM & its elements such that they only reflect interactions
  • By modeling the application, creating tests is intuitive & element selectors are assigned one time in one place
    • Using enumerations and/or constants allow for indirect references to elements so if their selectors change, the only update needed is one constant assignment
  • When the framework is updated to reflect architectural changes in the product, updates will be contained and encapsulated
    • failing tests will show technical debt & expose possible impact to the product that may have not been anticipated.

 

Page Object Model

Behat Mink: 000 - Blocking Issues in Mink for Drupal

  • Mink is probably a great tool for basic websites that don't implement a heavy back-end system.
  • Mink COULD be a winner IF
    • migrates to selenium3 webdriver
    • exposes the entire selenium3 api
    • provides a means to send XPATH directly to selenium api
      • currently catches, parses, translates, THEN sends to api
    • provides a means to send CSS directly to selenium api
      • currently catches, parses, translates, THEN sends to api

Behat front end is a solid Cucumber BDD Engine

  • Still requires a sensible & well-designed test framework to hook into
  • Design the framework around PHPUnit
  • Use Behat to provide BDD translation for feature files
  • BDD isn't test...

Behat Mink: 00 - Selenium

Selenium

Download the latest version of Selenium Server It’s under the heading Selenium Server (formerly the Selenium RC Server). This is a single file which can be placed any where you like on your system and run with the following command:

java -jar selenium-server-standalone-2.44.0.jar &
// replace with the name of the version you downloaded

 

Subscribe to Selenium