How to change value of element via JavaScript with Selenium webdriver .NET -


i'm trying test popup page chrome webdriver , selenium2 using .net, i'm having issues. need change value of element after it's window pops up. need chage default "selectedindexes":["1"]" "selectedindexes":["0"]"

the element is:

<input id="tstabs_clientstate" name="tstabs_clientstate" type="hidden" autocomplete="off" value="{"selectedindexes":["1"], "logentries":[], "scrollstate":{}}"> 

my code follows: (i've tried both below listed executescript lines)

dim chromedriver = new chromedriver("c:\clearcase\projects\cms\vbsetest")     try         'chrome test         chromedriver.navigate().gotourl("http://localhost/cms/<location>.aspx")          dim queryc iwebelement = chromedriver.findelement(by.id("ctl00_cphm_grd_ctl00_ctl02_ctl00_aci_btninitinsert"))         queryc.click()          dim current string = chromedriver.currentwindowhandle         dim windows = chromedriver.windowhandles.asenumerable         dim addorgwindow iwebdriver         each window in windows             if window <> current                 addorgwindow = chromedriver.switchto.window(window)             end if         next         'chromedriver.executescript("document.getelementbyid('tstabs_clientstate').value='{'selectedindexes':['0'],'logentries':[],'scrollstate':{}}'")         'or         chromedriver.executescript("var tab=$get('tstabs_clientstate'); tab.value ='{'selectedindexes':['0'],'logentries':[],'scrollstate':{}}'")         addorgwindow.findelement(by.id("organization_txtname")).sendkeys("magickingdom")         addorgwindow.findelement(by.id("organization_cbindustry_cb_input")).sendkeys("rep")         addorgwindow.findelement(by.id("lbadd")).click()         chromedriver.quit()      catch e exception         chromedriver.quit()         msgbox(e.tostring())     end try 

i keep getting error @ chromedriver.executescript(..... line as:

started chromedriver (v2.1) on port 63559  system.invalidoperationexception: unknown error: runtime.evaluate threw exceptio n: syntaxerror: unexpected identifier (session info: chrome=28.0.1500.72) (driver info: chromedriver=2.1,platform=windows nt 6.1 sp1 x86_64)  @ openqa.selenium.remote.remotewebdriver.unpackandthrowonerror(response erro  rresponse)  @ openqa.selenium.remote.remotewebdriver.execute(string drivercommandtoexecu  te, dictionary`2 parameters)  @ openqa.selenium.remote.remotewebdriver.executescriptinternal(string script  , boolean async, object[] args)  @ openqa.selenium.remote.remotewebdriver.executescript(string script, object  [] args)  @ vbsetest.popuptest.main() in c:\clearcase\projects\cms\vbsetest\vbsetest\p  opuptest.vb:line 89  [8412:6008:0717/103910:error:textfield.h(162)] not implemented 

the javascript works in selenium ide running script set text field of hidden client hopping similar here. know finds element doesn't run script. other stack answers here, here, or here have not proven need solve issue. appreciated.

i think error in escaping json string:

chromedriver.executescript("var tab=$get('tstabs_clientstate'); tab.value ='{'selectedindexes':['0'],'logentries':[],'scrollstate':{}}'") 

instead, try:

chromedriver.executescript("var tab=$get('tstabs_clientstate'); tab.value =\"{'selectedindexes':['0'],'logentries':[],'scrollstate':{}}\"") 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -