【发布时间】:2013-07-07 07:27:21
【问题描述】:
我正在尝试使用 nunit + Selenium + c# 创建一个自动化框架
我们的网络管理员基于 Devexpress 框架,因此我无法通过它的“ID”点击按钮,或者至少我不知道如何点击。对此的替代方法是简单地按下“Enter”按钮。 我已经试过了
driver.FindElement(By.XPath("String")).SendKeys(Keys.Enter);
【问题讨论】:
-
那么为什么
.Click不起作用? -
我收到此错误。单击“ClassLibrary2.UnitTest1.TestMethod2: OpenQA.Selenium.ElementNotVisibleException:元素当前不可见,因此可能无法与之交互”
-
您可以在查询中包含按钮的 html 吗??
-
'at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:OpenQA 的第 1009 行。 Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 849 at ClassLibrary2.UnitTest1.TestMethod2() in C :\Users\Administrator\documents\visual studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 46 '
-
我的代码看起来像这样... [Test] public void TestMethod2() { driver.Navigate().GoToUrl("localhost/websearch"); driver.FindElement(By.Id("pcLogin_Panel1_txtUsername_I" )).SendKeys("auto test1"); driver.FindElement(By.Id("pcLogin_Panel1_txtPassword_I")).SendKeys("Exchange1"); driver.SendKeys(Keys.Enter).perform; driver.FindElement(By.Id ("pcLogin_Panel1_btnLogon_B")).Click(); Assert.AreEqual("Web Admin - Dashboard", driver.Title); }
标签: c# nunit selenium-webdriver enter