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

class1_project_structure

 

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

class1_intellij_project_structure

 

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

BrowserCommands.feature

Addition.java (step definition for addition.feature)

BrowserCommands.java (step definition for BrowserCommands.feature)

How to Run from IntelliJ (similar in eclipse too)

intellij_run_scenario

Execution Output

Intellij Output

class1_intellij_output

Command Line Output

class1_cmd_output

CI Server

class1_output