1
selectctrl = @browser.select(:xpath, "//select[id='foo']")
selectctrl.select("Open")
  • in FireFox and Chrome this fires other events in jquery, in IE, you see the UI change to Open for the select box, but nothing is fired
  • I have looked at the events fired in firebug and tried to call fire_event("change") and other events that are shown, but nothing works
  • Code works in FireFox 5, Chrome 12, does not work in IE 9 using
  • latest gems on Ruby 1.8.7 patchlevel 334 on Windows
Željko Filipin
  • 56,372
  • 28
  • 94
  • 125
Jim
  • 61
  • 6
  • Did you check which javascript events get fired? http://stackoverflow.com/questions/3787555/how-to-find-out-which-javascript-events-fired – Željko Filipin Aug 11 '11 at 08:35
  • Yes, using firebug and setting logging to the select element it showed the standard javascript elements which I tried to call using fire_event. Though it works in firefox and not in IE 9. – Jim Aug 18 '11 at 19:15

1 Answers1

1

Try:

selectctrl.select 'open'
selectctrl.fire_event 'change'

You should avoid using xpath, it is problematic in IE, and less readable

selectctrl = @browser.select :id => 'foo'
Alister Scott
  • 3,675
  • 24
  • 41
  • We use xpath to select html controls, id's and class's changes but custom html attributes are always constant (especially in .net 3.5 websites). Does IE not support xpath correctly. We have no problems in FireFox and Chrome using xpath across 4 thousand steps. – Jim Aug 10 '11 at 15:10
  • Yes, I had already tried that, it doesn't error, but it also doesn't do anything in IE 9 except change the select ctrl to Open, but the other events that are hooked to a change (enable another button) are not firing. While in Chrome and FireFox they do. – Jim Aug 10 '11 at 15:12
  • seriously only use xpath when you need to, it's also generally slower. also for my money this is more streamlined and easier to read --- browser.select_list(:id, 'foo').select('Open') --- as it gives you in one line both the element you are acting on, and the action you are taking. – Chuck van der Linden Aug 12 '11 at 06:47
  • You can create custom elements like testid = 'Login' and always do browser.button(:xpath, "//button[@testid='Login']") and never have to worry about a developer change in id or class, or a language change that would cause your automation to fail. Why not use XPATH? How hard is that to read? There is only one element that has testid = Login on the entire page. Yes, I notice it is slower, but it's always guaranteed. – Jim Aug 16 '11 at 21:17