On Sunday, 30 September 2012 01:31:52 UTC+1, Hava Edelstein wrote:In the IDE, I use this line:fireEvent | [element] | blur
"fireEvent" is no longer supported in Selenium 2. I know there's TypeKeys, but to my understanding, this doesn't simulate what happens if the user leaves the field by manually clicking in another field with the mouse.
If you're aiming to simulate what happens when a user leaves a field by manually clicking in another field with the mouse, that's exactly what you should do.
Assuming the field with ID someField currently has focus:
driver.findElement(By.id("someOtherField")).click()
will fire all of the relevant events on someField, and then focus someOtherField.
Alternatively, you could (again, assuming someField already has focus), do something like press the tab key:
driver.switchTo().activeElement().sendKeys(Key.TAB)
"fireEvent" is no longer supported in Selenium 2. I know there's TypeKeys, but to my understanding, this doesn't simulate what happens if the user leaves the field by manually clicking in another field with the mouse.
If you're aiming to simulate what happens when a user leaves a field by manually clicking in another field with the mouse, that's exactly what you should do.
Assuming the field with ID someField currently has focus:
driver.findElement(By.id("someOtherField")).click()
will fire all of the relevant events on someField, and then focus someOtherField.
Alternatively, you could (again, assuming someField already has focus), do something like press the tab key:
driver.switchTo().activeElement().sendKeys(Key.TAB)
Manually firing events is a worse and more fiddly way to test than just doing what a user would do :)
http://osdir.com/ml/selenium-users/2012-09/msg02088.html