using System.Collections.Generic;
using System.Reflection;
namespace RuriLib.ViewModels
{
///
/// The Type of supported Browser to drive via selenium.
///
public enum BrowserType
{
/// Google Chrome
Chrome,
/// Mozilla Firefox
Firefox
}
///
/// Provides selenium-related settings.
///
public class SettingsSelenium : ViewModelBase
{
private BrowserType browser = BrowserType.Chrome;
/// The Browser to be used.
public BrowserType Browser { get { return browser; } set { browser = value; OnPropertyChanged(); } }
private bool headless = false;
/// Whether to run the browser in Headless mode (--headless argument).
public bool Headless { get { return headless; } set { headless = value; OnPropertyChanged(); } }
private string firefoxBinaryLocation = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
/// The location of the firefox.exe binary on disk.
public string FirefoxBinaryLocation { get { return firefoxBinaryLocation; } set { firefoxBinaryLocation = value; OnPropertyChanged(); } }
private string chromeBinaryLocation = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
/// The location of the chrome.exe binary on disk.
public string ChromeBinaryLocation { get { return chromeBinaryLocation; } set { chromeBinaryLocation = value; OnPropertyChanged(); } }
private List chromeExtensions = new List();
/// The list of .crx extensions for Chrome inside the ChromeExtensions folder. Extensions don't work in Headless mode!
public List ChromeExtensions { get { return chromeExtensions; } set { chromeExtensions = value; OnPropertyChanged(); } }
private bool drawMouseMovement = true;
/// Whether to draw red dots to follow the mouse movement when a MOUSEACTION command is issued.
public bool DrawMouseMovement { get { return drawMouseMovement; } set { drawMouseMovement = value; OnPropertyChanged(); } }
private int pageLoadTimeout = 60;
/// The default timeout for page load in the browser.
public int PageLoadTimeout { get { return pageLoadTimeout; } set { pageLoadTimeout = value; OnPropertyChanged(); } }
///
/// Resets the properties to their default value.
///
public void Reset()
{
SettingsSelenium def = new SettingsSelenium();
IList props = new List(typeof(SettingsSelenium).GetProperties());
foreach (PropertyInfo prop in props)
{
prop.SetValue(this, prop.GetValue(def, null));
}
}
}
}