How to wait for an element to be visible with Protractor if Angular is not available?

I have a login function that I use for the Protractor test that looks like this:

var config = require("../helpers/config.js"); var login = function() { browser.driver.get(config.dsp.url); browser.driver.findElement(by.name("userName")).sendKeys(config.dsp.user); browser.driver.findElement(by.name("password")).sendKeys(config.dsp.password); return browser.driver.findElement(by.name("submit")).click().then(function() { return browser.driver.wait(function() { return browser.driver.isElementPresent(browser.driver.findElement(by.className("sample-class-name"))); }, 360000); }); } module.exports = login; 

I cannot use any particular transportation hook because Angular is not used on this page, so I have to use the webdriver base API. The problem is that I cannot figure out how to wait for the element to be visible using this wrapped webdriver object. Any help would be appreciated.

+5
source share
1 answer

Try with the expected conditions from the base driver:

 var config = require("../helpers/config.js"); var until = require('selenium-webdriver').until; var login = function() { var driver = browser.driver; driver.get(config.dsp.url); driver.findElement(by.name("userName")).sendKeys(config.dsp.user); driver.findElement(by.name("password")).sendKeys(config.dsp.password); driver.findElement(by.name("submit")).click(); return driver.wait(until.elementLocated(by.css(".sample-class-name")), 10000) .then(e => driver.wait(until.elementIsVisible(e)), 10000); } module.exports = login; 
+5
source

Source: https://habr.com/ru/post/1259109/


All Articles