javascript - How to check the value of the "value" attribute in an <input> element? -
i have following:
<h1>request group rate</h1> <form> <input type="hidden" name="referrer" id="bmn"> name: <input type="text" id="fieldname" name="name"><br> group size: <input type="text" name="groupsize"><br> email: <input type="email" name="email"><br> <input type="submit" value="submit"> </form> <script> $(document).ready(function(){ $('input[name="referrer"]').val(document.referrer); $(document.body).append('<div id="ready"></div>'); }); </script>
after navigating page using selenium:
driver.findelement(by.id('requestgrouprate')).click(); driver.sleep(100); driver.wait(function(){ return driver.findelement(by.id('ready')).then(function(){ driver.sleep(1000); var element = driver.findelement(by.id('bmn')); console.log(element.value); assert(element.value === referrer); done(); }); },5000);
my assertion fails. reason element.value undefined. why ? how should compare value set in input field id "bmn" ? value should set, because div id "ready" created after value set, if driver can find "ready", value input field should set..
what doing wrong ?
var ele = driver.findelement(by.id('bmn')); ele.getattribute('value').then(function(text){ console.log('bmn value: ' + text); assert(text === 'change expected value'); });
Comments
Post a Comment