java - Selenium won't read the current input value -


i'm running selenium on site changes value of disabled input text box using jquery. looking @ html, value of input box continues "not available" though value changed.

i can current value using firebug

$("#inputid").val()  

but value "not available when i've used selenium code:

driver.findelement(by.id("inputid")).getattribute("value"); 

any suggestions on how value in selenium? want avoid trying use javascriptexecutor if that's best solution know.

i don't have access jquery code can't there. sorry :-/

if value changed jquery due dom events, chances selenium test going check new value fast. can value after changes away "not available" this:

webdriverwait wait = new webdriverwait(driver,10);  string value = wait.until(new expectedcondition<string>() {     public string apply(webdriver driver) {         string value = driver.findelement(by.id("inputid")).getattribute("value");          if value.equals("not available")             return null;          return value;     } }); 

(disclaimer: it's been ages since i've written java code may have goofed in code above.) wait.until call run apply method until returns else null. wait @ 10 seconds. value returned wait.until value last returned apply terminated end. in other words, return new value of element.

you say

looking @ html, value of input box continues "not available" though value changed.

yes, that's quirk of dom. when change value of input field, value attribute on element represent input field not change. changes value property on element. why have $("#inputid").val(), not $("#inputid").attr('value').


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -