I'm attempting to perform a popup page test using the chrome webdriver and selenium2 with .NET, but I am encountering some difficulties. After the window pops up, I need to modify the value of an element. Specifically, I need to change the default value from "selectedIndexes":["1"]" to "selectedIndexes":["0"]"
The element in question is:
<input id="tsTabs_ClientState" name="tsTabs_ClientState" type="hidden" autocomplete="off"
value="{"selectedIndexes":["1"], "logEntries":[], "scrollState":{}}">
My current code is as follows: (Both ExecuteScript lines listed below have been attempted)
Dim chromeDriver = New ChromeDriver("C:\clearcase\Projects\CMS\VbSeTest")
Try
'Chrome Test
chromeDriver.Navigate().GoToUrl("http://localhost/CMS/<location>.aspx")
Dim queryC As IWebElement = chromeDriver.FindElement(By.Id("ctl00_cphM_grd_ctl00_ctl02_ctl00_ACI_btnInitInsert"))
queryC.Click()
Dim current As String = chromeDriver.CurrentWindowHandle
Dim windows = chromeDriver.WindowHandles.AsEnumerable
Dim addOrgWindow As IWebDriver
For Each window In windows
If window <> current Then
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 As Exception
chromeDriver.Quit()
MsgBox(e.ToString())
End Try
An error keeps occurring at the line: chromeDriver.ExecuteScript(.....
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)
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response erro
rResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecu
te, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.ExecuteScriptInternal(String script
, Boolean async, Object[] args)
at OpenQA.Selenium.Remote.RemoteWebDriver.ExecuteScript(String script, Object
[] args)
at 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
Although the javascript executed successfully in Selenium IDE for setting the text field of another hidden client, it does not work here. I have reviewed other Stack answers here, here, or here without success in resolving this issue. Any assistance would be greatly appreciated.