在Selenium测试中去除JQuery日期选择器
我正在写一个Selenium测试,目的是在网页上填入一个日期字段。这个字段是和一个JQuery日期选择器关联的。当我用'type'函数输入日期时,日期选择器会弹出来。但是,我无法让它消失,即使我切换焦点、点击其他字段等等。我到现在为止尝试了以下方法……
# Python Code
# Setting the date in the field
sel.focus('tradeDate')
sel.type('tradeDate', '8/16/2011')
# Trying to get rid of the date picker popup, none of these work
sel.key_press('tradeDate', '5') # Trying to TAB out
sel.focus('link=[Search Filters]') # Trying to set focus to something else
sel.focus('searchDirectory') # Trying to set focus to another text field
sel.fire_event('tradeDate', 'blur')
sel.click('//span[@onclick="toggleTradeDetails(\'14859\',this);"]')
以上的方法都没有奏效。我其实并不是在测试JQuery。'tradeDate'字段有自己的点击事件,这是我真正想要测试的。
那么,我该如何让日期选择器的弹出窗口消失呢?我是在IE 8上使用Selenium RC。
2 个回答
0
我通过使用鼠标移动、鼠标按下和鼠标抬起这几个selenium命令,来移动到页面上的另一个输入框,这样就能避免出现日期选择器了。