Selenium Notes 1
Selenium Notes 1
if UI is in Android/ IOS
==> Appium
If UI is in React Js or Node Js
==>Protractor
Selenium-2:
RC + WebDriver
Selenium-3.x:
WebDriver:enhancememnt is UI interaction, accessing and contr0ling
Works on a protocol Json Wire Protocol
Selenium 4:
W3 constorium protocol
More Locators are introduced
take screen shot on field level, earlier it was on page level
Maven:
Project Build Tool
Import/ download all dependencies
Packaging:jar/war/ear
Version:
Select WebElement:
we have 8 selectors by which we can select web element
1. id ----(priority-1)
2. name -- (prio-3)
3. css-selector --(priority-2) #id, .class
4. xpath-- absolute path, relative path(recomd.) (prio-2)
5. tagname
6. class name
7. link text -- <a>
8. partiallink text <a>
e.g:
//input[@name='q']
//input[contains(@name, 'q')]
By.id("test_123")
after refreshing test_678, test_jdjf, test_34553
//input[contains(@id, 'test_')]
Switching Command:
Switch to Frame:
driver.switchTo().frame(String fname)
driver.switchTo().frame(int index)
driver.switchTo().frame(WebElement)
Switch to Alert
Switch to Window
====================================
Waits in Selenium:
Threre are two types of wait
1. Unconditional wait:
1. Thread.sleep() ---> Not-recomd
2. implicit wait: ---> works on driver itself
2. Conditional wait:
There are two Conditional Waits
1. Explicit Wait:
1. WebDriverWait-- It is applicable for only one WebElement
2. Fluent wait
=====================================
isEnable()
isDiplayed()
isSelected()
================================
Navigation:
driver.navigate().to(url)
driver.navigate().back();
driver.navigate.forward();
driver.navigate().refresh();
===================================
//if multiple action is to combine and perform the action then build is
required
action.clickandHold(WebElement)
.moveToElement(WebElement)
.release()
.build()
.perform()
OR
action.sendKeys(Keys.ARROW_DOWN).perform();
action.sendKeys(Keys.ARROW_DOWN).perform();
action.sendKeys(Keys.ARROW_DOWN).perform();
action.sendKeys(Keys.ENTER).perform();
=================================
Junit--Unit Testing
--------------
1) Add extent dependency(extentreport aventstack)
2) Create one utility class that will generate Extent Report
Step:
onTestSuccess
onTestFail
onTestSkipped