SimpleBrowserDotNet / SimpleBrowser.WebDriver

A webdriver for SimpleBrowser
Apache License 2.0
43 stars 16 forks source link

Exposing User-agent. #25

Closed AndersBillLinden closed 10 years ago

AndersBillLinden commented 10 years ago

SimpleBrowserDriver.UserAgent setter and getter.

Teun commented 10 years ago

Anders, Thanks for your contribution and sorry for nagging, but I would prefer to do this differently. The idea of WebDriver is that you can use the same interfaces on multiple browser implementations and that the actions performed on that interface should follow the actions that actual users could do in a browser. So you typically do not set a new value to an input box, but perform actions like sending keys.

Setting user agent strings and explicitly setting the HTML of a page are not among those. You can however from your own code do these things on the SimpleBrowser instance being driven. By instantiating the SimpleBrowser yourself and passing it to the WebDriver, you can call whatever methods on the browser you like. This should not be part of the WebDriver implementation.

var browser = new Browser();
// set useragent here
IWebDriver = new SimpleBrowserDriver(new BrowserWrapper(browser));

Do you agree? Are there issues in your use case that prevent this approach? Let me know.

AndersBillLinden commented 10 years ago

Well, it can actually work for me to write: var browser = new SimpleBrowserDriver(new BrowserWrapper(new Browser { UserAgent = "foo" } ));