Android apps to use in appium android test examples

Breaking

Thursday, July 12, 2018

Selenium WebDriver Quick Tutorial

Selenium WebDriver Quick Tutorial

i) Introduction to Selenium WebDriver

ii) Selenium WebDriver Environment Setup

iii) Web Elements too Operations

iv) Element Locators

v) WebDriver API Commands
------------------------------------------------
i) Introduction to Selenium WebDriver

> Selenium WebDriver is a programming Interface, no IDE

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

> Selenium WebDriver supports diverse Operating Environments.

> Selenium WebDriver supports diverse Browsers to exercise too execute Test Cases.

> Using Element Locators too WebDriver Commands nosotros tin terminate exercise Test Cases.

> Its back upward Batch Testing, Cross Browser Testing too Data Driven Testing
--------------------------------
Drawbacks of Selenium WebDriver

> It doesn't cause got IDE, too then hard to exercise Test cases too takes to a greater extent than time.

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

> No Tool integration for Test Management.
------------------------------------------------
ii) Selenium WebDriver Environment Setup

Steps:

i) Download too install Java (JDK) software. - To exercise too execute programs (Test scripts)

ii) Download Eclipse IDE too extract. - To write too execute Java programs.
----------------------------------
iii) Download Selenium WebDriver Java Language binding (from www.seleniumhq.org) too add together WebDriver jounce files to Java projection inwards Eclipse IDE.
------------------------------------------------  
v) Firefox Driver is default driver inwards Selenium Webdriver, for IE, Chrome too Safari etc... Browsers nosotros ask to download browser drivers too gear upward path.
--------------------------------------------
Manual Test Case:

Test Case ID: gcrshop_admin_TC001

Test Case Name: Verify Admin Login inwards GCR Shop spider web portal

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

Input Data / Test Data:
User cite =admin
Password = admin@123

Verification Point:
Capture the Url (Actual) afterwards Login to Application too Compare amongst Expected.

Expected URL: "www.gcrit.com/build3/admin/index.php"

Test Result: 
------------------------------------------------
1) Element Locators - To Identify the Elements

Example for Elements: Link, edit box, Button etc...
Examples for Operations on Elements: Click, Enter a Value, Check, select etc...

2) WebDriver Commands - Perform Operations on Elements

3) Java Programming - To heighten Test cases
-------------------------------------------------------------
Object / Element Property/Locator Value
Man name Santosh
height 6
-------------------------------------------------------------
Object name abc
Dog color white
weight 5
-------------------------------------------------------------
Edit box name Email
Button id tdb1
-------------------------------------------------------------
Selenium WebDriver Test Case:

public static void main(String[] args) {
WebDriver driver = novel FirefoxDriver();//Launches Firefox Browser amongst blank url.
driver.get("http://www.gcrit.com/build3/admin/login.php");//Naviage to Admin domicile page
driver.findElement(By.name("username")).sendKeys("admin");
driver.findElement(By.name("password")).sendKeys("admin@123");
driver.findElement(By.id("tdb1")).click();

String url = driver.getCurrentUrl();

if (url.equals("http://www.gcrit.com/build3/admin/index.php")){
System.out.println("Login Successful - Passed");
}
else {
System.out.println("Login Unsuccessful - Failed");
}
driver.close();//Closes the Browser
}
}
------------------------------------------------
iii) Web Elements too Operations on Elements

a) WebElements

Browser
Page
----------------
Edit box
Link
Button
Image, Image Link, Image Button
Text Area
Check box
Radio Button
Drop downward box
List box
Combo box
Web Table/ HTML Table
Frame 
Etc..
-------------------------------
b) Operations on Elements

i) Browser
(Launch Browser, Navigate to specified URL, Navigate back, Navigate forward, refresh, closed Browser....)

ii) Page
(Return Page Title, Return Page URL...)

iii) Link
(Click, Check the existence, Check Enabled condition ....)

iv) Button

(Click, Check Displayed status, Enabled status, provide push cite ....)

v) Image
a) General Image (Return Image Title etc...
b) Image Button (Click, Check Displayed status, Enabled status, provide push cite ....)
c) Image Link (Click, Check the existence, Check Enabled condition ....)

