使用 Selenium RC 和 python 选择下一个表单字段
我正在运行自动化测试来测试我公司的网络表单。他们刚刚安装了邮政编码服务,当您填写地址和门牌号时,该服务会自动添加街道和城市/地区。
当您取消选择最后一个表单元素(例如门牌号)时,会出现此自动填充。
这是我正在使用的字段的顺序;
- form:zipcode
- form:housenumber
- form:addition (可选)
- form:street (在提供邮政编码和门牌号码后由服务填写)
- form:city (另一个自动填充字段)
当您手动填写此表单时,地址会立即出现当您单击或按 Tab 键进入添加字段时(因为它是可选的),但是当它自动完成时,它不起作用。
我尝试过一些事情,比如;
- focus('form:addition') 或
- select('form:addition') 但这些不起作用。我尝试使用
- type('\t') 切换到表单字段,并
- 尝试使用 type('form:addition', ' ') 在添加中输入空格。 field 甚至
- type('form:addition', "") 将其留空。到目前为止,这些尝试都没有奏效。
有没有人可以帮助我解决这个问题?
I am running an automated test to test a webform for my company. They have just installed a zipcode service which automatically adds the Street and City/Region when you fill in the Address and housenumber.
This autofill appears when you deselect the last form element (e.g. that of the housenumber).
This is the order of the fields I'm using;
- form:zipcode
- form:housenumber
- form:addition (optional)
- form:street (gets filled in by service after zipcode and housenumber are provided)
- form:city (the other autofill field)
When you fill this form out manually, the address appears as soon as you click or tab into the addition field (as it is optional) but when it's done automated it doesn't work.
I have tried several things like;
- focus('form:addition') or
- select('form:addition') but these don't work. I have tried
- type('\t') to tab to the form field, and
- type('form:addition', ' ') to type a space into the add. field and even
- type('form:addition', "") to leave it empty. None of these attempts have worked so far.
Is there anyone that can help me with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗨,我找到了一个解决方案,我认为
问题是生成与添加字段的用户交互。
使用这些语句
focus("form:addition");
keyPressNative("10") //这是 ENTER 命令,
它应该起作用
Hi i got a solution for this i think,
problem is with generating the user interactions to the addition field.
use these statements
focus("form:addition");
keyPressNative("10") //this is ENTER command
it should work
昨天我发现邮政编码服务使用 Ajax 调用来检索信息。当邮政编码和门牌号字段都“失焦”(即取消选择)时执行此调用。
我发现利用这一点为我带来优势的正确说法是:
selenium.fireEvent('form:number', 'blur') 取消选择输入数据的最后一个字段。
Yesterday I found out that the zipcode service uses an Ajax call to retrieve the information. This call is executed when the zipcode and housenumber fields are both 'out of focus' (i.e. deselected).
The right statement I found to use this in my advantage is this;
selenium.fireEvent('form:number', 'blur') which deselects the last field where data was entered.