0

I am using

email.SendKeys("myemail@gmail.com")

but sometimes is putting myemail2gmail.com, is putting 2 instead of @, I already did a quick research and I would like to know if this is the best solution

email.SendKeys("myemail" + Keys.Shift + "2" + Keys.Shift + "gmail.com");

The issue is in IE 11 and I am using browserstack with specflow in Visual Studio c#.

budi
  • 6,351
  • 10
  • 55
  • 80
Marion
  • 335
  • 1
  • 4
  • 15

2 Answers2

0

I've heard about people having issues with sendkeys in combination with special characters in IE and Edge browsers. Indeed, the correct way to do this is:

email.SendKeys("myemail@gmail.com")

If that does not work, you can try using Javascript as a workaround to input the email address into the field. Something like this:

IWebElement email = driver.FindElement(By.Id("email"));

IJavaScriptExecutor js = driver as IJavaScriptExecutor;
string script = "arguments[0].setAttribute('value', 'arguments[1]');";
js.ExecuteScript(script, email, "dummy@user.de");
Agent Shoulder
  • 586
  • 8
  • 22
-1

I used something similar than @Agent Shoulder said

var _element= driver.FindElement(By.Id("id"));
IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
js.ExecuteScript("arguments[0].setAttribute('value', 'email@gmail.com')", _element);
Marion
  • 335
  • 1
  • 4
  • 15