OS:
OSX El Capitan
Selenium Version:
3.0
Browser:
Chrome & Safari
elementIsVisible should work
TypeError: element.isDisplayed is not a function
This could should be fine based on the node module and specification.
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var driver = new webdriver.Builder()
.forBrowser('safari')
.build();
driver.get('http://cnn.com');
driver.findElement(By.className('nav-menu')).click();
driver.wait(until.elementLocated(By.className('nav-menu'), 10000))
driver.wait(until.elementIsVisible(By.className('nav-menu')), 10000);
driver.quit();
elementIsVisible takes a webelement reference, not a By object
Ah sorry, thanks :)
Please Give example for that ?
What is webelement reference?
Thanks!
I'd also like to know:
Please Give example for that ?
What is webelement reference?
@ChrisGrigg, @KathiresanRamkumar95 - smth like this:
let by = By.className('nav-menu');
driver.wait(until.elementLocated(by, 10000));
let el = driver.findElement(by);
driver.wait(until.elementIsVisible(el), 10000);
@artemv thanks! That's working better than all other things I've tried.
Is there any shorter response ? It works btw
@gigouni you can remove 1 line:
let by = By.className('nav-menu');
driver.wait(until.elementLocated(by, 10000));
driver.wait(until.elementIsVisible(driver.findElement(by)), 10000);
Huum, what about
driver.wait(until.elementLocated(By.className('foobar'), 10000));
driver.wait(until.elementIsVisible(firefox_driver.findElement(by)), 10000);
?
@ChrisGrigg I was hoping even shorter but that's cool, thanks
Edit
Okay I've forgotten the _by_ declaration... My bad, that's good for you.
Thanks guys
Hi, talking about that, I tried to locate in the code how you figure out when an element is displayed, can anyone guide me? Thanks
@kiragengis
const ELEM_BY = BY.id("your-element-id")
driver.wait(UNTIL.elementLocated(ELEM_BY)).then(() => {
driver.wait(UNTIL.elementIsVisible(driver.findElement(ELEM_BY)), 10000).then(() => {
done()
})
})
The elementIsVisible() might be your answer.
Stupid question: instead of this unhelpful error message, why not throw one that says "elementIsVisible takes a webelement reference, not a By object"?
P.S. I'd be happy to submit a PR if this is desired.
PRs are always welcome.. this one sounds somewhat easy to implement, so it might be a good place to learn about the code too.
MM
Sent from my iPhone
On May 16, 2019, at 12:04 PM, Jeremy Walker notifications@github.com wrote:
Stupid question: instead of this unhelpful error message, why not throw one that says "elementIsVisible takes a webelement reference, not a By object"?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Most helpful comment
@ChrisGrigg, @KathiresanRamkumar95 - smth like this: