硒 + JavaScript + Infragistics WebDateChooser

发布于 2024-08-22 17:54:47 字数 1381 浏览 10 评论 0原文

我正在为我们的一个具有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

晨敛清荷 2024-08-29 17:54:47

尽管您的解决方案有效,但它没有像用户那样与 WebDateChooser 进行交互。这可能就是您想要的,但是在快速查看 http://samples.infragistics.com/2007.3/webfeaturebrowser/WebDateChooser/Grid/webform1.aspx 我能够编写一个简单的脚本来与 WebDateChooser 交互:

clickAt        | id=UltraWebGrid1_rc_0_5
waitForVisible | id=WebDateChooser1_img
clickAt        | id=WebDateChooser1_img
waitForVisible | id=WebDateChooser1_DrpPnl_Calendar1_504
select         | id=WebDateChooser1_DrpPnl_Calendar1_504 | label=July
select         | id=WebDateChooser1_DrpPnl_Calendar1_506 | label=1978
click          | id=WebDateChooser1_DrpPnl_Calendar1_d13

这些定位器使用 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:

clickAt        | id=UltraWebGrid1_rc_0_5
waitForVisible | id=WebDateChooser1_img
clickAt        | id=WebDateChooser1_img
waitForVisible | id=WebDateChooser1_DrpPnl_Calendar1_504
select         | id=WebDateChooser1_DrpPnl_Calendar1_504 | label=July
select         | id=WebDateChooser1_DrpPnl_Calendar1_506 | label=1978
click          | id=WebDateChooser1_DrpPnl_Calendar1_d13

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.

浮华 2024-08-29 17:54:47

最后偶然发现了它。虽然我现在对命令和值使用不同的值,但实际上是从目标中删除了“javascript{...}”语法,从而使我克服了错误。

getEval | this.browserbot.getUserWindow().igdrp_getComboById('ctl00_MainBody_ctl00_tdosDatePicker').setValue(new Date('2009-05-31')) | 

这是另一种方法:
该事件使用 fireEvent 在字段中输入文本后触发 onblur 事件。我通过 我是如何学会喜欢 Selenium 的 fireEvent

type | ctl00_MainBody_ctl00_fdosDatePicker_input | 01/01/2010
fireEvent | ctl00_MainBody_ctl00_fdosDatePicker_input | blur

拥有多个选项来完成所有这一切很好。

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.

getEval | this.browserbot.getUserWindow().igdrp_getComboById('ctl00_MainBody_ctl00_tdosDatePicker').setValue(new Date('2009-05-31')) | 

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

type | ctl00_MainBody_ctl00_fdosDatePicker_input | 01/01/2010
fireEvent | ctl00_MainBody_ctl00_fdosDatePicker_input | blur

Having multiple options to do all of this is nice.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文