javascript - Selenium findElement by CSS and sending form -
i'am new in selenium , have question first script.
driver.findelement({ css: '.input[name=login]' }).sendkeys('login'); //driver.sleep(0); driver.findelement({ css: '.input.passwd' }).sendkeys('passwd'); driver.sleep(5000); driver.findelement({ css: '.button[type=submit]' }).click(); driver.sleep(10000); driver.gettitle().then(function(title) { console.log(title); assert.ok(title.indexof('title') > -1, 'wrong title'); }
and after executing still on login page , don't have errors except "assertionerror: wrong title". if selenium doesn't find element have error "nosuchelementerror: no such element: unable locate element:", think elements found , actions "sendkeys" , "click" worked. didn't.
how can check it, during execution script?
how can see, query selenium generated , sent server?
upd:
<input name="login" value="" type="text" class="input" tabindex="5"> <input name="" value="" type="password" class="input passwd" tabindex="6"> <input hidefocus="true" type="submit" class="button"></input>
you used class attribute html tag. example class=input
, name=login
both attributes of webelement of <input>
tag. try
driver.findelement({ css: 'input[name="login"]' }).sendkeys('login'); driver.findelement({ css: '.passwd' }).sendkeys('passwd'); driver.findelement({ css: '.button' }).click();
or
driver.findelement({ name: 'login' }).sendkeys('login'); driver.findelement({ classname: 'passwd' }).sendkeys('passwd'); driver.findelement({ classname: 'button' }).click();
or using class
driver.findelement(by.name('login')).sendkeys('login'); driver.findelement(by.classname('passwd')).sendkeys('passwd'); driver.findelement(by.classname('button')).click();
Comments
Post a Comment