/ / बटन पर क्लिक करने के बाद पृष्ठ को कैसे रद्द करना है? - सेलेनियम, सेलेनियम-वेबड्राइवर

बटन पर क्लिक करने के बाद पृष्ठ को मंद होने तक प्रतीक्षा कैसे करें? सेलेनियम, सेलेनियम-वेबड्राइवर

बटन क्लिक करने के बाद पृष्ठ के मंद होने (लोड होने) तक इंतजार कैसे करें? मैंने निम्नलिखित विकल्पों की कोशिश की लेकिन अभी तक सफल नहीं हुआ। मुझे ट्रांजेक्शन टाइमिंग पर कब्जा करना है।

1) इंप्लीमेंट वेट

(driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);)

2) स्पष्ट प्रतीक्षा करें

(wait = new WebDriverWait(driver, 200);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("(//a[@ardbn="z3Btn_TDS_Next"]/div/img)[position()<3]")));)

3) मेरे अपने कार्य में से एक

public void waitForPageLoaded() {

ExpectedCondition<Boolean> expectation = new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver driver) { return ((JavascriptExecutor)driver).executeScript("return document.readyState").equals("complete"); } };

Wait<WebDriver> wait = new WebDriverWait(driver,30); try { wait.until(expectation); } catch(Throwable error) { fail("Timeout waiting for Page Load Request to complete."); } }

Screnshot

उत्तर:

जवाब के लिए 2 № 1

लोड हो रहे बॉक्स की अदृश्यता तक प्रतीक्षा करें। मान लीजिए कि लोडिंग बॉक्स के लोकेटर / आईडी / xpath आईडी = लोडर है, तो

By locator = By.id("loader");
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(timeOutInSeconds, TimeUnit.SECONDS)
.pollingEvery(pollingIntervalInSeconds, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class)
.ignoring(StaleElementReferenceException.class);
wait.until(ExpectedConditions.invisibilityOfElementLocated(locator));