Browser Commands

Context:

The Browser commands are generally the ones which we intuitively feel that a browser should control. Examples are “type url and hit enter”, “getTitle”,”back”,”forward” and so on. Video of the execution and walk through code is explained in the video at the bottom of this page.

Pre-Requisites

  1. Install Java JDK
  2. Install Maven
  3. Install and Configure Eclipse OR Install IntelliJ Community Edition
  4. Set up selenium webdriver components

It is assumed that you have downloaded the Class1 code base. – https://github.com/machzqcq/CucumberJVMExamples

Agenda:

  1. Simple cucumber scenario adding two numbers
  2. Selenium Scenario
  3. Browser Title, Current url, page sources
  4. Browser forward, backward and refresh

1. Navigate to url (Go to a URL)

 

2. Browser Title

4. Browser back

5. Browser forward

6. Browser refresh

7. Browser current url

 

Steps

  1. Once you have downloaded the codebase, import it into your Eclipse IDE by File – Import – Maven – Existing Maven Projects. Note:Eclipse Luna has maven plugin by default
  2. Point to the root folder of “cucumber-java-selenium-class1” [Basically the folder that contains the pom.xml for class1]
  3. There are two cucumber scenarios “addition.feature” and “BrowserCommands.feature”
  4. Right click anywhere on the feature file and Run As – Cucumber Feature. Again this is explained on Cucumber First project

After importing the project into eclipse, it should look like this

 

After importing the project into Intellij, it should look like this

 

Standards

  • Unless otherwise specified, our training class projects will have the files src/test/java/step_definitions/Hooks.java [We explained this file in Cucumber first project]
  • Unless otherwise specified, our training classe projects will have file src/test/java/step_definitions/RunCukesTest.java [We explained this file in Cucumber first project]
  • Rest of the files will be specific to the functionality we explain on each page.

Addition.feature

1
2
3
4
5
6
7
8
9
Feature: Addition
As a math idiot
In order to not feel silly
I add two numbers
Scenario: Adding a and b
Given I have variable a
And I have variable b
When I add a and b
Then I display the sum