【问题标题】:How to wait till the scrolling bar will disappear on a loading of a webpage in selenium?如何等到滚动条在硒中加载网页时消失?
【发布时间】:2017-12-06 07:08:05
【问题描述】:

我在自动化 Web 应用程序时遇到了页面加载器问题。 在加载每个页面时,滚动条正在接收所有 Web 元素的点击。如何等到滚动条消失?

请提出你的答案。

【问题讨论】:

  • 如果您觉得任何答案对您有帮助,请不要忘记点击勾选标记accept 或仍有疑问然后通过评论提问

标签: javascript json selenium loader


【解决方案1】:

您需要找到该加载程序并放置 ExplicitWait 直到它变得不可见,然后对其他元素执行操作

WebElement loader = driver.findElement(By.id("loader_id"));
WebDriverWait wait = new WebDriverWait(driver, 60);
wait.until(ExpectedConditions.invisibilityOf(loader));

【讨论】:

    【解决方案2】:

    您需要检查页面上是否加载了 javaScript,因为您需要在这样的脚本中使用 javascript 命令

    JavascriptExecutor js =(JavascriptExecutor)driver;
            boolean loadProcess=(Long)js.executeScript("return jQuery.active") == 0; 
            while((loadProcess==false)){
                try {
                    Thread.sleep(2000);
                    loadProcess=(Long)js.executeScript("return jQuery.active") == 0;
                    logger.info("loadProcess  : "+loadProcess);
                } catch (InterruptedException e) {
                    logger.info("waitForJStoLoad error "+e.getMessage());
                }   }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-21
      • 1970-01-01
      • 2023-04-02
      • 1970-01-01
      • 2017-03-15
      • 1970-01-01
      相关资源
      最近更新 更多