Selenium Quick Tutorial 5: Selenium WebDriver

preview_player
Показать описание
Selenium WebDriver Quick Tutorial, Introduction to Selenium WebDriver, Selenium WebDriver Environment Setup, Element locators in Selenium, Selenium WebDriver API Commands, and write first Selenium Test Case.
Рекомендации по теме
Комментарии
Автор

Class Notes:

Selenium WebDriver Quick Tutorial By G C Reddy

i) Introduction to Selenium WebDriver

ii) Selenium WebDriver Environment Setup

iii) Web Elements and Operations

iv) Element Locators

v) WebDriver API Commands

i) Introduction to Selenium WebDriver

> Selenium WebDriver is a programming Interface, no IDE

> Selenium WebDriver supports various Programming Languages to write programs (Test Scripts)

> Selenium WebDriver supports various Operating Environments.

> Selenium WebDriver supports various Browsers to create and execute Test Cases.

> Using Element Locators and WebDriver Commands we can create Test Cases.

> Its support Batch Testing, Cross Browser Testing and Data Driven Testing

> It doesn't have IDE, so difficult to create Test cases and takes more time.

> It doesn't have built-in Result Reporting facility.

> No Tool integration for Test Management.

ii) Selenium WebDriver Environment Setup

Steps:

i) Download and install Java (JDK) software. - To create and execute programs (Test scripts)

ii) Download Eclipse IDE and extract. - To write and execute Java programs.

iii) Download Selenium WebDriver Java Language binding (from www.seleniumhq.org) and add WebDriver jar files to Java project in Eclipse IDE.

v) Firefox Driver is default driver in Selenium Webdriver, for IE, Chrome and Safari etc... Browsers we need to download browser drivers and set path.

Manual Test Case:

Test Case ID: gcrshop_admin_TC001

Test Case Name: Verify Admin Login in GCR Shop web portal

Test Steps:
i) Launch the Browser and navigate to "www.gcrit.com/build3/admin"
ii) Enter User name
iii) Enter Password
iv) Click "Login" Button

Input Data / Test Data:
User name =admin

Expected URL:


Test Result: Pass

Selenium WebDriver Test Case:

public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();//Launches Firefox Browser with blank url.



String url = driver.getCurrentUrl();

System.out.println("Login Successful - Passed");
}
else {
System.out.println("Login Unsuccessful - Failed");
}
driver.close();//Closes the Browser
}
}

iii) Web Elements and Operations on Elements

a) WebElements
Browser
Page

Edit box
Link
Button
Image, Image Link, Image Button
Text Area
Check box
Radio Button
Drop down box
List box
Combo box
Web Table/ HTML Table
Frame
Etc..
b) .

iv) Element Locators

What is Locator?

> It is an address that identifies a Web element uniquely within the page.

Selenium supports 8 Element locators to recognize elements in web pages.

id,

name,

className,

tagName,

linkText,

partialLinkText,

cssSelector,

xpath

Syntax:

By.elementLocator("element locator value")

Example:



driver -Browser Object

findElement- WebDriver Method / Command

By - Built in Class

id - Locator

Email - Value

sendKeys -WebDriver Method / Command

India - Input Data

Examples:














v) WebDriver Commands / Methods

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

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

Element Locators - To recognize / Identify Elements

WebDriver Methods - To perform operations on Elements

1) get() - Opens a specified URL in the Browser window.


2) getTitle() - Returns the Browser Title.

String Title = driver.getTitle();

3) getCurrentUrl() - Returns Current URL of the Browser

String Url = driver.getCurrentUrl();

4) navigate().to() - Loads a new page in the current browser window.


5) navigate().back() - It moves a single item back in the Browser history.

driver.navigate().back();

6) navigate().forward() - It moves single item forward in the browser history.

driver.navigate().forward();

7) navigate().refresh() - Refreshes the Current web page


8) close() - Closes the focused Browser.

driver.close();

9) findElement() - Finds the first Element within the current page using given locator.



10) sendKeys() - Enters a value into Edit box/Text box.


11) clear() - It clears the value from Edit box



12) click() - Clicks an Element (Buttons, Links etc...)



13) isEnabled() - Checks weather the Element is in Enabled state or not?

boolean a =

14) isDisplayed() - Checks weather the Element is displayed or not?

boolean a =

15) isSelected() - Checks weather the Element is selected or not?

boolean after =

gcreddy
visit shbcf.ru