【问题标题】:How to press TAB button in Windows Security pop-up如何在 Windows 安全弹出窗口中按 TAB 按钮
【发布时间】:2017-07-17 14:40:34
【问题描述】:

我正在尝试使用 OpenQA.Selenium.IAlert 通过发送用户名和密码来处理 Internet Explorer Windows 安全弹出窗口。我需要在此窗口中按 TAB 和 Enter 按钮。键 {TAB} 发送文本而不是按下按钮。有没有什么方法可以在这个窗口中使用 C# 模拟按钮按下?

代码:

    var securityWindow = driver.SwitchTo().Alert();
    securityWindow.SendKeys("username");
    securityWindow.SendKeys("{TAB}");
    securityWindow.SendKeys("Password");
    securityWindow.SendKeys("{ENTER}");

Windows Security window

【问题讨论】:

标签: c# selenium popupwindow


【解决方案1】:

使用键类试试这个。

securityWindow.SendKeys(Keys.Tab);
securityWindow.SendKeys(Keys.Enter);

【讨论】:

  • void SendKeys(string keysToSend) OpenQA.Selenium.IAlert 的成员接受字符串
  • @PavelGalich 您是否尝试将密钥转换为字符串Convert.ToString(Keys.Tab)
  • 它将字符串“Tab”发送到文本框。 OpenQA.Selenium.IAlert SendKeys 它不是 System.Windows.Forms SendKeys。这是不同的方法。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-17
相关资源
最近更新 更多