Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Selenium-SendKeys(“发送键”)写一个“发送键”à&引用;_C#_.net_Selenium_Selenium Webdriver - Fatal编程技术网

C# Selenium-SendKeys(“发送键”)写一个“发送键”à&引用;

C# Selenium-SendKeys(“发送键”)写一个“发送键”à&引用;,c#,.net,selenium,selenium-webdriver,C#,.net,Selenium,Selenium Webdriver,我开始使用Selenium来测试我的网站,但是当我在InternetExplorer上测试它时,函数SendKeys(“@”)写的是“a”,而不是“@” 否则,它在Chrome和FF上运行良好 如果你有答案………..:) 这是我的密码: IWebElement loginInput = driver.FindElement(By.Id("login-inputEl")); loginInput.SendKeys("test@test.fr"); 泰 试试这个 l

我开始使用Selenium来测试我的网站,但是当我在InternetExplorer上测试它时,函数SendKeys(“@”)写的是“a”,而不是“@”

否则,它在Chrome和FF上运行良好

如果你有答案………..:)

这是我的密码:

        IWebElement loginInput = driver.FindElement(By.Id("login-inputEl"));
        loginInput.SendKeys("test@test.fr");

试试这个

loginInput.SendKeys(System.Net.WebUtility.HtmlDecode("test@test.fr"));

我得到了解决方案,以便在IE驱动程序中使用selenium编写“@”! 使用法语键盘时,您需要按图形键“ALT GR”和键“a”以获得“@”,然后,您需要告诉Selenium执行相同的操作

loginInput.SendKeys("test"); // the beginning of my email adress
var actions = new OpenQA.Selenium.Interactions.Actions(driver);
actions.KeyDown(Keys.Control).KeyDown(Keys.LeftAlt); // I press my graph key "ALT GR"
actions.SendKeys("à"); // Then, my key "@"
actions.KeyUp(Keys.Control).KeyUp(Keys.LeftAlt); // I release my key
actions.Build().Perform(); // execute
loginInput.SendKeys("test.fr"); // the end of my email adress

在为这个问题挣扎了几天之后,我找到了一个实用的解决方案,可以让我们轻松地输入包含@的电子邮件地址

str电子邮件=”username@domain.com"; Driver.Instance.FindElement(By.Name(“用户名”)).SendKeys(电子邮件)

这应该可以解决问题。我试图以var的形式输入电子邮件,并且总是以q的形式输入@符号(我有西班牙语lat-kb),而且。。。str做得很好

我希望您可以在测试中使用此提示


再见。

在Java中,我解决了转换字符列表中的输入字符串并将其与特殊字符进行比较的问题

static String charsSpecial = "@#[]€";
我的方法是这样的

public static void insertValueExplorer(WebDriver driver, WebDriverWait mywait, String locator, String variable) {
        mywait.until(ExpectedConditions.elementToBeClickable(By.xpath(locator))).clear();   
        if(driver.toString().contains("InternetExplorerDriver")){
            List<Character> chars = Utils.convertStringToCharList(variable);
            int j=0;
            while(j<chars.size())
            { 
                if (charsSpecial.contains(chars.get(j).toString())){
                
                    mywait.until(ExpectedConditions.elementToBeClickable(By.xpath(locator))).sendKeys(Keys.chord(Keys.CONTROL, Keys.ALT, chars.get(j).toString())); 
                }else{
                    mywait.until(ExpectedConditions.elementToBeClickable(By.xpath(locator))).sendKeys(chars.get(j).toString()); 
                }
                j=j+1;
            }
        }else {
            mywait.until(ExpectedConditions.elementToBeClickable(By.xpath(locator))).sendKeys(variable);    
        }
    }

publicstaticvoid insertValueExplorer(WebDriver驱动程序、WebDriverWait mywait、字符串定位器、字符串变量){
mywait.until(ExpectedConditions.elementToBeClickable(By.xpath(locator))).clear();
if(driver.toString().contains(“InternetExplorerDriver”)){
List chars=Utils.convertStringToCharList(变量);
int j=0;

而(在我的美国键盘上,“@”是shift+2。你的键盘上有什么?(我不知道这是否是问题,只是一个粗略的猜测)如果你使用
loginInput.SendKeys(“\u0040”)它能工作吗
取而代之的是?嗨,它像以前一样在写“a”…很好的尝试,你使用的是非英语键盘吗?这个网站也是非英语网站吗?我使用的是法语键盘,这个网站是法语的。什么是str?这是一个C#问题,所以不是字符串?