Permalink
Switch branches/tags
Nothing to show
Find file Copy path
5724e04 Jul 18, 2016
1 contributor

Users who have contributed to this file

63 lines (55 sloc) 1.85 KB
using System;
using System.Configuration;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;
namespace TestApplication.UiTests.Drivers
{
public class WebDriver
{
private IWebDriver _currentWebDriver;
public IWebDriver Current
{
get
{
if (_currentWebDriver != null)
return _currentWebDriver;
switch (BrowserConfig)
{
case "IE":
_currentWebDriver = new InternetExplorerDriver(new InternetExplorerOptions() { IgnoreZoomLevel = true }) { Url = SeleniumBaseUrl };
break;
case "Chrome":
_currentWebDriver = new ChromeDriver() { Url = SeleniumBaseUrl };
break;
case "Firefox":
_currentWebDriver = new FirefoxDriver() { Url = SeleniumBaseUrl };
break;
default:
throw new NotSupportedException($"{BrowserConfig} is not a supported browser");
}
return _currentWebDriver;
}
}
private WebDriverWait _wait;
public WebDriverWait Wait
{
get
{
if (_wait == null)
{
this._wait = new WebDriverWait(Current, TimeSpan.FromSeconds(10));
}
return _wait;
}
}
protected string BrowserConfig => ConfigurationManager.AppSettings["browser"];
protected string SeleniumBaseUrl => ConfigurationManager.AppSettings["seleniumBaseUrl"];
public void Quit()
{
_currentWebDriver?.Quit();
}
}
}