Can we run Selenium WebDriver Test case with IIS, instead of Visual Studio Development server

前端 未结 1 1615
逝去的感伤
逝去的感伤 2020-12-14 13:35

I am working with Selenium 2 WebDriver. Instead of UnitTest project, i initiate it from website because of following reasons:

  1. It should automatically run every
相关标签:
1条回答
  • 2020-12-14 14:05

    I have managed to find the solution myself.

    Basically, RemoteWebDriver has to be used instead of FirefoxDriver. Steps:

    1. Change the initialization of FirefoxDriver to RemoteWebDriver as:

    Change from

    IWebDriver driver = new FirefoxDriver();
    

    To

    DesiredCapabilities capability = DesiredCapabilities.Firefox();
    Uri url = new Uri("http://REMOTE_IP:4545/wd/hub");
    IWebDriver driver = new RemoteWebDriver(url, capability);
    

    2. Download Selenium Standalone server and initiate it via command prompt using ~

    java -jar E:\Software\selenium-server-standalone-2.24.1.jar -interactive -port 4545
    

    This approach has 2 benefits:

    1. One could use the local IIS for running the test.
    2. Test could be run remotely. Refer Selenium RC documentation. One could see the screenshots remotely using

      REMOTE_IP:4545/wd/hub/static/resource/hub.html

    I am thinking to modify the code of hub.html and client.js file used within it to provide a better Remote feel.

    I hope this can be useful for others as well.

    FYI:

    1. IP address REMOTE_IP could be changed to any realtime IP address OR localhost. Use the above mentioned port while initiating the page request.
    2. Start/Stop code of Standalone Server could be fitted inside the test, so that it is automatically started/stopped via batch file.
    3. Keep the server running by not closing the command prompt.
    0 讨论(0)
提交回复
热议问题