【发布时间】:2017-07-06 04:07:48
【问题描述】:
我正在尝试在查看 pdf 文件时在 Chrome 中打开保存文件对话框(通过按 Ctrl+s)。我目前所拥有的似乎没有发送任何击键,因为什么都没有发生。保存文件对话框打开后,我无需担心如何处理它,我只需要打开它即可。这就是我现在拥有的:
Actions action = new Actions(driver);
action.MoveToElement(driver.FindElement(By.TagName("body")));
action.KeyDown(OpenQA.Selenium.Keys.Control).SendKeys("s").KeyUp(OpenQA.Selenium.Keys.Control);
action.Build();
action.Perform();
【问题讨论】:
-
键组合不适用于
Chrome。改用Firefox -
应用程序需要在 Chrome 中进行测试。有没有其他方法可以保存pdf?
-
您可以尝试使用
String pageSource = driver.getPageSource();将文件内容保存为字符串,但我不确定 -
你可以试试键和弦组合。
-
或者怎么样 - action.SendKeys(Keys.Control + "s");
标签: c# selenium selenium-webdriver automated-tests selenium-chromedriver