vi) Text Area / Error Message

(Return Text Area/ Return Error Message etc...)

vii) Radio Button
(Check Displayed status, Enabled status, Select....)

viii) Check box
(Check Displayed status, Enabled status, Select, Unselect, cheque Selected status....)

ix) Drop downward box
(Check Displayed status, Enabled status, Select an Item, Get Items Count ....)

x) List Box
(Check Displayed status, Enabled status, Select i or to a greater extent than Items, Get Items Count ....)

xi) Combo box 
(Check Displayed status, Enabled status, Select an Item, Enter an Item, Get Items Count ....)

xii) Web Table
(Return specified Cell value, Return Rows Count, Column Count etc...)

xiii) Frame 
(Switch from Top window to specified frame, Frame to Top window

inLine Elements
------------------------------------------------
iv) Element Locators

What is Locator?

> It is an address that identifies a Web chemical ingredient uniquely inside the page.

Selenium supports 8 Element locators to recognize elements inwards spider web pages.

id,

name,

className,

tagName,

linkText,

partialLinkText,

cssSelector,

xpath
------------------------------------------------
Syntax:

By.elementLocator("element locator value")

Example:

driver.findElement(By.id("Email"))
----------------------------------------------
driver -Browser Object

findElement- WebDriver Method / Command

By - Built inwards Class

id - Locator

Email - Value

sendKeys -WebDriver Method / Command

India - Input Data
------------------------------------------------
Examples:

driver.findElement(By.name("Email")).sendKeys("India");

driver.findElement(By.className("textboxcolor")).sendKeys("India");

driver.findElement(By.tagName("input")).sendKeys("India123");

driver.findElement(By.linkText("Gmail")).click();

driver.findElement(By.partialLinkText("Gma")).click();

driver.findElement(By.cssSelector("#next")).click();

driver.findElement(By.xpath(".//*[@id='Email']")).sendKeys("abcd123");
------------------------------------------------
v) WebDriver Commands / Methods

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

> Using Element Locators too WebDriver Methods nosotros exercise Test Cases.

Element Locators - To recognize / Identify Elements

WebDriver Methods - To perform operations on Elements
------------------------------------------------
Important WebDriver API Commands

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

driver.get("https://www.google.com");
------------------------------------------------
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 novel page inwards the electrical flow browser window.

driver.navigate().to("https://in.yahoo.com");
------------------------------------------------
5) navigate().back() - It moves a unmarried especial dorsum inwards the Browser history.

driver.navigate().back();
------------------------------------------------
6) navigate().forward() - It moves unmarried especial frontwards inwards the browser history.

driver.navigate().forward();
------------------------------------------------
7) navigate().refresh() - Refreshes the Current spider web page

driver.get("https://www.google.com");
------------------------------------------------
8) close() - Closes the focused Browser.

driver.close();
------------------------------------------------
9) findElement() - Finds the get-go Element inside the electrical flow page using given locator.

driver.findElement(By.id("Email")).sendKeys("India123");
------------------------------------------------
10) sendKeys() - Enters a value into Edit box/Text box.

driver.findElement(By.id("Email")).sendKeys("India@123");
------------------------------------------------
11) clear() - It clears the value from Edit box

driver.findElement(By.id("Email")).clear();
------------------------------------------------
12) click() - Clicks an Element (Buttons, Links etc...)

driver.findElement(By.id("next")).click();
------------------------------------------------
13) isEnabled() - Checks conditions the Element is inwards Enabled field or not?

boolean a = driver.findElement(By.id("next")).isEnabled();
------------------------------------------------
14) isDisplayed() - Checks conditions the Element is displayed or not?

boolean a = driver.findElement(By.linkText("Gmail")).isDisplayed();
------------------------------------------------
15) isSelected() - Checks conditions the Element is selected or not?

boolean afterwards = driver.findElement(By.xpath("html/body/input[3]")).isSelected();
------------------------------------------------

Sumber http://www.gcreddy.com/

No comments:

Post a Comment