【发布时间】:2015-07-02 07:24:52
【问题描述】:
我开始使用 selenium,但遇到了一些问题。
这是我的代码 (c#):
namespace Selenium1
{
[TestClass]
public class UnitTest1
{
FirefoxDriver firefox;
[TestMethod]
public void TestMethod1()
{
firefox = new FirefoxDriver();
firefox.Navigate().GoToUrl("https://www.google.com");
firefox.FindElement(By.Id("gbqfq")).SendKeys("Google");
firefox.FindElement(By.Id("gbqfq")).SendKeys(Keys.Enter);
}
[TestCleanup]
public void TearDown()
{
firefox.Quit();
}
}
}
但不是打开 firefox,而是打开 chrome 并调用错误:
Test method Selenium1.UnitTest1.TestMethod1 threw exception:
OpenQA.Selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"gbqfq"}
我的错误在哪里?
谢谢。
【问题讨论】:
-
你添加了火狐插件吗?
-
看起来很奇怪的问题...您的默认浏览器是什么?
标签: c# selenium-webdriver