硒 + JavaScript + Infragistics WebDateChooser
我正在为我们的一个具有 Infragistics WebDateChooser 的页面进行 Selenium 测试。我花了一段时间才到达可以从 Selenium 测试中设置日期字段的位置,但我终于得到了一些东西:
waitForEval | javascript{this.browserbot.getUserWindow().igdrp_getComboById('ctl00_MainBody_ctl00_fdosDatePicker').setValue(new Date('2005-05-31'))} | dump
代码可以工作,但它在 Selenium IDE 中抛出错误:
[错误]意外异常:消息 -> eval(match[1]) 未定义,fileName -> chrome://selenium-ide/content/selenium/scripts/selenium-api.js, lineNumber ->; 2464,堆栈-> (“javascript{this.browserbot.getUserWindow().igdrp_getComboById('ctl00_MainBody_ctl00_fdosDatePicker').setValue(新日期('2005-05-31'))}”)@chrome://selenium-ide/content/selenium/scripts /selenium-api.js:2464 ()@chrome://selenium-ide/content/selenium/scripts/selenium-executionloop.js:109 ()@chrome://selenium-ide/content/selenium/scripts/selenium -executionloop.js:78 continueCurrentTest()@chrome://selenium-ide/content/selenium-runner.js:335 (true)@chrome://selenium-ide/content/debugger.js:165 ("cmd_selenium_step" )@chrome://selenium-ide/content/editor.js:233 doCommand("cmd_selenium_step")@:0 goDoCommand("cmd_selenium_step")@chrome://global/content/globalOverlay.js:96 oncommand([对象XULCommandEvent])@chrome://selenium-ide/content/selenium-ide.xul:1 ,名称 ->类型错误
我尝试了几个不同的命令(waitForEval、storeEval 等),但它们都抛出相同的错误。
对我应该尝试的其他事情有什么建议吗?
谢谢, 马特
I am working on Selenium tests for one of our pages that has an Infragistics WebDateChooser. It took me a while to get to where I could set the date field from the Selenium test, but I finally got something to work:
waitForEval | javascript{this.browserbot.getUserWindow().igdrp_getComboById('ctl00_MainBody_ctl00_fdosDatePicker').setValue(new Date('2005-05-31'))} | dump
The code works but it throws an error in the Selenium IDE:
[error] Unexpected Exception: message -> eval(match[1]) is undefined, fileName -> chrome://selenium-ide/content/selenium/scripts/selenium-api.js, lineNumber -> 2464, stack -> ("javascript{this.browserbot.getUserWindow().igdrp_getComboById('ctl00_MainBody_ctl00_fdosDatePicker').setValue(new Date('2005-05-31'))}")@chrome://selenium-ide/content/selenium/scripts/selenium-api.js:2464 ()@chrome://selenium-ide/content/selenium/scripts/selenium-executionloop.js:109 ()@chrome://selenium-ide/content/selenium/scripts/selenium-executionloop.js:78 continueCurrentTest()@chrome://selenium-ide/content/selenium-runner.js:335 (true)@chrome://selenium-ide/content/debugger.js:165 ("cmd_selenium_step")@chrome://selenium-ide/content/editor.js:233 doCommand("cmd_selenium_step")@:0 goDoCommand("cmd_selenium_step")@chrome://global/content/globalOverlay.js:96 oncommand([object XULCommandEvent])@chrome://selenium-ide/content/selenium-ide.xul:1 , name -> TypeError
I have tried a couple different of the command (waitForEval, storeEval, etc.) but they are all throwing the same error.
Any suggestions for other things I should try?
Thanks,
Matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尽管您的解决方案有效,但它没有像用户那样与 WebDateChooser 进行交互。这可能就是您想要的,但是在快速查看 http://samples.infragistics.com/2007.3/webfeaturebrowser/WebDateChooser/Grid/webform1.aspx 我能够编写一个简单的脚本来与 WebDateChooser 交互:
这些定位器使用 ID,看起来它们可能是动态的且不可靠的。如果是这样,您可能需要研究一些更可靠的 XPath 或 CSS 定位器。
Although your solution works, it's not interacting with the WebDateChooser as a user would. This might be what you want, however after having a quick look at the with example demo at http://samples.infragistics.com/2007.3/webfeaturebrowser/WebDateChooser/Grid/webform1.aspx I was able to put together a simple script to interact with the WebDateChooser:
These locators are using the IDs, that look like they may be dynamic and unreliable. If so, you might want to look into some more reliable XPath or CSS locators.
最后偶然发现了它。虽然我现在对命令和值使用不同的值,但实际上是从目标中删除了“javascript{...}”语法,从而使我克服了错误。
这是另一种方法:
该事件使用 fireEvent 在字段中输入文本后触发 onblur 事件。我通过 我是如何学会喜欢 Selenium 的 fireEvent
拥有多个选项来完成所有这一切很好。
Finally stumbled on it. While I am now using different values for Command and Value, it was really removing the 'javascript{...}' syntax from the Target that got me past the error.
And here is another approach:
This one uses fireEvent to get the onblur event to fire after entering text in the field. I found it via How I learned to love Selenium’s fireEvent
Having multiple options to do all of this is nice.