एक्सप्लिसिट वेट वेब पेज पर एक विशिष्ट एलिमेंट पर लागू होते हैं। यह निष्पादन को तब तक रोकता है जब तक शर्त पूरी नहीं हो जाती। एक्सप्लिसिट वेट भी एक डायनामिक है क्योंकि यदि वेट समय पंद्रह सेकंड है और शर्तें (जैसे किसी एलिमेंट के क्लिकेबल, विजिबल या सेलेक्टेबल होने का इंतजार करना आदि) इस निर्दिष्ट समय से पहले पूरी हो जाती हैं, तो कंट्रोल अगले चरण पर चला जाएगा।
एक्सप्लिसिट वेट अधिक कस्टमाइज़ेबल है क्योंकि हम इसे शर्त के लिए सेट कर सकते हैं। एक्सप्लिसिट वेट के लिए कुछ अपेक्षित शर्तों की सूची नीचे सूचीबद्ध है -
textToBePresentInElement()
सिंटैक्स
w.until(ExpectedConditions.textToBePresentInElement(By.id(“<<id expression>>“), “Tutorialspoint”));
textToBeClickable()
सिंटैक्स
w.until(ExpectedConditions.textToBeClickable(By.id(“<<id expression>>“)));
alertisPresent()
सिंटैक्स
w.until(ExpectedConditions.alertisPresent())= null);
frameToBeAvailableAndSwitchToIt()
सिंटैक्स
w.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id(“<<frame id >>“)));
एक्सप्लिसिट कार्यान्वयन के मामले में जटिल है, हालांकि यह निष्पादन की गति को प्रभावित नहीं करता और पेज पर एक विशिष्ट एलिमेंट पर लागू होता है।
एक्सप्लिसिट वेट में, एक बार अधिकतम समय बीत जाने पर, ElementNotVisibleException फेंका जाता है।
उदाहरण
import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.support.ui.Wait; public class Explictwt { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); String url = "https://www.tutorialspoint.com/index.htm"; driver.get(url); //प्रत्येक एलिमेंट पर लागू सेकंड में इम्प्लिसिट वेट driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS); //Coding Ground लिंक पर क्लिक करना driver.findElement(By.xpath("//span[text()=’Coding Ground’]")).click(); // एक्सप्लिसिट वेट घोषणा WebDriverWait w = new WebDriverWait(driver,10); // textToBePresentInElement मेथड के साथ इंतजार करने की शर्त w.until(ExpectedConditions.textToBePresentInElement(By.xpath("//img[@title=’Whiteboard’]"),” Whiteboard”)); driver.quit(); } }