Selenium 28: Selenium WebDriver Commands

preview_player
Показать описание
Selenium WebDriver Commands Or Methods to write Selenium Test Cases, Selenium WebDriver Browser Commands, Browser Navigation Commands, WebDriver commands on general Web Elements, and Selenium WebDriver verification commands. Selenium Webdriver get(), getCurrentUrl(), getTitle(), findElement, sendKeys, clear(), click, isDisplayed(), isEnabled(), and isselected Commands.
Рекомендации по теме
Комментарии
Автор

Class Notes:
Selenium Class 28: Selenium WebDriver Commands / Methods

> Selenium WebDriver Commands are used to perform operations on Web Elements
> Using Element Locators and WebDriver Commands we can create Test Cases...

Categories of WebDriver Commands:

a) Browser regular commands
b) Browser navigation commands
c) Regular Commands on Web Elements
d) Verification Commands on Web Elements
e) Others

1) get()

Description: Opens a specified URL in the Browser Window.

Syntax:
driverObject.get("URL");

Example:

2) getTitle()

Description: Returns the current Browser Title

Syntax:
String browserTitle = driver.getTitle();

Example:
WebDriver driver = new FirefoxDriver();
String browserTitle = driver.getTitle();


3) getCurrentUrl()

Description: Returns current URL of the Browser window

Syntax:
String browserURL = driver.getCurrentUrl();

Example:
String browserUrl = driver.getCurrentUrl();


Browser navigation Methods

4) navigate().to()

Loads a new page in the current Browser window

Syntax:
driver.navigate().to("URL");

Example:
WebDriver driver = new FirefoxDriver();
String browserUrl = driver.getCurrentUrl();


browserUrl = driver.getCurrentUrl();


or

WebDriver driver = new FirefoxDriver();
String browserUrl = driver.getCurrentUrl();


browserUrl = driver.getCurrentUrl();


5) navigate().back();

It moves a single item back in the browser history

Syntax:

driver.navigate().back();

Example:
driver.navigate().back();


Or


6) navigate().forward()

It moves a single item forward in the browser history

Syntax:

driver.navigate().forword();

Example:

WebDriver driver = new FirefoxDriver();


driver.navigate().back();

driver.navigate().forward();


Or
WebDriver driver = new FirefoxDriver();





7) navigate().refresh()

Syntax:
driver.navigate().refresh();

Example:
WebDriver driver = new FirefoxDriver();
driver.navigate().refresh();

8) close()

Closes the focused Browser

Syntax:
driver.close();

Example:
WebDriver driver = new FirefoxDriver();
Thread.sleep(4000);
driver.close();

9) quit()

Closess all Browsers that opened by WebDriver during Execution.

Syntax:
driver.quit();

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

UFT vs. Selenium - in case of Browser or AUT,

Test Operations:
i) Launch Browser and navigate to Google Home page
ii) Click on "Gmail" Link

UFT Script:


Or


Selenium Test Script

WebDriver driver= new FirefoxDriver();


* In Selenium, we can't Set Base state, using seleneium Test script only we can perform operations...

10) findElement()

Finds first Element within the Current web page using give locator.

Syntax:
- Partial Syntax,


Example:


Or

Or


11) sendkeys()

Enter a value in to an Edit Box or Text Box

Syntax:
/ Input Data");
Note: If the Input Data is String then use "", suppose your passing parameters then don't use "'...

Example:

Or
String Username = "India123";


12) clear()

Clears the Value from edit Box

Syntax:


Example:

Thread.sleep(5000);


13) click()

Clicks an Element (Button, Link, Radio Button, Check box...)

Syntax:


Examples:

WebDriver driver = new FirefoxDriver();
Thread.sleep(3000);

Thread.sleep(3000);

Thread.sleep(3000);
Thread.sleep(3000);


gcreddy
Автор

Hi Sir,

I had watched many of your videos and they are very good with clear explanation. I have gone through your TestNG frame work and Data driven framework which are explained clearly, but I want to learn Hybrid framework(data driven frame + keyword driven framework). So, can you let me know whether you will be uploading videos for Key word driven framework and Hybrid framework in your videos.Waiting eagerly for the response.

Thx

laxmic