I have a grid hub running with some nodes, the grid URL is stored in a c# project App.Config file. My App.Config also specifies which browser to use to run tests against. In a WebDriver factory class I create a new instance of RemoteWebDriver pointing to the grid URL with the proper browser and capabilities.
My question is, what if I want to run my tests locally and bypass the grid sometimes for debugging purposes or whatever, I can specify an additional App.Config key, say Local = true or false, if set to true, don't use RemoteWebDriver. Is there an elegant way to provide this functionality? Can remotewebdriver run tests locally without using the grid? I want to avoid having to create additional factories and check whether the user requested a local run. Has anyone implemented something similar?
You wouldn't need to avoid using RemoteWebDriver
in order to run tests locally. If you download and run the selenium-server-standalone on your local machine (with associated configuration done as well, so browser driver executables, PATH variables, etc), you can simply point your tests to your local hub instead of the remote hub.
Running the Selenium server in standalone mode starts both a hub and node at once with a default configuration (which can be changed via command line args or json config), but it's great for debugging tests without having to run on a production Grid.