无法输入与号“&"在Selenium-2中 [英] Unable to type ampersand "&" in Selenium-2

查看:68
本文介绍了无法输入与号“&"在Selenium-2中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要键入&"在带有Selenium Web驱动程序的文本框中键入内容.但是selenium-2在键入&"号时放宽了对类型框的关注.我的命令是self.type(&",:update => true)

I want to type the ampersand "&" key in the text-box with selenium web-driver. But selenium-2 looses its focus from type-box while typing the ampersand. My command is, self.type("&", :update => true)

我知道在硒中,密钥是以UTF_8格式发送的,并且我尝试发送等效的&"号,但是行为仍然相同(与预期的一样).我知道XML或HTML支持与号,并带有一些特殊的转义字符.我想知道是否有一种方法可以用一些转义序列(例如,HTML代码&")替换&"号.或send_keys或type_keys命令中的&"?

I know that in selenium, keys are sent in UTF_8 format and I have tried to send the equivalent of ampersand but the behavior is still same (as expected). I know XML or HTML supports ampersand with some special escape characters. I want to know is there a way to replace the ampersand with some escape sequence like (HTML code) "&" or "&" in send_keys or type_keys command?

或者还有其他方式可以键入&"在带有硒2的文本框中?

OR is there any other way to type the ampersand "&" in the text-box with selenium-2?

请让我知道您的建议.

谢谢, 斯里

推荐答案

我花了数小时在此上花费了数小时,最终@Asaph告诉我暂时删除了所有JavaScript,看看是否是导致与号的原因头脑一片空白."他是正确的.现在$searchBox->send_keys("bath & body");可以正常工作.

I spent hours on this over multiple days, and eventually @Asaph told me "temporarily remove all of your javascript and see if that is what is causing the ampersand to blank out." He was correct. Now $searchBox->send_keys("bath & body"); works fine.

我最终将其范围缩小到Jquery-ui Autocomplete的一部分.这个性质: source:function( request, response ) { //implementation removed } 所有其他javascript都可以保留在原处,并且可以正常工作.现在,我想弄清楚为什么Jquery-ui>自动完成>源与WebDriver冲突,并查看是否有解决方法.

I eventually narrowed it down to one part of Jquery-ui Autocomplete that was interfering. This property: source:function( request, response ) { //implementation removed } All other javascript could remain in place and work fine. I now want to figure out why Jquery-ui > Autocomplete > Source conflicted with WebDriver and see whether there is a workaround.

这篇关于无法输入与号“&"在Selenium-2中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