Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

Selenium:

Developed by the Company Thought Works.


It is open source automation tool suit.
It is available in the form of API(.jar)
It supports multiple

if UI is in Android/ IOS
==> Appium
If UI is in React Js or Node Js
==>Protractor

Selenium has 4 major Components: selenium.dev


1. IDE: plugin-- Firfox Browser, record and play
limit: looping, condtional statement
2. RC-(Remote Control):
Server
3. WebDriver:
4. GRID:Parallel execution of Test

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

<input type='text' name='abc' class='input-design' id='nameid'/>


<a href=''>click</a> partial linkText , xpath --absolute, relative //

Maven:
Project Build Tool
Import/ download all dependencies

Artifact Id:--Project Name---CradsProject


Group-Id:--name of the company
com.capgemini-- package

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>

Writing own Xpath:


======================
1. Xpath should be start with //
2. Then check the tag name
3. Then use properity/attribute with @

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_')]

For Anchor Tag:


//a[contains(text(),'Gmail')]

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();
===================================

Action class in selenium:

Actions action = new Actions(driver);


action.moveToElement(WebElement).perform(); // build is optional for single
operation
or
action.moveToElement(WebElement).build().perform();

//if multiple action is to combine and perform the action then build is
required
action.clickandHold(WebElement)
.moveToElement(WebElement)
.release()
.build()
.perform()

// for double click -- http://demo.guru99.com/test/simple_context_menu.html

WebElement link =driver.findElement(By.xpath("//button[text()='Double-Click


Me To See Alert']"));
action.doubleClick(link).perform();

//Switch to the alert box and click on OK button

Alert alert = driver.switchTo().alert();


System.out.println("Text on Alert" +alert.getText());
alert.accept();

// for right clcik --http://demo.guru99.com/test/simple_context_menu.html

WebElement link = driver.findElement(By.cssSelector(".context-menu-one"));


action.contextClick(link).perform();
// Click on Edit link on the displayed menu options
WebElement element = driver.findElement(By.cssSelector(".context-menu-icon-
copy"));
element.click();

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

TestNG (open source, free, .jar)


TDD-- Test Driven Development
-- Unit Test Framework
--Purpose--design the test cases in a systematic way
-- Good Suport for reporting-- html
-- Annotations --(always satrts with @)
-- priorities / sequence
-- data providers
-- grouping

For the test:


there will be some pre-requisites
@Before*
after that we will write the test, for writing the test we use
@Test
Post-condition
@After*
BeforeMethod Method
Test Case Method
AfterMethod Method

How to install TestNg in Eclipse?

--------------
1) Add extent dependency(extentreport aventstack)
2) Create one utility class that will generate Extent Report

Step:
onTestSuccess
onTestFail
onTestSkipped

BDD-- Behavior Driven Development -- commom language(English) --Cucumber(Gherkin-


keywords)
it is extension of TDD

You might also like