কম্পিউটার

সাবলীল অপেক্ষা কি সঞ্চালন করে?


সাবলীল অপেক্ষা হল একটি গতিশীল অপেক্ষা যা ড্রাইভারকে এমন অবস্থার জন্য বিরতি দেয় যা একটি ব্যতিক্রম নিক্ষেপ করার আগে একটি ফ্রিকোয়েন্সিতে পরীক্ষা করা হয়। উপাদানটি DOM-এ ক্রমাগত নয় বরং একটি নিয়মিত বিরতিতে অনুসন্ধান করা হয়।

উদাহরণস্বরূপ, যদি অপেক্ষা 5 সেকেন্ডের জন্য হয়, FluentWait নিয়মিত বিরতিতে DOM নিরীক্ষণ করে (সময়ের মধ্যে পোলিং দ্বারা সংজ্ঞায়িত)। FluentWait-এ, শর্তের উপর ভিত্তি করে কাস্টমাইজড অপেক্ষার পদ্ধতি তৈরি করতে হবে।

সিনট্যাক্স

Wait<WebDriver> w = new FluentWait< WebDriver >(driver)
.withTimeout (10, SECONDS)
.pollingEvery (2, SECONDS)
.ignoring (NoSuchElementException.class)

উদাহরণ

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;
import org.openqa.selenium.support.ui.FluentWait;
public class Fluentwt {
   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);
      //implicit wait with time in seconds applied to each elements
      driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);
      //Clicking on Coding Ground link
      driver.findElement(By.xpath("//span[text()=’Coding Ground’]")).click();
      // fluent wait declaration
      Wait<WebDriver> w = new FluentWait<WebDriver>(driver).withTimeout
      (Duration.ofSeconds(30))
      .pollingEvery(Duration.ofSeconds(3)).ignoring(
      NoSuchElementException.class);
      WebElement fl = w.until(new Function<WebDriver, WebElement>() {
         // customized condition for fluent wait
         public WebElement apply(WebDriver driver) {
            if (driver.findElement(By.xpath("[//img[@title=’Whiteboard’"))
            .isDisplayed()) {
               return true;
            }else {
               return null;
            }
         }
      });
      driver.quit();
   }
}

  1. SNMP মানে কি?

  2. Windows এ সিস্টেম রিস্টোর কি করে?

  3. একটি ডিভাইস ড্রাইভার কি? এটা কিভাবে কাজ করে?

  4. অ্যান্টিভাইরাস সফ্টওয়্যার কি করে?