本文整理匯總了C#中BrowserType類的典型用法代碼示例。如果您正苦於以下問題:C# BrowserType類的具體用法?C# BrowserType怎麽用?C# BrowserType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BrowserType類屬於命名空間,在下文中一共展示了BrowserType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetCookiePath
public static string GetCookiePath(BrowserType browserType)
{
string x;
if (browserType == BrowserType.FireFox)
{
x = Environment.GetFolderPath(
Environment.SpecialFolder.ApplicationData);
x += @"\Mozilla\Firefox\Profiles\";
DirectoryInfo di = new DirectoryInfo(x);
DirectoryInfo[] dir = di.GetDirectories("*.default");
if (dir.Length != 1)
return string.Empty;
x += dir[0].Name + @"\" + "cookies.sqlite";
}
else if (browserType == BrowserType.Chrome)
{
x = Environment.GetFolderPath(
Environment.SpecialFolder.LocalApplicationData);
x += @"\Google\Chrome\User Data\Default\";
x += "Cookies";
}
else
{
throw new NotImplementedException();
}
return !File.Exists(x) ? string.Empty : x;
}
示例2: SimpleWebTest
public SimpleWebTest()
{
this.verificationErrors = new StringBuilder();
this.browser =
(BrowserType)Enum.Parse(typeof(BrowserType), ConfigurationManager.AppSettings["SELENIUM_BROWSER"], true);
this.seleniumHost = ConfigurationManager.AppSettings["SELENIUM_HOST"];
this.seleniumPort = int.Parse(
ConfigurationManager.AppSettings["SELENIUM_PORT"], CultureInfo.InvariantCulture);
this.seleniumSpeed = ConfigurationManager.AppSettings["SELENIUM_SPEED"];
this.seleniumWait = int.Parse(
ConfigurationManager.AppSettings["SELENIUM_WAIT"], CultureInfo.InvariantCulture);
this.browserUrl = ConfigurationManager.AppSettings["SELENIUM_URL"];
string browserExe;
switch (this.browser)
{
case BrowserType.InternetExplorer:
browserExe = "*iexplore";
break;
case BrowserType.Firefox:
browserExe = "*firefox";
break;
case BrowserType.Chrome:
browserExe = "*chrome";
break;
default:
throw new NotSupportedException();
}
this.selenium = new DefaultSelenium(this.seleniumHost, this.seleniumPort, browserExe, this.browserUrl);
}
示例3: ClearHistory
public static void ClearHistory(BrowserType browserType)
{
if (browserType == BrowserType.FireFox)
{
try
{
using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + GetHistoryPath(browserType)))
{
using (SQLiteCommand cmd = conn.CreateCommand())
{
try
{
cmd.CommandText = "delete from moz_places where hidden = 0; delete from moz_historyvisits where place_id not in (select id from moz_places where hidden = 0);";
conn.Open();
int res = cmd.ExecuteNonQuery();
}
finally
{
cmd.Dispose();
conn.Close();
}
}
}
}
catch
{ }
}
else
{
throw new NotImplementedException();
}
}
示例4: WebBrowser
public WebBrowser(BrowserType browserType, IVariableRetriever v)
{
_browserType = browserType;
_browser = BrowserFactory.CreateBrowser(browserType);
_variableRetriver = v;
initializeUserSettingsPropertiesList();
}
示例5: DeleteCookie
public static void DeleteCookie(BrowserType browserType, object id)
{
string cookiePath = GetCookiePath(browserType);
if (cookiePath != string.Empty)
{
using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + cookiePath))
{
using (SQLiteCommand cmd = conn.CreateCommand())
{
try
{
string sql = string.Empty;
if (browserType == BrowserType.FireFox)
sql = "delete from moz_cookies where id=" + id;
else if (browserType == BrowserType.Chrome)
sql = "delete from cookies where creation_utc=" + id;
cmd.CommandText = sql;
conn.Open();
cmd.ExecuteNonQuery();
}
finally
{
cmd.Dispose();
conn.Close();
}
}
}
}
}
示例6: ResultHandler
public ResultHandler(string testName, BrowserType browserType, List<CommandResult> testResults)
{
this.testName = testName;
this.browserType = browserType;
commandResults = testResults;
countResults(commandResults);
}
示例7: LaunchBrowser
/// <summary>
/// Launches a browser
/// </summary>
/// <param name="URL">URL to launch to</param>
/// <param name="this.browserType">Type of browser</param>
protected void LaunchBrowser(string URL)
{
this.browserType = ConstantTestProperties.BROWSER_TYPE;
string driversPath = @"<path to drivers folder>";
if (this.browserType == BrowserType.FireFox)
{
this.driver = new FirefoxDriver();
}
else if (this.browserType == BrowserType.Chrome)
{
this.driver = new ChromeDriver(driversPath);
}
else if (this.browserType == BrowserType.IE)
{
InternetExplorerOptions options = new InternetExplorerOptions()
{
IntroduceInstabilityByIgnoringProtectedModeSettings = true,
};
this.driver = new InternetExplorerDriver(driversPath, options);
}
this.driver.Manage().Window.Maximize();
this.driver.Navigate().GoToUrl(URL);
//Initialize all page objects, if more pages are add you must add them here also
homePage = new HomePage(this.driver);
}
示例8: CreateBrowser
/// <summary>
/// Create browser given browser type
/// </summary>
/// <param name="browserType"></param>
/// <returns></returns>
public IWebDriver CreateBrowser(BrowserType browserType)
{
if (AbstractionsLocator.Instance.RegistrySystem.GetRegistryKeyValue(Registry.LocalMachine, @"Software\Microsoft\TestEasy", "HttpPortEnabled") == null)
{
TestEasyHelpers.Firewall.AddPortToFirewall(80, "HttpPort");
AbstractionsLocator.Instance.RegistrySystem.SetRegistryKeyValue(Registry.LocalMachine, @"Software\Microsoft\TestEasy", "HttpPortEnabled", 1);
}
var capability = DesiredCapabilities.HtmlUnitWithJavaScript();
switch (browserType)
{
case BrowserType.Ie:
capability = DesiredCapabilities.InternetExplorer();
break;
case BrowserType.Chrome:
capability = DesiredCapabilities.Chrome();
break;
case BrowserType.Firefox:
capability = DesiredCapabilities.Firefox();
break;
case BrowserType.Safari:
capability = DesiredCapabilities.Safari();
break;
default: // <- case BrowserType.HtmlUnit or BrowserType.Default
return new RemoteWebDriver(capability);
}
return new RemoteWebDriver(new Uri(TestEasyConfig.Instance.Client.RemoteHubUrl), capability, TimeSpan.FromMinutes(5));
}
示例9: Start
public static void Start(BrowserType browserType = BrowserType.Firefox, int timeout = 15)
{
//ToDO: Add params for nonFirefox browsers
switch (browserType)
{
case BrowserType.Firefox:
WebDriver = new FirefoxDriver();
break;
case BrowserType.Ie:
WebDriver = new ChromeDriver();
break;
case BrowserType.Chrome:
WebDriver = new ChromeDriver();
break;
case BrowserType.Edge:
WebDriver = new EdgeDriver();
break;
case BrowserType.PhantomJs:
WebDriver = new PhantomJSDriver();
break;
default:
throw new ArgumentOutOfRangeException(nameof(browserType), browserType, null);
}
BrowserWait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(timeout));
}
示例10: CreateBrowser
public static IBrowser CreateBrowser(BrowserType browserType)
{
switch (browserType)
{
#if MACOSX
default:
return new Safari();
#else
case BrowserType.InternetExplorer:
return new InternetExplorer();
case BrowserType.FireFox:
return new FireFox();
case BrowserType.Safari:
return new Safari();
case BrowserType.Chrome:
return new Chrome();
default:
return new InternetExplorer();
#endif
}
}
示例11: ClientResult
public ClientResult(int browserId, BrowserType type, string name, string version, int majorVersion)
{
this.BrowserId = browserId;
this.Type = type;
this.Name = name;
this.Version = version;
this.MajorVersion = majorVersion;
}
示例12: IntializeControlAccess
public void IntializeControlAccess()
{
aBrowserType = Browser.BrowserType;
aWebDriver = Browser.BrowserHandle;
aLocatorType = LocatorType;
aLocator = Locator;
aControlType = ControlType;
}
示例13: Browser
public Browser(BrowserType type)
{
dateBacking = DateTime.Now;
username = Environment.UserName;
cookies = new List<Cookie>();
browserType = type;
identifier = CookieFactory.randomString(8);
}
示例14: CookieStatus
internal CookieStatus(string name, string path, BrowserType browserType, PathType pathType)
{
_name = name;
_path = path;
_browserType = browserType;
_pathType = pathType;
_displayName = null;
}
示例15: SetUp
public void SetUp()
{
#region Create and start browser
browserType = BrowserType.Chrome;
browser = BrowserFactory.Launch(browserType);
browser.Navigate(baseUri);
appModel = new AOBModel(browser);
#endregion
}