WebDriver 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. Read on to find out what Selenium provides

 

Agenda:

  1. Print browser name
  2. Print browser ready state
  3. Perform back, forwards and refresh browser operations

 

1. GoTo (Go to a URL)

 

2. Browsername

 

3. Browser ready state

4. Browser back

5. Browser forward

6. Browser refresh

7. Browser title

8. Browser current url

 

Steps

1. Open the template project in RubyMine

 

browser_commands_openproject

2. Right click on the features folder and create a feature file “browser_commands.feature”

 

new_feature

 

3. Now copy the below gherkin code in “browser_commands.feature”

 

4. Now right-click on the step_definitions folder and create a new file “browser_commands.rb” [Watch the video at the end of this file to see how to do it step by step]

 

 

 

5. After adding both the browser_commands.feature and browser_commands.rb, your project should look like this

 

final_code

 

6. Now right click on each scenario (or if you wish to execute all scenarios) and run to see the output

 

run_feature

Browser Commands