Posts

Showing posts from May, 2024

Asserts

 Asserts - are used to perform Validations

TestNG Annotations:

  TestNG à    It is a unit testing framework -> Selenium + testNG Browser + testing Java- Junit/TestNG Python : Pytest JS : Mocha/Jasmine C# : NUnit 1.       Free and open source 2.       Easily integrated with selenium 3.       Report à HTML: PASS/FAIL, XML report 4.       Organize test cases 5.       Prerequisites: 6.       Test runners->testng.xml 7.       Parallel Run 8.       Priority test cases/Ignore tcs 9.       Invocation count 10.   testNG listeners : attach screenshot in the report, allure, extends report 11.   annotations: before steps, after steps (please open before after test close all) 12.   Data Provider- test data, supply in the form of arrays- one test with 5 diff usr/pws 13.   Parameters: envoi paramet...

Implicit and Explicit Waits,FluentWait,PageLoadTimeOut

In selenium we have  Implicit and Explicit Waits:  Dynamic wait : Element is found in 2 seconds it will skip the 8 seconds OR                           Element is found in 4 seconds it will skip the 6 seconds Static wait - Thread.sleep(10000) // 10 secons it will halt the program Implicitly Wait : is a dyanmic wait  //implicitlyWait is a global wait it is applied to all the elements by default Implicitly wait only applies for web elements (it will never wait for NonWeb Elements EX: browsers title, alerts,URL,browserwindow,URL) driver .manage().timeouts().implicitlyWait(Duration. ofSeconds (10)); driver .manage().timeouts().implicitlyWait(Duration. ofMinutes ( 0 )); Element is found in 2 seconds it will skip the 8 seconds //implicitlyWait by default it will wait 10 seconds , //if element found for 2 seconds then it will take only 2 seconds only ,8 seconds will be ignored //if we have 5 elem...

Nested Frames

 Frames -> package NestedFrames; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.Test; public class NestedFramesEx { @ Test public void NframeEg() { WebDriver driver = new ChromeDriver(); driver .get( "https://selectorshub.com/iframe-scenario/" ); // Frame 1 driver .switchTo().frame( "pact1" ); // driver.findElement(By.cssSelector("#inp_val")).sendKeys("First Frame"); // Frame 2 driver .switchTo().frame( "pact2" ); driver .findElement(By. cssSelector ( "#jex" )).sendKeys( "Second Frame" ); //// Frame 3 driver .switchTo().frame( "pact3" ); driver .findElement(By. cssSelector ( "#glaf" )).sendKeys( "Third Frame" ); // SwitchTo--> parentFrame -->goes to 2nd from 3rd driver .switchTo().parentFrame(); driver .findElement(By. cssSelector ( "#jex" )).sendKeys( ...

JavaScript Executor

 JavaScript Executor

Relative Locators- LeftOf, RightOf,Above, Below

  WebDriver driver = new ChromeDriver(); driver .get( "https://www.aqi.in/dashboard/canada" ); Thread. sleep (4000); WebElement city = driver .findElement(By. linkText ( "Creston, Canada" )); String rightAQIUS = driver .findElement(RelativeLocator. with (By. tagName ( "p" )).toRightOf( city )).getText(); System. out .println( rightAQIUS ); String leftOf = driver .findElement(RelativeLocator. with (By. tagName ( "p" )).toLeftOf( city )).getText(); System. out .println( leftOf ); String aboveText = driver .findElement(RelativeLocator. with (By. tagName ( "p" )).above( city )).getText(); System. out .println( aboveText ); String belowText = driver .findElement(RelativeLocator. with (By. tagName ( "p" )).below( city )).getText(); System. out .println( belowText ); ************************* WebElement lastName = driver .findElement(By. cssSelector ( "label[for='input-lastname']" )); String aa = d...