Selenium Browser Automation Setup

Selenium Browser Automation Setup

Ensure you have a version of PHP greater than 7. You can use php --version to check this. First install Firefox 43.0 Download Firefox 43.0. Enter about:config into the search bar. Acknowledge you may void your warranty. Right click, create new row. Enter the following values.

type: string

preference name: general.useragent.override

value: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36

Install the selenium IDE Download Selenium IDE.Selenium IDE is an integrated development environment for Selenium scripts. The next section is revised from the Behat user guide.

Every .feature file consists of a single feature. A feature contains a list of scenarios. Every scenario consists of a list of Steps, which must start with one of the following keywords:

Behat treats them all the same, but you shouldn’t. Here is an example:

Feature: Serve coffee
    In order to earn money
    Customers should be able to
    buy coffee at all times

    Scenario: Buy last coffee
      Given there are 1 coffees left in the machine
      And I have deposited 1 dollar
      When I press the coffee button
      Then I should be served a coffee

Working with the configuration .yml file

Note: in this demonstration the .yml structure differs from Behat's documentation since we have implemented an Abstract Web Driver to maintain the web driver instance between scenarios. You can read more on the Abstract Web Driver implementation.

Configuration happens in the behat.yml file. We can tell Behat which scenarios we want to skip etc. Read more here:

Default. This is a configurations profile name. Default profile is always default. Every other profile will inherit the default profile configuration. You can switch testing configuration by using the --profile [name] option when executing your feature suite.

Autoload. Sets the path where Behat looks for context classes.

Suites. Describe suites. Each suite has a name and paths attribute. The paths attribute is the path to the .feature file to use for this suite. Each suite has a contexts attribute. There can be multiple contexts files associated with a suite, but please do not associate multiple suites with one context file.

Filters. Defines default filters (name or tag) for your features.

More settings can be configured such as environment variables, colors, imports, etc. Please refer to the Behat config guide for more information.

After writing a feature file, you can automatically append the behat step functions to the a feature context file by including "--append-snippets" when running tests.

bin/behat --append-snippets

Behat will automatically generate context methods for you! This is how they look:

     * @Given I do something
    public function iDoSomething()
        throw new PendingException();