Selenium Framework for Beginners 30 | What is fluent wait | How to use fluent wait in Selenium

Поділитися
Вставка
  • Опубліковано 4 гру 2024

КОМЕНТАРІ • 76

  • @f.a5148
    @f.a5148 Рік тому

    thank you brother a always watch your tutorials.

  • @mandavars
    @mandavars 3 роки тому +1

    Thanks this helped me so much

  • @Monikakumari-hp9dv
    @Monikakumari-hp9dv Рік тому

    Thanks it helped me👍

  • @aloksharma1426
    @aloksharma1426 5 років тому +1

    Sir @15:48, if u don't click on manually on page 2 , Is our script automatically goto page 2 and click that required link🤔???

    • @RaghavPal
      @RaghavPal  5 років тому

      Is it, okay, I did not check that.

    • @shakirhussain4639
      @shakirhussain4639 4 роки тому

      you can scroll down using javascriptexecutor and click on page 2 and then search for that link

  • @wilsonfernandes21
    @wilsonfernandes21 6 років тому +2

    What is difference between WebDriverWait and FluentWait ?
    I feel WebDriverWait does same task with less lines of code.

    • @RaghavPal
      @RaghavPal  6 років тому +1

      Hi Wilson, you can read this
      stackoverflow.com/questions/40753321/fluent-wait-vs-webdriver-wait
      stackoverflow.com/questions/19908296/fluent-wait-and-webdriver-wait-differences

  • @milindprabhakarshirsat1614
    @milindprabhakarshirsat1614 2 роки тому

    Hello sir , I have one condition in a portal where there is a random allocation , allocation happens after random interval time like 2 sec , 2 min , 2 hour. So I have to automate in a way whenever the allocation will happened it should auto accept .
    Any suggestion for making this script ?

    • @RaghavPal
      @RaghavPal  2 роки тому

      Hi Milind, I will need to check and study the scenario

    • @milindprabhakarshirsat1614
      @milindprabhakarshirsat1614 2 роки тому

      @@RaghavPal Hello Sir , Thanks for your response , I have achieved the result ,

    • @AmarKumar-pu1ch
      @AmarKumar-pu1ch 2 роки тому

      @@milindprabhakarshirsat1614 I am stuck in a similar situation please tell me how you achieved

  • @saraswatihulagannavar5630
    @saraswatihulagannavar5630 3 роки тому

    Hi Raghav could you explain how to write fluent wait code in typescript?

    • @RaghavPal
      @RaghavPal  3 роки тому

      I will create a session

  • @icebluebear
    @icebluebear 3 роки тому +2

    In Selenium 4.0, we have to use "Java.time.duration", so the wait method would be .withTimeOut(Duration.ofSeconds(30))

    • @RaghavPal
      @RaghavPal  3 роки тому

      Yes, thanks for adding

    • @shri1185
      @shri1185 3 роки тому

      WHO IS YOUR TRAINER??

    • @RaghavPal
      @RaghavPal  3 роки тому +2

      I just try on my own taking help from online resources

  • @bajishaik429
    @bajishaik429 5 років тому

    superb

  • @rahuldubey9013
    @rahuldubey9013 3 роки тому +1

    "withTimeout(10, TimeUnit.Seconds)" and PollingEvery(2, TimeUnit.Seconds)" getting error that it is deprecated after Selenium v3.11.0. Using withTimeout(Duration.ofSeconds(10)) and pollingEvery(Duration.ofMillis(500)) will work now. Import Java.time.Duration

    • @RaghavPal
      @RaghavPal  3 роки тому +1

      Hi Rahul, thanks for the update

    • @rahuldubey9013
      @rahuldubey9013 3 роки тому

      @@RaghavPal Thank you Raghav... Learning a Lot from you🙏

  • @rajiniyalamarthy4480
    @rajiniyalamarthy4480 5 років тому

    Function and apply are keywords?

    • @RaghavPal
      @RaghavPal  5 років тому

      these are functions Rajini

  • @zameerkhan29
    @zameerkhan29 6 років тому

    Hi Raghav,
    Which version of selenium are you using?
    I'm getting methods depreciated warning for version 3.14.0.
    I used 2.53.0 but the browser is closing very soon.

    • @RaghavPal
      @RaghavPal  6 років тому

      I used 3.4.0

    • @zameerkhan29
      @zameerkhan29 6 років тому

      @@RaghavPal I solved the depreciated warning issue but the browser is closing fast ..its not waiting for the time mentioned

    • @RaghavPal
      @RaghavPal  6 років тому

      Hi Zameer, what was the solution. Do you have any logs for this new issue.

  • @hima3867
    @hima3867 4 роки тому +2

    Wait wait = new FluentWait(driver)
    .withTimeout(30, SECONDS)
    .pollingEvery(5, SECONDS)
    .ignoring(NoSuchElementException.class);
    I got error here as well
    It didn't work saying WebDriverWait deprecated in Selenium 4.0.0-alpha-3. as I am using selenium-java version 4.0.0-alpha-5
    Later I found out that
    Wait wait = new FluentWait(driver)
    .withTimeout(Duration.ofSeconds(30))
    .pollingEvery(Duration.ofSeconds(5))
    .ignoring(NoSuchElementException.class);
    There is change in syntax n it worked for me
    Hope this works for someone
    Thanks in advance
    Hima

    • @RaghavPal
      @RaghavPal  4 роки тому

      Hi Hima, Thanks for adding this to help others

  • @faisalsakib9586
    @faisalsakib9586 6 років тому

    What is the problem if we use click
    .rether than sendkeys.return. can you plz.explain
    Thanks

    • @waniya-huzzu
      @waniya-huzzu 6 років тому +2

      Click will throw exception as that button is overlap by auto suggestion list , that's why we are using sendkeys

    • @RaghavPal
      @RaghavPal  6 років тому

      That's right, thanks Azhar

    • @romanmotovilov129
      @romanmotovilov129 5 років тому

      Some times I can't find button 'btnK' and use 'sendKey' only 'click' is working. Does anybody know why?

  • @waniya-huzzu
    @waniya-huzzu 6 років тому

    How you getting auto suggestion of code in eclipse, I am not getting in auto suggestion,if I am moving my mouse to those classes and methods.

    • @RaghavPal
      @RaghavPal  6 років тому +1

      If you write Flue and hover over, do you get option for FluentWait, then right click again on that option, you will get the documentation
      Else copy it from documentation page as shown.

  • @manikandanm6528
    @manikandanm6528 4 роки тому

    In want to apply fluent wait irrespective of all elements... how to achieve that??

    • @RaghavPal
      @RaghavPal  4 роки тому

      Hi Mani, what exactly you mean by irrespective of all elements. This can help - www.techbeamers.com/webdriver-fluent-wait-command-examples/

  • @pitumburvivekanand9101
    @pitumburvivekanand9101 6 років тому

    Hi Raghav, I am getting the following error with FluentWait, "The type FluentWait is not generic; it cannot be parameterized with arguments " and I am selenium 3.12. Can you please advise. Thank you in advance.

    • @RaghavPal
      @RaghavPal  6 років тому

      Hi, have you imported Fluent Wait, Pls recheck and also refer in the video - ua-cam.com/video/iUQIL2VsHIk/v-deo.html

    • @prakashchandra1103
      @prakashchandra1103 4 роки тому +1

      i am also getting the same error. import org.openqa.selenium.support.ui.*; - imported this package already. please suggest asap.

    • @prakashchandra1103
      @prakashchandra1103 4 роки тому

      import java.util.concurrent.TimeUnit;
      import org.openqa.selenium.By;
      import org.openqa.selenium.Keys;
      import org.openqa.selenium.NoSuchElementException;
      import org.openqa.selenium.WebDriver;
      import org.openqa.selenium.WebElement;
      import org.openqa.selenium.chrome.ChromeDriver;
      import org.openqa.selenium.support.ui.*;
      import com.google.common.base.Function;
      public class FluentWait {
      public static void main(String[] args) throws Exception {
      test();

      }

      public static void test() throws Exception
      {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\Prakash\\eclipse-workspace\\SeleniumTrainings\\ExeFiles\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      //driver.manage().window().maximize();
      driver.get("www.google.com");
      driver.findElement(By.name("q")).sendKeys("selenium");
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      driver.findElement(By.name("btnK")).sendKeys(Keys.ENTER);

      //driver.findElement(By.className("LC20lb DKV0Md")).click();

      Wait wait = new FluentWait(driver)
      .withTimeout(30, TimeUnit.SECONDS)
      .pollingEvery(5, TimeUnit.SECONDS)
      .ignoring(NoSuchElementException.class);
      WebElement foo = wait.until(new Function() {
      public WebElement apply(WebDriver driver) {
      WebElement linkelement = driver.findElement(By.className("LC20lb DKV0Md"));

      if(linkelement.isEnabled()) {
      System.out.println("found");}

      return linkelement;
      }

      });
      foo.click();


      }

      }
      This is my script. please suggest.

  • @vamsikumili26
    @vamsikumili26 4 роки тому

    How does he is able to click on a link of page 2 from page 1?

    • @RaghavPal
      @RaghavPal  4 роки тому

      Hi Virat, pls point the time in the video so I can check

    • @vamsikumili26
      @vamsikumili26 4 роки тому

      @@RaghavPal from 7:10 to 7:50 , you selected a link from page 2 and you created a webelement for that.. But ur driver initially refers to page 1, how u r able to access elm of page 2.. after 7:50 u implemented fluent wait..

    • @RaghavPal
      @RaghavPal  4 роки тому +1

      Hi Virat, if you check at 15:45, I have manually clicked on page 2 link. This was just to show the working of fluent wait

  • @yuvraj4870
    @yuvraj4870 4 місяці тому

    you should have explained wait.until in detail. that was the most important part.

    • @RaghavPal
      @RaghavPal  4 місяці тому

      Sure. I will check on this and improve

  • @bartomiejkmita5118
    @bartomiejkmita5118 3 роки тому

    This reminds me CompletableFeature from Java threads :D I find it similar in some ways.

  • @ashwinilohar1169
    @ashwinilohar1169 5 років тому

    Wait wait = new FluentWait(driver)
    .withTimeout(5,TimeUnit.SECONDS)
    .pollingEvery(5,TimeUnit.SECONDS)
    .ignoring(NoSuchElementException.class);
    WebElement foo = wait.until(new Function() {
    public WebElement apply(WebDriver driver) {
    return driver.findElement(By.id("foo"));
    }
    });
    Error is
    The method withTimeout(Duration) in the type FluentWait is not applicable for the arguments (int, TimeUnit)
    please Help

    • @RaghavPal
      @RaghavPal  5 років тому

      Hi Ashwini, what are your imports. Try
      import java.time.Duration;

    • @boroop
      @boroop 4 роки тому

      The original parameters for withTimeout() & pollingEvery() have been deprecated (changed and removed).These each now only take 1 parameter, which is a unit of time.
      Below is a sample of currently working code (without the warnings):
      Wait wait = new FluentWait(driver)
      .withTimeout(Duration.ofSeconds(30))
      .pollingEvery(Duration.ofMillis(500))
      .ignoring(NoSuchElementException.class);

  • @revathikamaraj6650
    @revathikamaraj6650 Рік тому

    These 2 lines are not working in selenium 4.11.0
    WebDriverWait wait = new WebDriverWait(driver,Duration.ofSeconds(10));
    FluentWait wait = new FluentWait(driver).withTimeout(Duration.ofSeconds(35)).pollingEvery(Duration.ofSeconds(10));
    and also,
    wait.until(ExpectedConditions.visibilityOf(e));
    Can anyone help me to handle this? Please

    • @RaghavPal
      @RaghavPal  Рік тому

      Revathi
      Yes, the `WebDriverWait` and `FluentWait` classes are deprecated in Selenium 4.11.0. You should use the `Wait` class instead.
      The `Wait` class has a constructor that takes a `Duration` object as its argument. The `Duration` object specifies the amount of time to wait for the condition to be met.
      For example, the following code creates a `Wait` object that will wait for 10 seconds for the element to be visible:
      ```
      Wait wait = new Wait(driver, Duration.ofSeconds(10));
      ```
      The `wait.until()` method is also deprecated in Selenium 4.11.0. You should use the `until()` method instead.
      The `until()` method takes a `Function` object as its argument. The `Function` object specifies the condition that you want to wait for.
      For example, the following code waits for the element to be visible:
      ```
      wait.until(ExpectedConditions.visibilityOf(e));
      ```
      Here is the updated code that you can use:
      ```
      Wait wait = new Wait(driver, Duration.ofSeconds(10));
      wait.until(ExpectedConditions.visibilityOf(e));
      ```
      I hope this helps

    • @revathikamaraj6650
      @revathikamaraj6650 Рік тому

      @@RaghavPal public void waitforvisiblityofelement(String element) {
      WebElement e = getelement(element);
      try {
      Wait wait = new Wait(driver, Duration.ofSeconds(10));

      wait.withTimeout(Duration.ofSeconds(35));
      wait.pollingEvery(Duration.ofSeconds(10));
      wait.ignoring(NoSuchElementException.class);
      wait.ignoring(ElementNotVisibleException.class);
      wait.ignoring(StaleElementReferenceException.class);
      wait.ignoring(NoSuchFrameException.class);
      wait.ignoring(TimeoutException.class);
      wait.ignoring(NoAlertPresentException.class)
      wait.ignoring(NoSuchWindowException.class);

      wait.until(ExpectedConditions.visibilityOf(e));
      wait.until(ExpectedConditions.elementToBeClickable(e));
      wait.until(ExpectedConditions.visibilityOfAllElements(e));
      wait.until(ExpectedConditions.alertIsPresent());
      wait.until(ExpectedConditions.elementSelectionStateToBe(e, true));
      wait.until(ExpectedConditions.elementToBeSelected(e));
      // Add more conditions as needed

      } catch (Exception ex) {
      ex.printStackTrace();
      }
      }
      No sir, I can't able to import the above Wait and ExpectedConditions
      Using selenium 4.11.0 only

    • @RaghavPal
      @RaghavPal  Рік тому

      Can check and try some online examples

    • @revathikamaraj6650
      @revathikamaraj6650 Рік тому

      @@RaghavPal Okay

    • @revathikamaraj6650
      @revathikamaraj6650 Рік тому

      Hi sir,
      I cleared that Wait issue
      But another issue came while running the script
      [INFO] --- maven-compiler-plugin:3.11.0:testCompile (default-testCompile) @ Aim ---
      [INFO] Nothing to compile - all classes are up to date
      [INFO]
      [INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ Aim ---
      [INFO]
      [INFO] -------------------------------------------------------
      [INFO] T E S T S
      [INFO] -------------------------------------------------------
      SLF4J: No SLF4J providers were found.
      SLF4J: Defaulting to no-operation (NOP) logger implementation
      SLF4J: See www.slf4j.org/codes.html#noProviders for further details.
      null
      com.google.inject.ProvisionException:
      Unable to provision, see the following errors:
      1) [Guice/ErrorInjectingConstructor]: NoClassDefFoundError: org/openqa/selenium/interactions/HasInputDevices
      at WebdriverCloseBrowser.(WebdriverCloseBrowser.java:22)
      while locating WebdriverCloseBrowser
      at WebDriverModule.configure(WebDriverModule.java:20)
      while locating CloseBrowser
      Learn more:
      github.com/google/guice/wiki/ERROR_INJECTING_CONSTRUCTOR
      1 error
      ======================
      Full classname legend:
      ======================
      CloseBrowser: "net.thucydides.core.webdriver.CloseBrowser"
      WebDriverModule: "net.thucydides.core.guice.webdriver.WebDriverModule"
      WebdriverCloseBrowser: "net.thucydides.core.webdriver.WebdriverCloseBrowser"
      ========================
      End of classname legend:
      ========================
      I checked in my script whether I am using the HasInputDevice. But I didn't found anything. I think it is indirectly using HasInputDevice. I know this method is deprecated in selenium 4.11.0 but I don't know how to solve?

  • @100janyam
    @100janyam Рік тому

    Its really confusing to inspect current google results. unable to click on anything automatically with code, need to understand and work more

    • @100janyam
      @100janyam Рік тому

      Was able to find by xpath and click on it

  • @Deniz-ss1sv
    @Deniz-ss1sv 3 роки тому

    :)