我正在使用 Selenium Webdriver 和 C# 编写一个自动化测试,以测试键盘快捷键是否适用于我们的应用程序。这适用于复制/粘贴:
public static void CopyPasteShortcut(string copyFrom, string pasteTo, IWebDriver driver)
{
Common.Helpers.ClickOn(copyFrom, driver);
Actions copy = new Actions(driver);
copy.KeyDown(Keys.Control).SendKeys("c").KeyUp(Keys.Control);
copy.Perform();
Common.Helpers.ClickOn(pasteTo, driver);
Actions paste = new Actions(driver);
paste.KeyDown(Keys.Control).SendKeys("v").KeyUp(Keys.Control);
paste.Perform();
}
那么为什么这不适用于剪切/粘贴呢?
public static void CutPasteShortcut(string cutFrom, string pasteTo, IWebDriver driver)
{
Common.Helpers.ClickOn(cutFrom, driver);
Actions cut = new Actions(driver);
cut.KeyDown(Keys.Control).SendKeys("x").KeyUp(Keys.Control);
cut.Perform();
Common.Helpers.ClickOn(pasteTo, driver);
Actions paste = new Actions(driver);
paste.KeyDown(Keys.Control).SendKeys("v").KeyUp(Keys.Control);
paste.Perform();
}
谢谢你的帮助!