Using Selenium-Cucumber to run automated tests on browserstack.

Lets get started

Prerequisites :

Setup

  • Install Ruby
  • Install selenium-cucumber gem : “gem install selenium-cucumber” (trouble?)
  • Create a browserstack account, if not exist. (sign-up)

Project Setup

  • Create new project directory.
  • Generate feature skeleton using command : “selenium-cucumber gen”.
  • Copy your browserstack account username & access-key
    • Login to browserstack
    • Go to “Automate” tab.
    • Click on “Username and Access Keys” menu from left-hand side panel.
  • Now open “account_credentials.yml” file from following path
    • your_project/features/support/account_credentials.yml
    • Paste your username & access-key in browserstack section.
    • (Add code snippet)

    take a breath, 50% work is done

Lets write some tests

  • Pick-up your product under test, write test steps using our predefined-steps.
  • (Add code snippet)

Now time to pick testing platform

    now here’s come tricky part…

  • Go to “platform_configs” directory i.e. “your_project/features/platform_configs/”
  • Create a new file with following name pattern
    • cloudService_os_device_browser or cloudService_os_device_app
    • e.g. If your using Browserstack
      • browserstack_android_nexus5_chrome.yml
      • browserstack_windows_ie11.yml
    • e.g. If your using Saucelab
      • saucelab_mac_safari_10.yml
      • saucelab_ios_app_iphone6S.yml
  • Store file with “.yml” extension. (YAML file)
  • Now again go to platform settings page where you selected your platform.
  • Copy on keys and values as follows:
  • (Code snippet of yml file)
  • still confused? (checkout video!)

    it’s time to run tests…

  • Open command prompt/terminal.
  • Go to your project directory
  • Hit the command “cucumber CONFIG=your_platform_config_file.yml
    • e.g cucumber CONFIG_FILE=browserstack_android_nexus5_chrome.yml
  • You can see real time execution progress at Browserstack’s automate tab.

    you are done! wasn’t it simple!

 

Key Benefits

  • Easy to setup.
  • Minimal coding required.
  • Reduce test hardware cost.
  • Increase test coverage across the number of platforms.
  • Parallel test runs.

limitations

Checkout complete video tutorial.

Advertisement