将符号("@")转换为CharSequence [英] convert at symbol ("@") to CharSequence
问题描述
我正在用硒测试站点,我需要向其中一个字段发送电子邮件.到目前为止,我正在使用此Java方法:
I am testing site with selenium and I need to send an e-mail to one of the fields. So far I am using this Java method:
String email = "test@example.com"
WebElement emailField = driver.findElement(By.id("mainForm:accountPanelTabId:1:accountEmails");
emailField.sendKeys(email);
但是由于(对我而言)一个未知的原因,这正是将该值发送到该字段:
But from (to me) uknown reason, this is sending exactly this value to the field:
testvexample.com
(因此基本上将"@"替换为"v")
(so basically the "@" got replaced by "v")
只是出于好奇:我是捷克人,有捷克语键盘.写入"@"符号的一种快捷方式是rightAlt + v,因此我相信可以将其连接...
Just out of curiosity: I am Czech and have Czech keyboard. One shortcut to write "@" symbol is rightAlt + v so I believe this can be connected...
因此,我正在搜索始终写有"@"符号的任何防弹" methot.任何帮助表示赞赏.
So I am searching any "bulletproof" methot which always writes "@" symbol. Any help appreciated.
编辑sendKeys是Selenium的方法,它模拟键盘上的键入.javadoc在这里:
EDIT the sendKeys is method of Selenium, and it simulates typing on keyboard. The javadoc is here: http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebElement.html#sendKeys%28java.lang.CharSequence...%29
推荐答案
以下应该起作用: 字符串email ="test \ u0040example.com";
The following should work: String email = "test\u0040example.com";
对于之前误读问题的歉意.
Apologies for misreading the question earlier.
我认为您将必须使用 Keys
枚举中的正确值来调用 sendKeys
,以模拟获得标志的方式.在和弦中将 Keys.ALT
与您的"v"一起使用:
I think you will have to call sendKeys
using the proper values from the Keys
enum to simulate the way you get your at-sign. Use Keys.ALT
with your "v" in a chord:
sendKeys(Keys.chord(Keys.ALT, "v"));
这篇关于将符号("@")转换为CharSequence的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!