使用SendKeys将'@'特殊字符发送到IE 11 [英] Sending '@' special character with SendKeys to IE 11

查看:159
本文介绍了使用SendKeys将'@'特殊字符发送到IE 11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Internet Explorer 11中的SendKeys方法将特殊字符发送到文本框.在尝试在其他浏览器中发送特殊字符时,我没有这个问题,但是Internet Explorer在发送特殊字符时尝试发送特殊字符.

I'm trying to send a special character to a textbox using the SendKeys method in Internet Explorer 11. I didn't have this problem while trying to send special characters in other browsers, but Internet Explorer is sending completely different characters when trying to send special characters.

大多数特殊字符都可以工作(例如!#()$%&/),但@@}之类的字符不起作用,并且在文本框中编写了诸如vbnm之类的字符,而不是这些字符.这些字母代表与密钥Alt Gr结合使用来创建特殊符号的密钥(例如Alt Gr + v = @,Alt Gr + b = {,Alt Gr + n =},Alt Gr + m =§).

Most of the specials characters do work (e.g. !#()$%&/) but the characters like @{}§ are not working, and instead of those characters, something like vbnm is written in the textbox. These letters represents the keys with which the special signs are created in combination with the key Alt Gr (e.g. Alt Gr + v = @, Alt Gr + b = {, Alt Gr + n = }, Alt Gr + m = §).

我尝试使用Action对象通过KeyDown方法发送密钥,但也没有成功,当尝试在其中写入带有'@'的字符串(例如username@mail.com)时,特殊符号被替换为字母"v"(用户名vmail.com).我也尝试使用等效于'@'的ASCII字符,但不是特殊字符,而是在文本框中放置了"64"文本.

I tried using the Action object to send the keys with KeyDown method, but it was also unsuccessful, when trying to write a string with '@' in it (e.g. username@mail.com) the special sign is replaced with the letter 'v' (usernamevmail.com). I also tried to use the ASCII equivalent of the '@' sign but instead of the special character, I got the '64' text placed in the textbox.

private static string UserName
    {
        get { return Browser.GetSingleElement(Login.txtUserName).GetAttribute("value"); }
        set
        {
            if (value == null) return;
            var domElement = Browser.GetSingleElement(Login.txtUserName);
            Actions action = new Actions(Browser._driver);
            action.MoveToElement(domElement);
            action.Perform();
            domElement.Clear();
            action.KeyDown(Keys.LeftAlt);
            action.Perform();
            action.SendKeys(Keys.NumberPad6);
            action.SendKeys(Keys.NumberPad4);
            action.Perform();
            //action.MoveToElement(Browser.GetSingleElement(Login.txtUserName)).Click().KeyDown(Keys.LeftAlt).SendKeys("64").Perform();
            if (!Browser.SendKeys(Browser.GetSingleElement(Login.txtUserName), "@{}§~$%&()="))
                throw new Exception("Failed to send keys on Login.txtUserName DOM element.");
        }
    }

将"@ {}§〜$%&()=字符串发送到文本框时,我将其作为输出.

When sending "@{}§~$%&()=" string to the textbox I get this as an output.

推荐答案

string a = "@{}§~$%&()=";
string b = WebUtility.HtmlDecode(a);

这篇关于使用SendKeys将'@'特殊字符发送到IE 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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