Wednesday 3 February 2016

Selenium webdriver navigate commands

Selenium web driver navigate commands:
================================
we are going to discuss about various navigate  commands that we would be using in our day to day life in testing.

Navigate commands
==============



1.navigate().to():
==================

syntax:

public Navigate To(String url):
-------------------------------
This command is like get() command. It opens a new browser window and it will opens the page that you have given.

2.navigate().refresh():
==============

syntax:

public Navigate refresh():
--------------------------
 This command is used to refresh the current page.

3.public Navigate back():
=========================

syntax:

4.public Navigate  forward():
=====================
Takes you forward by one page on the browser's history.


Example:
==========

package newselenium.topics;

import java.util.concurrent.TimeUnit;


import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class BrowserCommandsDemo {


public static void main(String[] args) {


WebDriver webDriver = new FirefoxDriver();
webDriver.manage().window().maximize();
webDriver.manage().deleteAllCookies();
webDriver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS);

webDriver.navigate().to("https://www.google.com");


webDriver.findElement(By.id("Email")).clear();
webDriver.findElement(By.id("Email")).sendKeys("rameshat914@gmail.com");

webDriver.findElement(By.id("next")).click();

webDriver.findElement(By.id("Passwd")).clear();
webDriver.findElement(By.id("Passwd")).sendKeys("rameshat");

webDriver.findElement(By.id("signIn")).click();

webDriver.navigate().refresh();

webDriver.navigate().back();

webDriver.quit();
}
}






No comments:

Post a Comment