我正在尝试使用 nunit + Selenium + c# 创建一个自动化框架
我们的网络管理员基于 Devexpress 框架,因此我无法通过它的“ID”单击按钮,或者至少我不知道如何操作。对此的替代方法是简单地按下“Enter”按钮。我已经试过了
driver.FindElement(By.XPath("String")).SendKeys(Keys.Enter);
我正在尝试使用 nunit + Selenium + c# 创建一个自动化框架
我们的网络管理员基于 Devexpress 框架,因此我无法通过它的“ID”单击按钮,或者至少我不知道如何操作。对此的替代方法是简单地按下“Enter”按钮。我已经试过了
driver.FindElement(By.XPath("String")).SendKeys(Keys.Enter);
using OpenQA.Selenium.Interactions;
Actions builder = new Actions(driver);
builder.SendKeys(Keys.Enter);
使用下面的代码单击一个不可见的按钮。
IWebElement tmpElement = Driver.FindElement(By.Id("invisibleButton"));
var executor = (IJavaScriptExecutor)Driver;
executor.ExecuteScript("arguments[0].click();", tmpElement);
wait.Until(d => { return d.Title.Equals("pageTitle"); });
RON,在调用 GoToUrl 之后,DOM 可能需要一些时间来加载。增加隐式等待时间,以便 findElement 在抛出任何异常之前等待更多时间。或者使用明确的 wiat --- http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp
如果这仍然不起作用,那么使用 Actions 类 -- http://www.guru99.com/keyboard-mouse-events-files-webdriver.html
Keys.Return()
解决了压制的问题enter