0

I'm using selenium-webdriver in nodeJS not Java.

I'm using this.getPageSource() which return HTML but it doesn't wait for javascript to execute so I don't see some elements in dom which are loaded by JS.

How to wait for javascript execution?

BT101
  • 3,666
  • 10
  • 41
  • 90
  • Please check following SO.See if this help. https://stackoverflow.com/questions/10720325/selenium-webdriver-wait-for-complex-page-with-javascript-to-load – KunduK Mar 04 '19 at 15:57
  • I've already seen it but it's about selenium in java. I'm using javascript (node) selenium-webdriver – BT101 Mar 04 '19 at 16:01
  • How is question about javascript selenium-webdriver duplicate of question about java selenium? – BT101 Mar 04 '19 at 18:41

1 Answers1

-1

Try this

wait.until( 
    new Predicate<WebDriver>() {
        public boolean apply(WebDriver driver) {
            return ((JavascriptExecutor)driver)
                    .executeScript("return document.readyState")
                    .equals("complete");
            }
        }
    );
Pritam Maske
  • 2,670
  • 2
  • 22
  • 29