无法使用 Selenium Chrome 驱动程序设置提示框值

Unable to set Prompt Box value using Selenium Chrome driver

我正在使用 Selenium Chrome 驱动程序在 Chrome 浏览器中自动化 Web 应用程序。我收到无法输入值的提示框弹出窗口。 这是代码-

chromeDriver.SwitchTo().Alert().SendKeys("Some value");

代码执行成功但没有在提示框内的文本框中设置值。 虽然我可以使用此代码获取提示框的文本值-

chromeDriver.SwitchTo().Alert().Text;

我的 Chrome 版本是- 46.0.2490.80

知道为什么它不起作用吗?

试试这个

chromeDriver.switchTo().activeElement().sendKeys("Some value");
try
   {
      IAlert alert = driver.SwitchTo().Alert();
   if (alert != null)
   {
      alert.SendKeys("Some value");
      alert.Accept();
   }
}
catch (Exception ex) { }