Selenium

Selenium: WebDriver Wait

ImplicitWait

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

FluentWait

  • creates a method that polls for a successful findElement() response every 5s - for 30s
  • wait.until(loop until no exception/false returned){
    • create an 'on-the-fly' method
      • create a FluentWait wait & set its properties
      • try findElement(By) while response is NoSuchElementFound or null
        • once true, return WebElement

requires import:

Tags

Selenium: PageObjectModel vs Object Repository

Great explanation on the difference between POM and 'Data Driven' Object Repository

Testing Drupal all but requires POM due to the challenging element selector requirements & the need for multiple actions against the element/page to access it or interact with it.

Namely CKEditor injects an iframe inside a textarea and the need for JavaScriptExecutioner to update the text() of the embedded body tag.

Selenium Webdriver's Location In A TestFramework Stack

  • A WebBrowser is a front-end to a website http server
  • A WebDriver is a front-end to a specific WebBrowser that controls interaction with a website
  • Selenium-Server is a front-end to a WebDriver that provides API calls to interact the WebDriver over HTTP
    • Theoretically, Selenium Server provides a library of actions/listeners/utils and the WebDriver provides the custom browser implementation
    • Selenium Server does nothing without a WebDriver
  • Language bindings provide a language-specific API and interface to Selenium Server API
    • The language bindings expose/translate API calls to Selenium Server
    • Available Selenium Server functions are dependent on the Language Binding
    • Language bindings can differ in their class hierarchies, API structure, and available functions.
  • SeleniumCore = Webdriver: chromedriver.exe, iedriver.exe, geckodriver.exe
  • SeleniumServer = selenium-se

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.

 


 

Subscribe to Selenium