javascript - <Selenium WebDriver JS> Can't find element & implicit wait problems -
i've been trying write selenium script in javascript fill out 'email' field on site, keeps telling me "element not found"...
i'm trying find element:
<input type="email" placeholder="email" name="email" class="form-control sweep" data-radium="true" data-reactid=".btcvpfkiyo.0.$/=10=22.0.0.$=12.0.0.0.$=10.$=11.0.$/=10.$=10.0" disabled="">
first go page, wait few seconds before try find element:
driver.get('www.mysite.com').then(function() { driver.manage().timeouts().implicitlywait(10000); driver.findelement({name:'email'}) .then(function(present) { if (present) { console.log("found"); } }); });
i've tried access element in many ways... here's i've tried:
driver.findelement(by.xpath("//input[@name='email']")) driver.findelement(by.css("input[type='email']")) driver.findelement(by.css("input[name='email']")) driver.findelement({name:'email'})
every 1 of these gives me same error: no such element
what's weird when use jquery select element using js tools, finds element immediately. every command above tested in jquery , worked
i'm thinking error 1 of these:
- maybe implicit wait isn't working (it wait 10 seconds i'm not sure if it's trying find element immediately). tried
implicitlywait(10000).then
maybe did wrong - maybe selector wrong
environment
- selenium webdriver v3.0.0-beta-2
- i'm using webdriver https://github.com/seleniumhq/selenium.
- the api here: selenium webdriver api
- node v4.4.4
as you've tried possible ways find element, didn't frame/iframe
.
there possibility desired element present inside frame/iframe
.
if there frame/iframe
exists need switch frame/iframe
using webdriver#switchto()
before finding desired element below :-
driver.switchto().frame("frame/iframe id or name") //now find desire element inside frame/iframe //after doing stuff inside frame/iframe switch default content driver.switchto().defaultcontent()
Comments
Post a Comment