Selenium Class 25 - Handling Elements in Selenium

preview_player
Показать описание
Element Handling in Selenium WebDriver using Element Locators and WebDriver API Commands and prerequisites for writing Selenium Test Cases.
Writing Selenium Test Steps using Element Locators and WebDriver API Commands and Perform Test Operations on Web Elements using WebDriver API Commands.
Types of Elements in Web Applications/Web Environment, Operations on the Web Elements using Selenium. Element Locators in Selenium, What is Element Locator?, Types of Element locators in Selenium, and How to identify & use unique element locator in Selenium.
Automated Testing using Selenium WebDriver and Java Programming, Inspect Web Elements using browser built-in developer tools, recognize the elements and perform Test operations on the Web Elements.
Рекомендации по теме
Комментарии
Автор

Class Notes:
Selenium Class 25: Handling Elements in Selenium

Prerequisites to create Test Cases in Selenium WebDriver

i) Element Locators - to identify Elements in Web Pages
ii) Selenium WebDriver Commands - to perform Operations on the Web Elements

iii) Programming (Java or Python etc...)- to write Test Scripts/to enhance Test Scripts
iv) Testing Framework (either JUnit or TestNG) - to group Test cases, prioritizing Test Cases,
execute Test Batches and generate Test Reports.

Selenium WebDriver API commands Cont...

10) sendKeys()

Enter a value in to an Edit box or Text box

Syntax:


Example:

System.setProperty("webdriver.chrome.driver", "E:/chromedriver.exe");
WebDriver driver = new ChromeDriver();

//Or


11) clear()

Clears the value from Edit box/Text box

Syntax:


Example:
System.setProperty("webdriver.chrome.driver", "E:/chromedriver.exe");
WebDriver driver = new ChromeDriver();

Thread.sleep(5000);


//Or
WebElement
editBox.sendKeys("India123");
Thread.sleep(6000);
editBox.clear();

12) click()

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

Syntax:
Command/click();

Examples:
System.setProperty("webdriver.chrome.driver", "E:/chromedriver.exe");
WebDriver driver = new ChromeDriver();

Thread.sleep(4000);
//Click Command on Link Element

Thread.sleep(4000);
//Click Command on Button Element

Thread.sleep(4000);
//Click Command on Radio Button

Thread.sleep(4000);
//Click Command on Check Box(Select Operation)
Thread.sleep(4000);
//Click Command on Check Box(Unselect Operation)
Thread.sleep(4000);
driver.close();
}
}

Verification Commands

13) isDisplayed()
Checks weather the element is displayed or not in the current web page
It returns Boolean result, display status is true means visible....
It is applicable only on all type of Elements

Syntax:
boolean displayStatus = Command/isDisplayed();

Example:
System.setProperty("webdriver.chrome.driver", "E:/chromedriver.exe");
WebDriver driver = new ChromeDriver();
boolean


14) isEnabled()

Checks weather the element is Enabled or not?
It is applicable only on all type of Elements

Syntax:
boolean displayStatus = Command/isEnabled();

Example:
System.setProperty("webdriver.chrome.driver", "E:/chromedriver.exe");
WebDriver driver = new ChromeDriver();
boolean

Thread.sleep(3000);

boolean



Thread.sleep(3000);

System.out.println(xyz);
driver.close();
}
}

15) isSelected()

Checks weather the element is selected or not?
It is applicable only on Radio Buttons, and Check Boxes

Syntax:
boolean displayStatus = Command/isSelected();

Example:
System.setProperty("webdriver.chrome.driver", "E:/chromedriver.exe");
WebDriver driver = new ChromeDriver();

boolean selectedStaus



selectedStaus


driver.close();

Handling Elements in Selenium
i) Web Elements
Browser,
Page

Link,
Button,
Edit Box,
Text Box,
Text Area, Help Message, Error message, Popup Window (*Popup is not a web element)
Image, Image Button, Image Link,
Radio Button,
Check Box,
Drop down Box,
List Box
Combo box,
Web Table / HTML Table,
Frame etc....

ii) Element Locators

1) id
2) name
3) className
4) tagName
5) linkText
6) partialLinkText
7) cssSelector
8) xpath

iii) WebDriver API Commands
a) Browser Regular methods
1) get()
2) getTitle()
3) getCurrentUrl()
5) getWindowHandle()
6) getPageSource()
7) close()
8) quit()

b) Browser Navigation commands
9) navigate().to()
10) navigate().back()
11) navigate().forward()
12) navigate().refresh()

c) Regular Commands on Elements
13) findElement()
14) findElements()
15) sendKeys()
16) clear()
17) click()
18) getText()
19) getAttribute()

d) Verification Commands
20) isDisplayed()
21) isEnabled()
22) isSelected()

Others:
23) manage().window().maximize()
24) explicitlyWait()

iv) Java Programming (Java Standard Edition / Core Java)

1) Comments
2) Data Types
3) Modifiers
4) Variables
5) Operators
6) Control Flow Statements
a) Conditional Statements
b) Loop Statements
c) Branching Statements
7) Strings
8) Arrays, ArrayList
9) IO Operations, File Handling
10) Methods
a) Predefined Methods
b) User defined Methods
11) Exception Handling
12) Java Object Oriented Programming
a) Inheritance
b) Polymorphism
c) Abstraction
d) Encapsulation

i) Handling Browser

Manual Operations
1) Launch the Browser
2) Navigate to particular URL
3) Return the Browser Title
4) Return the Browser URL
5) Return the Browser Window Handle
6) Navigate to another URL
7) Navigate back to previous URL
8) Navigate forward to next URL
9) Refresh the Browser window
10) Minimize the Browser window
11) Full Screen
12) Close the focused Browser
13) Close all Browsers that opened by Selenium
etc...

Selenium Test Steps:

gcreddy
Автор

Sir scroll down command is there, we can use that to select check box

Mousamastana
Автор

Sir do you have git repository so that I can easily check out the code?

surajrajput-ioub