Rogger
Rogger

Reputation: 65

Wait javascript event WebDriver

I have a menu and sub-menus built in angularJS.

Each menu has the following code:

<a class="ng-scope" ng-click="irPara(item, $event)" ng-if="!item.heading" title="">

When I try to click in a link of a submenu, Selenium throws an exception that Element is not clickable, or element is not found.

I assume this happens because I have to wait submenu be load, how Do I wait for this submenu to be loaded without using Thread.sleep()

thanks

Upvotes: 1

Views: 85

Answers (1)

Guy
Guy

Reputation: 50864

You can use explicit wait. Work around in JavaScript:

driver.wait(function() {
    return driver.findElement(locator).isDisplayed();
}, 10);

This will wait up to 10 seconds for the element to be displayed.

Upvotes: 2

Related Questions