...4import org.openqa.selenium.By;5import org.openqa.selenium.NoSuchElementException;6import org.openqa.selenium.WebDriver;7import org.openqa.selenium.chrome.ChromeDriver;8import org.openqa.selenium.support.ui.ExpectedConditions;9import org.openqa.selenium.support.ui.FluentWait;10import org.openqa.selenium.support.ui.Wait;11import org.openqa.selenium.support.ui.WebDriverWait;12import org.testng.annotations.Test;13public class WaitEx {14 15 WebDriver driver;16 17 @Test18 public void test() {19 System.setProperty("webdriver.chrome.driver","chromedriver.exe"); 20 driver=new ChromeDriver();21 driver.get("file:///D:/Omkar%20java/SELENIUM/Offline%20Website/index.html#");22 //browser related waits -- globally declared23 24 // 1) pageLoadTimeOut wait25 driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); // TimeoutException-If the timeout expires.26 27 // 2) Implicit wait28 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); // NoSuchElementException29 30 //element specific wait -- declared as & when necessary (required) 31 32 // 3) Explicit wait33 WebDriverWait wait=new WebDriverWait(driver, 30);34 wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//img"))));35 36 // 4) Fluent wait37 Wait w=new FluentWait(driver)38 .withTimeout(30, TimeUnit.SECONDS)39 .ignoring(NoSuchElementException.class)40 .pollingEvery(3, TimeUnit.SECONDS); 41 w.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//img"))));42 43 driver.findElement(By.id("email")).sendKeys("kiran@gmail.com");44 45 46}47 48 49} // class WaitEx ends50/*511) driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);52agar page load nahi hua 30 seconds me to wo TimeOutException dega, this is single line implementation53pageLoadTimeout ye page load hone ka wait kar raha he , na ki kisi WebElement ka 542) driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);55this is single line implementation, it is similar to pageLoadTimeout, just the difference is agar page 30 seconds56me load nahi hua to ye NoSuchElementException dega57implicitlyWait har ek WebElement ke liye wait karta he automatically58both are driver level waits, pageLoadTimeout ye page ke liye kam karta he & implicitlyWait ye all WebElement ke59liye kam karta he.603) WebDriverWait wait=new WebDriverWait(driver, 30);61WebDriverWait is class uska objcet create kiya, WebDriverWait ka constructor hame kya mangata he62 -- org.openqa.selenium.support.ui.WebDriverWait.WebDriverWait(WebDriver driver, long timeOutInSeconds) ---63 driver as 1st parameter and 2nd parameter time mangta he by default wo seconds me hi he.64WebDriverWait wait=new WebDriverWait(driver, 30);65wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("email"))));66hamne hya par wait ka objcet create kiya, and bola ki alag se 30 seconds ka wait karo ,email ke webelement ke 67liye jab tak wo dikhta nahi he.68until() method me hamne condition di ,until() method ye WebDriverWait class ki he, condition ye ExpectedConditions69class se ayegi70ExpectedConditions class iss package se import hota he71----- import org.openqa.selenium.support.ui.ExpectedConditions; --72ExpectedConditions is Utility class ,all the methods are static here, so ham ExpectedConditions class ki 73method kaise call kar sakhte he --> className with dot operator(ExpectedConditions.call method which you want)74static method kaise call karte he ham --> className with dot operator75so ExpectedConditions class kyu use karte he , hame jis condition ka wait karna he uss condition ko provide76karne ke liye use karte he77 78 79jab hamare pass List of WebElements hoge tab ham ExpectedConditions ki konsi method use karnge 80visibilityOfAllElements() ye wali use karnge81nested webelements means for eg got to website --> https://www.carmax.com/ --> hya par hame 'More' kar ke82option dikhega jab ham uske upper cursor(mouse) leke jate he to uske elements dikh jate he83ye hote he nested webelements.84presence & invisible me difference kya he?85for eg. ek login page hota he jab tak username & password enter nahi karte tab tak sign-in button click nahi 86ho pata, means sign-in button is waiting for some condition, which is present but not visible87kuch webelements aise hote he ki wo kisi na kisi condition ke liye ruke hue hote he 884) jab jab ham wait use karnge to hame check karna he ki wo import kaha se ho rahe he89import org.openqa.selenium.support.ui.ExpectedConditions;90import org.openqa.selenium.support.ui.FluentWait;91import org.openqa.selenium.support.ui.Wait;92import org.openqa.selenium.support.ui.WebDriverWait;93import ye org.openqa.selenium.support.ui--- iss package se hi hone chaiye945)Wait w=new FluentWait(driver)95 .withTimeout(30, TimeUnit.SECONDS)96 .ignoring(NoSuchElementException.class)97 .pollingEvery(3, TimeUnit.SECONDS); 98 99.withTimeout(30, TimeUnit.SECONDS) -- it is maximum time frame, it will wait upto 30 seconds 100 101.ignoring(NoSuchElementException.class) -- hya par ham exception ignore kar sakhte he,suppose muze pata he102ki aisa aisa exception a sakhta he so we can ignore that exception, to execute our test case smoothly103agar hame exception aata he to hamari next steps execute nahi hote to wo execution stop na ho wo ham hya par104handle kar sakhte he by ignoring that exception105ignoring nahi likha to bhi chalta he . mandatory nahi he ki likhan hi chaiye.106.pollingEvery(3, TimeUnit.SECONDS); -- pollingEvery means frequency, total mime frame agar 30 seconds ka he107to ye polling hamne 3 seconds ka rakha 108Explicit wait me kya hota tha ki hamne 3o seconds ka time rakah tha to wo her second ko jake check karta tha 109ki wo condition fulfill ho rahi he ya nahi110aab fluent wait kya karega har 3 seconds me check karega iss condition ko111---- w.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("email")))); ---112so there will be 10 polling coz (10*3=30) so ye 10 bar hi check karega ja kar ki condition fulfill ho rahi 113he ya nahi114how frequently it should check, to hamne bola ki her 3 seconds ke bad check karo.115Wait w=new FluentWait(driver)116here Wait is an interface so we cant create object of that, so hamne uske child class ka objcet banaya117public class FluentWait<T> implements Wait<T>118public class WebDriverWait extends FluentWait<WebDriver>119so here FluentWait is class, WebDriverWait is class & Wait is interface120releation is sabse upper wait he ,wait ka child class he FluentWait & FluentWait ka child class he WebDriverWait1216) Explict wait & fluent wait dono bhi single webelement ke liye kam karte he 122 */...