Selenium Tutorial 18: WebDriver Commands and Operations

preview_player
Показать описание
Selenium WebDriver Methods tutorial explains Webdriver commands and operations with examples. Selenium Webdriver Browser methods, Browser navigation methods, methods on web elements and other methods. Selenium WebDriver methods for performing operations on Web Elements.
Рекомендации по теме
Комментарии
Автор

You make Selenium easy to understand. You stand out to me as the best i have heard from. Very thorough and simple in approach. Thanks Reddy!

mcseagate
Автор

Class Notes:
Selenium Class 18: Selenium WebDriver Methods

> Selenium WebDriver Methods are used to perform operations on Web Elements.

> Using Element Locators and WebDriver Methods we create Test Cases.

Element Locators - for recognizing Elements

WebDriver Methods - for performing operations on Elements.

1) get()

Description: Opens a specified URL in the Browser window.

Syntax:

driverObject.get("URL");

Example:


2) getTitle()

Returns Title of the Browser.

Syntax:

String variable = driver.getTitle();

Example:

String Title = driver.getTitle();
System.out.println(Title);

3) getPageSource()

Returns HTML page source.

Syntax:

String stringName = driver.getPageSource();

Example:

String pageSource = driver.getPageSource();


4) getCurrentUrl();

Returns Current URL of the Browser.

Syntax:

String stringName = driver.getCurrentUrl();

Example:
String URL = driver.getCurrentUrl();
System.out.println(URL);

Browser Navigation Methods

5) navigate().to();

Loads a new web page in the current browser window.

Syntax:


Example:

String URL = driver.getCurrentUrl();
System.out.println(URL);
URL = driver.getCurrentUrl();
System.out.println(URL);

6) navigate().back()

It moves a single item back in the Browser history.

Syntax:

driver.navigate().back();

Example:

String URL = driver.getCurrentUrl();
System.out.println(URL);
URL = driver.getCurrentUrl();
System.out.println(URL);
driver.navigate().back();
URL = driver.getCurrentUrl();
System.out.println(URL);

Or

String URL = driver.getCurrentUrl();
System.out.println(URL);
URL = driver.getCurrentUrl();
System.out.println(URL);
URL = driver.getCurrentUrl();
System.out.println(URL);

7) navigate().forward();

It moves single item forward in the Browser history.

Syntax:

driver.navigate().forward();

Example:

String URL = driver.getCurrentUrl();
System.out.println(URL);

URL = driver.getCurrentUrl();
System.out.println(URL);

driver.navigate().back();
URL = driver.getCurrentUrl();
System.out.println(URL);

driver.navigate().forward();
URL = driver.getCurrentUrl();
System.out.println(URL);

Or

String URL = driver.getCurrentUrl();
System.out.println(URL);

URL = driver.getCurrentUrl();
System.out.println(URL);

URL = driver.getCurrentUrl();
System.out.println(URL);

URL = driver.getCurrentUrl();
System.out.println(URL);

8) navigate().refresh()

Refresh the current web page

Syntax:

driver.navigate().refresh()

WebDriver driver = new FirefoxDriver();
String URL = driver.getCurrentUrl();
System.out.println(URL);
driver.navigate().refresh();
URL = driver.getCurrentUrl();
System.out.println(URL);

Method Syntax in Java

Object.method();
Object.property().method();
Class.method();

9) close()

It closes the focused Browser.

Syntax:

driverObject.close();

Example:

driver.close();

10) quit()

It closes all browser that opened by WebDriver during execution.

Syntax:

driverObject.quit();

Example:

In")).click();
driver.quit();

11) findElement()

It finds the first element within the current page using the give locator.



Syntax:
WebDriver driver = new FirefoxDriver();


Or

WebElement Email =
Email.sendKeys("India");

12) sendkeys()

Enters a value into Edit box/Text box

Syntax:
data");

Example:


}

13) clear()

It clears the value

Syntax:


Example:

Thread.sleep(5000);


14) click()

Clicks an Element (Buttons, Links)

Syntax:



Example:



15) isEnabled()

It checks weather the Element is in enabled state or not?

Syntax:

boolean variableName =

Example:

boolean a =
System.out.println(a);

16) isDisplayed()

Checks if the Element is displayed or not? in the current web page.

Syntax:

boolean variableName =

boolean a =
System.out.println(a);

17) isSelected()

checks if the Element is Selected or not? in the current web page.

Syntax:

boolean variableName =

example:

boolean a =
System.out.println(a);//false

a =
System.out.println(a);//true

18) manage().window().maximize()

Syntax:



Example:

Thread.sleep(5000);


gcreddy
Автор

Gc Reddy Sir thanks a lot for such a good and cool explanation on each topic.Non technical person also can understand very easily Hats off sir

sai
Автор

Very good and very well explained. Nice work G.C. Reddy :)

grvlal
Автор

Thank you very much Sir! you have a very good method teaching, Great Guy!!!

qaisqais
Автор

When navigating to another page on the same browser, you did not allow the page to load before closing it. That was the reason it keeps generating errors when you were trying to get the current URL.

hennymakaveli
Автор

Sir Really useful and explained everything, very nice video

manishkadam
Автор

In the driver.quit() part, why were you not explaining to the students the purpose of adding Thread.Sleep and the throw declaration?

BienRV
Автор

Great work sir, if you get a chance sir can you teach us Cucumber, Jenkins, Jausng.

AbdulKhan-oemk
Автор

In navigate.back() method is it possible to go back at a particular link or it is possible only to view the last page @G C Reddy

Sadhana
Автор

just wanted to know did you find what was the problem with null pointer exception coming when you were using driver.quit() to close all the browser s?

devsenapati
Автор

hello sir, thanks for your effort. I have one doubt among get and navigate, if both does the same why do we have two commands. whats the special use and which scenarios we use perticular method . thanks in advance sir

saleem
Автор

hello sir,
Your videos are very understandable sir.Thank you sir

onlymathstutorialpoint
Автор


Just wanted to know when we launch the browser using get() gets launched in maximize what is the need of manage.window.maximize() method

rakshitasehgal
Автор

tutorial is very good and helpful .thanks for the video but driver.close() and sendKeys method is not working.I am using selenium 3.3 and firefox 53.Please help

richasingh
Автор

this is the answer to your question for minimizing the window
Dimension windowMinSize = new Dimension(100, 100);


I have tried this it is working in my system.

skp
Автор

it's really easy to understand...Thank you sir

ManiKandan-kgky
Автор

Thank u sir for your deep explanaction and also for notes

abdussami
Автор

Class note link is not working. can you please upload again. Thanks

ajitce
Автор

First of all, A Big thank sir.
In this session You are getting some problem for "Navigate" method, some text were sometimes appeared in Red color in eclipse console. Kind of same thing happening with all time. Anyway everything is working properly but don't know why that red lines is coming in console.
Can you please help.

kuldeepsinghchouhan