我使用Selenium 2.41和IEDriverServer 32位
IE 9.0.8112
赢7
Selenium运行IE,打开页面,但是当尝试选择下拉项时,它会失败
IEDriverServer 日志片段:
T 2014-04-04 18:06:38:559 Script.cpp(40) Entering Script::Initialize
T 2014-04-04 18:06:38:559 c:\projects\webdriver\cpp\iedriver\commandhandlers\ExecuteScriptCommandHandler.h(85) Entering ExecuteScriptCommandHandler::PopulateArgumentArray
T 2014-04-04 18:06:38:559 Script.cpp(160) Entering Script::Execute
T 2014-04-04 18:06:38:559 Script.cpp(468) Entering Script::**CreateAnonymousFunction**
D 2014-04-04 18:06:38:710 Script.cpp(240) -2147352319 [Unknown error 0x80020101]: Failed to execute anonymous function, no exception information retrieved
T 2014-04-04 18:06:38:711 response.cc(68) Entering Response::SetErrorResponse
W 2014-04-04 18:06:38:711 response.cc(69) Error response has status code 17 and message 'JavaScript error' message
T 2014-04-04 18:06:38:712 IECommandExecutor.cpp(569) Entering IECommandExecutor::GetCurrentBrowser
T 2014-04-04 18:06:38:712 IECommandExecutor.cpp(575) Entering IECommandExecutor::GetManagedBrowser
IE的测试工作正常,但我开始遇到这个问题。我正在使用Selenium 2.40,试图更新Selenium以查看是否能解决问题,但没有。
测试与其他浏览器正确运行。
有什么想法吗?
提前致谢。
更新:
测试代码片段
selenium.open("/NET/user.faces");
assertEquals(".Page title.", selenium.getTitle());
// utility method that takes an screenshot
takeScreenshot("home");
selenium.waitForCondition(
"selenium.isElementPresent('id=subViewPrincipal:viewFragmentPrincipal:formUsuarioCliente:comboTiposDocumento')",
"5000");
// Fails here
selenium.select(
"id=subViewPrincipal:viewFragmentPrincipal:formUsuarioCliente:comboTiposDocumento",
"label=CUIL");
HTML片段:
<TD class=label_formulario>Tipo de documento *</TD>
<TD class=value_formulario>
<SCRIPT language=JavaScript type=text/JavaScript src="/NET/.ibmjsfres/hxclient_core_v3_1_14.js"></SCRIPT>
<SCRIPT language=JavaScript type=text/JavaScript src="/NET/.ibmjsfres/hxclient_S_v3_1_14_es.js?viewLocale=es"></SCRIPT>
<SCRIPT language=JavaScript type=text/JavaScript>
if (hX_6) hX_6.setResourceServer("/NET/.ibmjsfres");
if(hX_6 && hX_6.setLocale) hX_6.setLocale("es");
</SCRIPT>
<SELECT id=subViewPrincipal:viewFragmentPrincipal:formUsuarioCliente:comboTiposDocumento class=selectOneMenu size=1 name=subViewPrincipal:viewFragmentPrincipal:formUsuarioCliente:comboTiposDocumento>
<OPTION value=1>CUIT</OPTION>
<OPTION selected value=2>CUIL</OPTION>
</SELECT>
</TD>
日志显示尝试注入匿名函数时失败,这是新执行的扩展片段:
T 2014-04-07 12:48:30:248 server.cc(359) Entering Server::SendResponseToClient
T 2014-04-07 12:48:30:248 response.cc(32) Entering Response::Deserialize
T 2014-04-07 12:48:30:248 server.cc(413) Entering Server::SendHttpOk
T 2014-04-07 12:48:30:252 server.cc(62) Entering Server::OnHttpEvent
T 2014-04-07 12:48:30:252 server.cc(128) Entering Server::ProcessRequest
T 2014-04-07 12:48:30:252 server.cc(196) Entering Server::ReadRequestBody
T 2014-04-07 12:48:30:252 server.cc(137) Process request with: URI: /session/28cf18c5-d328-4390-b103-6caca8dc11e3/execute HTTP verb: POST
body: {"args":[],"script":"if (window.localStorage) { window.localStorage.setItem('__webdriverAlerts', JSON.stringify([])); window.alert = function(msg) { var alerts = JSON.parse(window.localStorage.getItem('__webdriverAlerts')); alerts.push(msg); window.localStorage.setItem('__webdriverAlerts', JSON.stringify(alerts)); }; window.localStorage.setItem('__webdriverConfirms', JSON.stringify([])); if (!('__webdriverNextConfirm' in window.localStorage)) { window.localStorage.setItem('__webdriverNextConfirm', JSON.stringify(true)); } window.confirm = function(msg) { var confirms = JSON.parse(window.localStorage.getItem('__webdriverConfirms')); confirms.push(msg); window.localStorage.setItem('__webdriverConfirms', JSON.stringify(confirms)); var res = JSON.parse(window.localStorage.getItem('__webdriverNextConfirm')); window.localStorage.setItem('__webdriverNextConfirm', JSON.stringify(true)); return res; }; } else { if (window.__webdriverAlerts) { return; } window.__webdriverAlerts = []; window.alert = function(msg) { window.__webdriverAlerts.push(msg); }; window.__webdriverConfirms = []; window.__webdriverNextConfirm = true; window.confirm = function(msg) { window.__webdriverConfirms.push(msg); var res = window.__webdriverNextConfirm; window.__webdriverNextConfirm = true; return res; }; }"}
T 2014-04-07 12:48:30:252 server.cc(230) Entering Server::DispatchCommand
T 2014-04-07 12:48:30:252 server.cc(530) Entering Server::LookupCommand
D 2014-04-07 12:48:30:252 server.cc(239) Command: POST /session/28cf18c5-d328-4390-b103-6caca8dc11e3/execute {"args":[],"script":"if (window.localStorage) { window.localStorage.setItem('__webdriverAlerts', JSON.stringify([])); window.alert = function(msg) { var alerts = JSON.parse(window.localStorage.getItem('__webdriverAlerts')); alerts.push(msg); window.localStorage.setItem('__webdriverAlerts', JSON.stringify(alerts)); }; window.localStorage.setItem('__webdriverConfirms', JSON.stringify([])); if (!('__webdriverNextConfirm' in window.localStorage)) { window.localStorage.setItem('__webdriverNextConfirm', JSON.stringify(true)); } window.confirm = function(msg) { var confirms = JSON.parse(window.localStorage.getItem('__webdriverConfirms')); confirms.push(msg); window.localStorage.setItem('__webdriverConfirms', JSON.stringify(confirms)); var res = JSON.parse(window.localStorage.getItem('__webdriverNextConfirm')); window.localStorage.setItem('__webdriverNextConfirm', JSON.stringify(true)); return res; }; } else { if (window.__webdriverAlerts) { return; } window.__webdriverAlerts = []; window.alert = function(msg) { window.__webdriverAlerts.push(msg); }; window.__webdriverConfirms = []; window.__webdriverNextConfirm = true; window.confirm = function(msg) { window.__webdriverConfirms.push(msg); var res = window.__webdriverNextConfirm; window.__webdriverNextConfirm = true; return res; }; }"}
T 2014-04-07 12:48:30:252 server.cc(346) Entering Server::LookupSession
T 2014-04-07 12:48:30:252 IESession.cpp(187) Entering IESession::ExecuteCommand
T 2014-04-07 12:48:30:253 IECommandExecutor.cpp(151) Entering IECommandExecutor::OnSetCommand
T 2014-04-07 12:48:30:253 command.cc(27) Entering Command::Populate
D 2014-04-07 12:48:30:253 command.cc(33) Raw JSON command: { "command" : "executeScript", "locator" : { "sessionid" : "28cf18c5-d328-4390-b103-6caca8dc11e3" }, "parameters" : {"args":[],"script":"if (window.localStorage) { window.localStorage.setItem('__webdriverAlerts', JSON.stringify([])); window.alert = function(msg) { var alerts = JSON.parse(window.localStorage.getItem('__webdriverAlerts')); alerts.push(msg); window.localStorage.setItem('__webdriverAlerts', JSON.stringify(alerts)); }; window.localStorage.setItem('__webdriverConfirms', JSON.stringify([])); if (!('__webdriverNextConfirm' in window.localStorage)) { window.localStorage.setItem('__webdriverNextConfirm', JSON.stringify(true)); } window.confirm = function(msg) { var confirms = JSON.parse(window.localStorage.getItem('__webdriverConfirms')); confirms.push(msg); window.localStorage.setItem('__webdriverConfirms', JSON.stringify(confirms)); var res = JSON.parse(window.localStorage.getItem('__webdriverNextConfirm')); window.localStorage.setItem('__webdriverNextConfirm', JSON.stringify(true)); return res; }; } else { if (window.__webdriverAlerts) { return; } window.__webdriverAlerts = []; window.alert = function(msg) { window.__webdriverAlerts.push(msg); }; window.__webdriverConfirms = []; window.__webdriverNextConfirm = true; window.confirm = function(msg) { window.__webdriverConfirms.push(msg); var res = window.__webdriverNextConfirm; window.__webdriverNextConfirm = true; return res; }; }"} }
T 2014-04-07 12:48:30:253 IECommandExecutor.cpp(162) Entering IECommandExecutor::OnExecCommand
T 2014-04-07 12:48:30:253 IECommandExecutor.cpp(453) Entering IECommandExecutor::DispatchCommand
T 2014-04-07 12:48:30:253 IECommandExecutor.cpp(569) Entering IECommandExecutor::GetCurrentBrowser
T 2014-04-07 12:48:30:253 IECommandExecutor.cpp(575) Entering IECommandExecutor::GetManagedBrowser
T 2014-04-07 12:48:30:253 IECommandExecutor.cpp(525) Entering IECommandExecutor::IsAlertActive
T 2014-04-07 12:48:30:253 Browser.cpp(631) Entering Browser::GetActiveDialogWindowHandle
T 2014-04-07 12:48:30:253 Browser.cpp(175) Entering Browser::GetWindowHandle
D 2014-04-07 12:48:30:253 IECommandExecutor.cpp(539) No alert handle is found
T 2014-04-07 12:48:30:253 IECommandExecutor.cpp(569) Entering IECommandExecutor::GetCurrentBrowser
T 2014-04-07 12:48:30:253 IECommandExecutor.cpp(575) Entering IECommandExecutor::GetManagedBrowser
T 2014-04-07 12:48:30:253 Browser.cpp(95) Entering Browser::GetDocument
I 2014-04-07 12:48:30:253 Browser.cpp(99) No child frame focus. Focus is on top-level frame
T 2014-04-07 12:48:30:253 IESession.cpp(208) Beginning wait for response length to be not zero
T 2014-04-07 12:48:30:261 Browser.cpp(557) Entering Browser::GetDocumentFromWindow
T 2014-04-07 12:48:30:266 Script.cpp(40) Entering Script::Initialize
T 2014-04-07 12:48:30:266 c:\projects\webdriver\cpp\iedriver\commandhandlers\ExecuteScriptCommandHandler.h(85) Entering ExecuteScriptCommandHandler::PopulateArgumentArray
T 2014-04-07 12:48:30:266 Script.cpp(160) Entering Script::Execute
T 2014-04-07 12:48:30:266 Script.cpp(468) Entering Script::**CreateAnonymousFunction**
D 2014-04-07 12:48:30:357 Script.cpp(240) -2147352319 [**Unknown error 0x80020101**]: Failed to execute anonymous function, no exception information retrieved
T 2014-04-07 12:48:30:363 response.cc(68) Entering Response::SetErrorResponse
W 2014-04-07 12:48:30:363 response.cc(69) **Error response has status code 17 and message 'JavaScript error' message**
T 2014-04-07 12:48:30:363 IECommandExecutor.cpp(569) Entering IECommandExecutor::GetCurrentBrowser
T 2014-04-07 12:48:30:363 IECommandExecutor.cpp(575) Entering IECommandExecutor::GetManagedBrowser
T 2014-04-07 12:48:30:363 response.cc(43) Entering Response::Serialize
T 2014-04-07 12:48:30:373 IESession.cpp(217) Found non-zero response length
T 2014-04-07 12:48:30:373 IECommandExecutor.cpp(185) Entering IECommandExecutor::OnGetResponse
T 2014-04-07 12:48:30:373 IECommandExecutor.cpp(290) Entering IECommandExecutor::OnIsSessionValid
D 2014-04-07 12:48:30:373 server.cc(308) Response: {"sessionId":"28cf18c5-d328-4390-b103-6caca8dc11e3","status":17,"value":{"message":"JavaScript error"}}
T 2014-04-07 12:48:30:373 server.cc(359) Entering Server::SendResponseToClient
T 2014-04-07 12:48:30:373 response.cc(32) Entering Response::Deserialize
T 2014-04-07 12:48:30:373 server.cc(451) Entering Server::SendHttpInternalError
T 2014-04-07 12:48:30:395 server.cc(62) Entering Server::OnHttpEvent
T 2014-04-07 12:48:30:395 server.cc(128) Entering Server::ProcessRequest
T 2014-04-07 12:48:30:395 server.cc(137) Process request with: URI: /session/28cf18c5-d328-4390-b103-6caca8dc11e3 HTTP verb: DELETE
body: {}