views:

567

answers:

2

Hi everyone,

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

A: 

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.

mattsmith321
+1  A: 

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.

Dave Hunt
Thanks Dave! Yes, that does give a truer representation of the UX with the actual control. Since I am just getting started with Selenium and are looking at it for a verification tool, I was mainly focused on just getting something into the field to pass the validation.Yeah, the beautiful IDs are one benefits of ASP.NET WebForms.
mattsmith321