【问题标题】:Chrome instead of firefox, element not foundChrome而不是Firefox,找不到元素
【发布时间】: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


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 2020-05-16
  • 2020-11-12
  • 2018-01-24
  • 2011-10-05
  • 1970-01-01
  • 2016-04-17
  • 1970-01-01
  • 2015-12-30
相关资源
最近更新 更多