Month: August 2017

  • WebdriverIO with ChromeDriver headless without Selenium

    I was excited to discover that WebdriverIO supports the use of ChromeDriver running in headless mode without the use of Selenium (because ChromeDriver supports the WebDriver protocol). Here’s a starter guide (assuming Node.js is installed):

    1. Install Chrome Web Browser
    2. Download ChromeDriver
    3. Run ChromeDriver
    4. Install WebdriverIO by running npm i webdriverio
    5. Run the following file (based on the WebdriverIO example)
    const webdriverio = require('webdriverio')
    const client = webdriverio.remote({
    host: "localhost",
    port: 9515,
    path: "/",
    desiredCapabilities: {
    browserName: "chrome"
    }
    })
    client
    .init()
    .url('https://duckduckgo.com/')
    .setValue('#search_form_input_homepage', 'WebdriverIO')
    .click('#search_button_homepage')
    .getTitle().then(function(title) {
    console.log('Title is: ' + title);
    })
    .end()
    

    To run Chrome in headless, use the following config:

    const client = webdriverio.remote({
    host: "localhost",
    port: 9515,
    path: "/",
    desiredCapabilities: {
    browserName: "chrome",
    chromeOptions: {
    args: ["headless", "disable-gpu"]
    }
    }
    })
    
  • Multiple layouts with React Router v4

    I was searching for a way to add use multiple layouts with React Router v4. I could only find examples for v3, but was inspired by the Redirects (Auth) example in the docs. I created a simple wrapper component for a Route that allows a layout prop to be passed which renders the component as a child of the layout: