質問

I have a test method created using Selenium, something similar to this:

[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);
    }
}

When the test runs, it opens an IE and carries out its test.

Imagine there are 200 test methods like this spread across multiple test fixtures, which means IE has to be opened and closed many times (as many as test fixtures since 1 browser will be opened per test fixture).

How to run Selenium system tests without requiring to open the browser?

I mean for example I was thinking it might be possible to develop a windows service to run the Selenium tests in the WinForms Web Browser Control, in which case the browser doesn't have to be opened each time and the tests can run automatically and seemlessly. Not sure how to implement this though?

Or is there any other better known way?

Thanks,

役に立ちましたか?

解決

No. Selenium is written in JavaScript; it's designed to run in a real browser to test compatibility with a real browser. There are a variety of other tools out there designed to run tests that simulate a browser; you can look into HtmlUnit or Canoo WebTest.

Hope this will help you.

他のヒント

Have you tried XLT? It doesnt require an open browser at all http://www.xceptance.com/products/xlt/what-is-xlt.html

You can run all your tests in one browser instance if you like. You just have to pass your webdriver instance to each test. Like having a singelton WebDriver in a static class from where all your testcases can access the WebDriver. Works fine and is usefull if you got a session to keep

driver = new HtmlUnitDriver(true); java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top