Testing 如何在不需要打开浏览器的情况下运行Selenium系统测试?

Testing 如何在不需要打开浏览器的情况下运行Selenium系统测试?,testing,selenium,windows-services,webbrowser-control,system-testing,Testing,Selenium,Windows Services,Webbrowser Control,System Testing,我有一个使用Selenium创建的测试方法,类似于: [TestFixture] public class Test_Google { IWebDriver driver; [SetUp] public void Setup() { driver = new InternetExplorerDriver(); } [TearDown] public void

我有一个使用Selenium创建的测试方法,类似于:

[TestFixture]
public class Test_Google
{
        IWebDriver driver;

        [SetUp]
        public void Setup()
        {
            driver = new InternetExplorerDriver();
        }

        [TearDown]
        public void Teardown()
        {
            driver.Quit();
        }

    [Test]
    public void TestSearchGoogleForTheAutomatedTester()
        {
            //Navigate to the site
        driver.Navigate().GoToUrl("http://www.google.co.uk");
        //Find the Element and create an object so we can use it
        IWebElement queryBox = driver.FindElement(By.Name("q"));
        //Work with the Element that's on the page
        queryBox.SendKeys("The Automated Tester");
            queryBox.SendKeys(Keys.ArrowDown);
        queryBox.Submit();
        //Check that the Title is what we are expecting
        Assert.True(driver.Title.IndexOf("The Automated Tester") > -1);
    }
}
当测试运行时,它打开一个IE并执行测试

假设有200种这样的测试方法分布在多个测试装置上,这意味着IE必须多次打开和关闭(因为每个测试装置将打开一个浏览器,所以打开和关闭的次数与测试装置相同)

如何在不需要打开浏览器的情况下运行Selenium系统测试

我的意思是,例如,我想可能可以开发一个windows服务来运行WinForms Web Browser控件中的Selenium测试,在这种情况下,浏览器不必每次都打开,测试可以自动运行且无需查看。但不知道如何实现这一点

或者还有其他更为人熟知的方法吗

谢谢,

您试过XLT吗? 它根本不需要打开浏览器

否。Selenium是用JavaScript编写的;它设计用于在真实浏览器中运行,以测试与真实浏览器的兼容性。还有很多其他的工具被设计用来运行模拟浏览器的测试;你可以研究一下或者


希望这对您有所帮助。

如果您愿意,可以在一个浏览器实例中运行所有测试。您只需将webdriver实例传递给每个测试。就像在一个静态类中有一个Singleton WebDriver,您的所有测试用例都可以从该类访问WebDriver。工作正常,如果你有一个会话要保持,它是有用的

驱动程序=新的HtmlUnitDriver(真); getLogger(“com.gargoylesoftware”).setLevel(Level.OFF)


取决于你如何运行它。您可以使用HtmlUnitDriver,没有GUI也可以,但是当只有真正的浏览器起作用时,您必须使用假X或VNC或类似的东西。