1
votes

WebDriverWait est obsolète dans Selenium 4

Je reçois un

Avertissement: (143,13) 'WebDriverWait (org.openqa.selenium.WebDriver, long)' est obsolète

dans Selenium 4.0.0-alpha-3.

Mais officiel Selenium page répertorie uniquement

WebDriverWait(WebDriver driver, Clock clock, Sleeper sleeper, long timeOutInSeconds, long sleepTimeOut)

comme obsolète.

Qu'est-ce qui ne va pas? J'utilise IntelliJ, cela pourrait-il être leur problème?


0 commentaires

3 Réponses :


3
votes

Ce message d'avertissement ...

v4.0.0-alpha-3
==============

* Add "relative" locators. The entry point is through the `RelativeLocator`.
  Usage is like `driver.findElements(withTagName("p").above(lowest));`
* Add chromedriver cast APIs to remote server (#7282)
* `By` is now serializable over JSON.
* Add ApplicationCache, Fetch, Network, Performance, Profiler,
  ResourceTiming, Security and Target CDP domains.
* Fixing Safari initialization code to be able to use Safari Technology
  Preview.
* Ensure that the protocol converter handles the new session responses
  properly.
* Expose devtools APIs from chromium derived drivers.
* Expose presence of devtools support on a role-based interface
* Move to new Grid, deleting the old standalone server and grid implementation.
* Switch to using `HttpHandler` where possible. This will impact projects that
  are extending Selenium Grid.
* Respect "webdriver.firefox.logfile" system property in legacy Firefox driver.
  Fixes #6649
* Back out OpenCensus support: OpenTracing and OpenCensus are merging, so
  settle on one for now.
* Only allow CORS when using a —allow-cors flag in the Grid server
* If you're using the Java Platform Module System, all modules
  associated with the project are generated as "open" modules. This
  will change in a future release.
* The version of Jetty being used is unshadowed.

... implique que le constructeur actuel de WebDriverWait sont obsolètes.


Recherche du code pour WebDriverWait.java a > il semble:

  • Les méthodes suivantes sont obsolètes :

    • public WebDriverWait (pilote WebDriver, long timeoutInSeconds)

      /**
       * @param driver the WebDriver instance to pass to the expected conditions
       * @param clock used when measuring the timeout
       * @param sleeper used to make the current thread go to sleep
       * @param timeout the timeout when an expectation is called
       * @param sleep the timeout used whilst sleeping
       */
      public WebDriverWait(WebDriver driver, Duration timeout, Duration sleep, Clock clock, Sleeper sleeper) {
        super(driver, clock, sleeper);
        withTimeout(timeout);
        pollingEvery(sleep);
        ignoring(NotFoundException.class);
        this.driver = driver;
      }
      
    • public WebDriverWait (pilote WebDriver, long timeoutInSeconds, long sleepInMillis)

      /**
       * Wait will ignore instances of NotFoundException that are encountered (thrown) by default in
       * the 'until' condition, and immediately propagate all others.  You can add more to the ignore
       * list by calling ignoring(exceptions to add).
       *
       * @param driver The WebDriver instance to pass to the expected conditions
       * @param timeout The timeout in seconds when an expectation is called
       * @param sleep The duration in milliseconds to sleep between polls.
       * @see WebDriverWait#ignoring(java.lang.Class)
       */ 
      public WebDriverWait(WebDriver driver, Duration timeout, Duration sleep) {
        this(driver, timeout, sleep, Clock.systemDefaultZone(), Sleeper.SYSTEM_SLEEPER);
      }
      
    • public WebDriverWait (pilote WebDriver, horloge, Sleeper sleeper, long timeoutInSeconds, long sleepInMillis)

      /**
       * @param driver The WebDriver instance to pass to the expected conditions
       * @param timeout The timeout when an expectation is called
       * @see WebDriverWait#ignoring(java.lang.Class)
       */
      public WebDriverWait(WebDriver driver, Duration timeout) {
        this(
            driver,
            timeout,
            Duration.ofMillis(DEFAULT_SLEEP_TIMEOUT),
            Clock.systemDefaultZone(),
            Sleeper.SYSTEM_SLEEPER);
      } 
      
  • Alors que les méthodes suivantes ont été ajoutées :

    • public WebDriverWait (pilote WebDriver, délai d'expiration)

      @Deprecated
      public WebDriverWait(
          WebDriver driver, Clock clock, Sleeper sleeper, long timeoutInSeconds, long sleepInMillis) {
        this(
            driver,
            Duration.ofSeconds(timeoutInSeconds),
            Duration.ofMillis(sleepInMillis),
            clock,
            sleeper);
      }
      
    • public WebDriverWait (pilote WebDriver, délai d'expiration, durée de veille)

      @Deprecated
      public WebDriverWait(WebDriver driver, long timeoutInSeconds, long sleepInMillis) {
        this(driver, Duration.ofSeconds(timeoutInSeconds), Duration.ofMillis(sleepInMillis));
      }
      
    • Pilote WebDriver, Délai d'expiration, Durée du sommeil, Horloge, Sleeper sleeper)

      @Deprecated
      public WebDriverWait(WebDriver driver, long timeoutInSeconds) {
        this(driver, Duration.ofSeconds(timeoutInSeconds));
      }
      

Vous voyez donc l'erreur.


Cependant, je ne vois aucune modification apportée à WebDriverWait Classe dans Selenium v4.0.0-alpha * Le journal des modifications du client Java et la fonctionnalité doivent continuer à fonctionner selon l'implémentation actuelle.

Journal des modifications du client Selenium Java v4.0.0-alpha-3 :

Warning: (143,13) 'WebDriverWait(org.openqa.selenium.WebDriver, long)' is deprecated

Conclusion

Le client Java de Selenium v4.0.0-alpha-3

est toujours une version alpha et doit passer par la version beta et ne devrait donc pas être utilisé pour tester l’activité dans un environnement de production.


Solution

Une solution immédiate serait de revenir au niveau publié actuel Version 3.141.59


0 commentaires

6
votes

Il n'apparaît pas dans la documentation, mais si vous regardez le code source vous verrez l'annotation @Deprecated

new WebDriverWait(driver, Duration.ofSeconds(10));

Dans la description du constructeur vous avoir la solution

@deprecated Utilisez plutôt {@link WebDriverWait # WebDriverWait (WebDriver, Durée)}.

Quel est le constructeur appelé à partir du constructeur obsolète dans tous les cas.

@Deprecated
public WebDriverWait(WebDriver driver, long timeoutInSeconds) {
    this(driver, Duration.ofSeconds(timeoutInSeconds));
}


0 commentaires

2
votes
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
Use this instead, only WebDriverWait(driver, clock)  is supported;

1 commentaires

aucun avertissement après avoir utilisé ceci dans la version de sélénium 4.0.0-alpha-7