Web Elements as well as Element Locators
i) Web Elements
ii) Element Locators
---------------------------------------
i) Web Elements
Browser
Page
-----------------
Edit Box
Link
Button
Image, Image Link, Image Button
Text box
Text Area
Check box
Radio Button
Drop downwardly box
List box
Combo box
Web tabular array /HTML table
Frame
-----------------------------------
1) Operations on Browser
> Launch the browser,
> Navigate to item spider web page,
> Close focused Browser
> Close all Browsers that opened past times WebDriver during execution
---------------
> Navigate from ane URL to another
> Navigate dorsum to previous URL
> Navigate forward
> Refresh the Browser
> Maximize the Browser
Etc...
-----------------------------------
2) Operations on Web Page
> Get Page Title
> Get Page URL
-----------------------------------
3) Operations on Edit box
> Enter a Value,
> Clear the Value,
> Check enabled status,
> Check edit box existence,
> Get the value etc...
-----------------------------------
4) Operations on Link
> Click Link,
> Check the link existence,
> Check the link enabled status,
> Return the Link Name
Etc...
-----------------------------------
5) Operations on Button
> Click
> Check Enabled status
> Display status
Etc...
-----------------------------------
6) Operations Image
Three types of Image elements inwards Web Environment
a) General Image (No functionality)
b) Image Button (Submits)
c) Image Link (Redirects to roughly other page/location)
-----------------------------------
7) Operations on Text Area
> Return / Capture Text Area or Error message from a spider web page
-----------------------------------
8) Operations on Check box
> Check if the depository fiscal establishment jibe box is displayed or not?
> Check if the depository fiscal establishment jibe box is enabled or not?
> Check if the depository fiscal establishment jibe box is Selected or not?
> Select the Check box
> Unselect the Check box
-----------------------------------
9) Operations on Radio Button
> Select Radio Button
> Verify if the Radio Button is Displayed or not?
> Verify if the Radio Button is enabled or not?
> Verify if the Radio Button is Selected or not?
------------------------------------
10) Operations on Drop downwardly box
> Check the Drop downwardly box existence
> Check if the Drop downwardly is enabled or not?
> Select an item
> Items Count
-----------------------------------
11) Operations on List box
12) Operations on Combo box
-----------------------------------
13) Operations on Web tabular array /HTML Table
> Get jail cellular telephone value
> Rows Count
> Cells Count Etc...
-----------------------------------
14) Operations on Frame
-----------------------------------
> Switch from Top window to a frame
> Switch from a frame to Top window
Etc...
----------------------------------------------
ii) Element Locators
What is Locator?
> Locator is an address that identifies a spider web chemical cistron uniquely inside the webpage. Locators are the HTML properties of a spider web element.
Selenium WebDriver uses 8 chemical cistron locators
id,
name,
className,
tagName,
linkText,
partialLinkText,
cssSelector,
xpath
to discovery elements on Web pages.
Why nosotros take away to work unlike locators?
1) Developers may non supply all locators for all elements
2) Some locators may endure duplicated.
So nosotros bring to direct whatever ane unique locator to recognize the element.
How to inspect elements?
Download as well as install Firebug as well as Firepath plug ins/Add ons for Firefox Browser.
If it Internet Explorer or Chrome, nosotros no take away to install whatever Add on, they supply built -in Developer Tools (F12) to inspect elements.
Element Locators are mutual for all Browsers.
-----------------------------------------
1) id
Syntax:
By.id("id value")
Examples:
driver.findElement(By.id("Email"))
driver- is Object
findElement - WebDriver method
By - pre-defined Class
id - Element locater
Email - id locator value
-------------------------------------
driver.findElement(By.id("Email")).sendKeys("gcrindia");
--------------------------------------------
Or
WebElement Email = driver.findElement(By.id("Email"));
Email.sendKeys("gcrindia");
-------------------------------------------
id locator for Button
WebElement Email = driver.findElement(By.id("signIn"));
Email.click();
Or
driver.findElement(By.id("signIn")).click();
-------------------------------------------------------
2) name
Synatx:
By.name("name value/locator name")
Examples:
driver.findElement(By.name("Email")).sendKeys("gcrindia");
Or
WebElement e = driver.findElement(By.name("Email"));
e.sendKeys("gcrindia");
------------------------------------------
WebElement e = driver.findElement(By.name("signIn"));
e.click();
------------------------------------------
3) className
Syntax: By.className("class cite value")
Example:
driver.findElement(By.className("textboxcolor")).sendKeys("Hyderabad");
----------------------------------------------
4) tagName
Syntax:
By.tagName("tag cite value")
Example:
driver.findElement(By.tagName("input")).sendKeys("Hyderabad");
--------------------------------------------------------------
5) linkText
Syntax:
By.linkText("Link Text Value")
Example:
driver.findElement(By.linkText("Gmail")).click();
-----------------------------------------------------
6) paritialLinkText
Syntax:
By.partialLinkText("Partial Link Text Value")
Example:
driver.findElement(By.partialLinkText("Gma")).click();
-----------------------------------------------
7) cssSelector
Syntax:
By.cssSelector("value")
Example:
driver.findElement(By.cssSelector(".gb_m")).click();
---------------------------------------------------
8) xpath
Xpath inwards XML document shows the direction of software spider web application's chemical cistron location.
Syntax:
By.xpath("xpath value")
driver.findElement(By.xpath(".//*[@id='Email']")).sendKeys("abcdef");
------------------------------------------------------------------------------
i) Web Elements
ii) Element Locators
---------------------------------------
i) Web Elements
Browser
Page
-----------------
Edit Box
Link
Button
Image, Image Link, Image Button
Text box
Text Area
Check box
Radio Button
Drop downwardly box
List box
Combo box
Web tabular array /HTML table
Frame
-----------------------------------
1) Operations on Browser
> Launch the browser,
> Navigate to item spider web page,
> Close focused Browser
> Close all Browsers that opened past times WebDriver during execution
---------------
> Navigate from ane URL to another
> Navigate dorsum to previous URL
> Navigate forward
> Refresh the Browser
> Maximize the Browser
Etc...
-----------------------------------
2) Operations on Web Page
> Get Page Title
> Get Page URL
-----------------------------------
3) Operations on Edit box
> Enter a Value,
> Clear the Value,
> Check enabled status,
> Check edit box existence,
> Get the value etc...
-----------------------------------
4) Operations on Link
> Click Link,
> Check the link existence,
> Check the link enabled status,
> Return the Link Name
Etc...
-----------------------------------
5) Operations on Button
> Click
> Check Enabled status
> Display status
Etc...
-----------------------------------
6) Operations Image
Three types of Image elements inwards Web Environment
a) General Image (No functionality)
b) Image Button (Submits)
c) Image Link (Redirects to roughly other page/location)
-----------------------------------
7) Operations on Text Area
> Return / Capture Text Area or Error message from a spider web page
-----------------------------------
8) Operations on Check box
> Check if the depository fiscal establishment jibe box is displayed or not?
> Check if the depository fiscal establishment jibe box is enabled or not?
> Check if the depository fiscal establishment jibe box is Selected or not?
> Select the Check box
> Unselect the Check box
-----------------------------------
9) Operations on Radio Button
> Select Radio Button
> Verify if the Radio Button is Displayed or not?
> Verify if the Radio Button is enabled or not?
> Verify if the Radio Button is Selected or not?
------------------------------------
10) Operations on Drop downwardly box
> Check the Drop downwardly box existence
> Check if the Drop downwardly is enabled or not?
> Select an item
> Items Count
-----------------------------------
11) Operations on List box
12) Operations on Combo box
-----------------------------------
13) Operations on Web tabular array /HTML Table
> Get jail cellular telephone value
> Rows Count
> Cells Count Etc...
-----------------------------------
14) Operations on Frame
-----------------------------------
> Switch from Top window to a frame
> Switch from a frame to Top window
Etc...
----------------------------------------------
ii) Element Locators
What is Locator?
> Locator is an address that identifies a spider web chemical cistron uniquely inside the webpage. Locators are the HTML properties of a spider web element.
Selenium WebDriver uses 8 chemical cistron locators
id,
name,
className,
tagName,
linkText,
partialLinkText,
cssSelector,
xpath
to discovery elements on Web pages.
Why nosotros take away to work unlike locators?
1) Developers may non supply all locators for all elements
2) Some locators may endure duplicated.
So nosotros bring to direct whatever ane unique locator to recognize the element.
How to inspect elements?
Download as well as install Firebug as well as Firepath plug ins/Add ons for Firefox Browser.
If it Internet Explorer or Chrome, nosotros no take away to install whatever Add on, they supply built -in Developer Tools (F12) to inspect elements.
Element Locators are mutual for all Browsers.
-----------------------------------------
1) id
Syntax:
By.id("id value")
Examples:
driver.findElement(By.id("Email"))
driver- is Object
findElement - WebDriver method
By - pre-defined Class
id - Element locater
Email - id locator value
-------------------------------------
driver.findElement(By.id("Email")).sendKeys("gcrindia");
--------------------------------------------
Or
WebElement Email = driver.findElement(By.id("Email"));
Email.sendKeys("gcrindia");
-------------------------------------------
id locator for Button
WebElement Email = driver.findElement(By.id("signIn"));
Email.click();
Or
driver.findElement(By.id("signIn")).click();
-------------------------------------------------------
2) name
Synatx:
By.name("name value/locator name")
Examples:
driver.findElement(By.name("Email")).sendKeys("gcrindia");
Or
WebElement e = driver.findElement(By.name("Email"));
e.sendKeys("gcrindia");
------------------------------------------
WebElement e = driver.findElement(By.name("signIn"));
e.click();
------------------------------------------
3) className
Syntax: By.className("class cite value")
Example:
driver.findElement(By.className("textboxcolor")).sendKeys("Hyderabad");
----------------------------------------------
4) tagName
Syntax:
By.tagName("tag cite value")
Example:
driver.findElement(By.tagName("input")).sendKeys("Hyderabad");
--------------------------------------------------------------
5) linkText
Syntax:
By.linkText("Link Text Value")
Example:
driver.findElement(By.linkText("Gmail")).click();
-----------------------------------------------------
6) paritialLinkText
Syntax:
By.partialLinkText("Partial Link Text Value")
Example:
driver.findElement(By.partialLinkText("Gma")).click();
-----------------------------------------------
7) cssSelector
Syntax:
By.cssSelector("value")
Example:
driver.findElement(By.cssSelector(".gb_m")).click();
---------------------------------------------------
8) xpath
Xpath inwards XML document shows the direction of software spider web application's chemical cistron location.
Syntax:
By.xpath("xpath value")
driver.findElement(By.xpath(".//*[@id='Email']")).sendKeys("abcdef");
------------------------------------------------------------------------------