问题
I'm trying to set up a test project for my ASP website. For some tests I want to use selenium to perform end-to-end tests.
Therefor my website has to be running so the tests can access the site.
How can I start my website project when I run tests?
回答1:
Please reference the following links. I believe it is possible, but will be a little tricky. These are detailed and provide information on doing this programmatically.
Starting and stopping IIS Express programmatically
https://www.reimers.dk/jacob-reimers-blog/testing-your-web-application-with-iis-express-and-unit-tests
- The idea is that you would need to start it and navigate to your particular local app in your browser.
- Then you will need to get the window handle of the open browser window
- Then instantiate your Driver object and use the window handle for that instantiation to get Selenium to execute on the open window.
来源:https://stackoverflow.com/questions/25290079/automatically-start-asp-mvc-project-when-running-test-project