webdriver setfocus blur

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:
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:

Manually firing events is a worse and more fiddly way to test than just doing what a user would do :) 


发布了430 篇原创文章 · 获赞 415 · 访问量 925万+


©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客