Reputation:
I want to print the element as part of a message when protractor times out waiting for the element.
waitForElementDisplayed(webDriverEl, time = timeOut) {
let EC = protractor.ExpectedConditions;
let isVisible = EC.visibilityOf(webDriverEl);
browser.wait(isVisible, time, `Timed out waiting for element ${webDriverEl} to be visible`);
}
Have not had any luck trying to get the element to print correctly. Any help is appreciated.
Upvotes: 2
Views: 998
Reputation: 45
I am getting "Failed: webElement.locator is not a function"
My code sample:
var clickOn = function(webElement){
return webElement.click().then(()=> {
console.log("Successfully clicked on the " + webElement.locator().toString());
});
Upvotes: 0
Reputation: 4832
You can use element.locator().toString()
to get the locator of a webelement.
browser.wait(isVisible, time, "Timed out waiting for element "+element.locator().toString() +" to be visible");
Upvotes: 1