private static void InitializeDriver() { Trace.WriteLine("Starting Browser ..."); string browser = ConfigurationManager.AppSettings["browser"]; string firefoxbinary = ConfigurationManager.AppSettings["ffbinary"]; baseurl = ConfigurationManager.AppSettings["baseurl"]; switch (browser.ToLower()) { case "ie": { var options = new InternetExplorerOptions { EnableNativeEvents = true, // just as an example, you don't need this IgnoreZoomLevel = true, IntroduceInstabilityByIgnoringProtectedModeSettings = true }; globalDriver = new InternetExplorerDriver(options); globalDriver.Manage().Window.Maximize(); globalDriver.Navigate().GoToUrl(baseurl); break; } case "chrome": { var options = new ChromeOptions(); options.AddArguments("chrome.switches", "--disable-extensions --disable-extensions-file-access-check --disable-extensions-http-throttling --disable-infobars --enable-automation --start-maximized"); options.AddUserProfilePreference("credentials_enable_service", false); options.AddUserProfilePreference("profile.password_manager_enabled", false); globalDriver = new ChromeDriver(options); globalDriver.Manage().Window.Maximize(); globalDriver.Navigate().GoToUrl(baseurl); break; } case "firefox": { // Set all desired Firefox profiles using profiles Ini try { FirefoxBinary fbinary = new FirefoxBinary(firefoxbinary); FirefoxProfile profiles = new FirefoxProfile(); globalDriver = new FirefoxDriver(profiles); globalDriver.Manage().Window.Maximize(); globalDriver.Navigate().GoToUrl(baseurl); } catch (Exception e) { Trace.WriteLine("Failure in initializing Firefox Driver: " + e.ToString()); } break; } default: break; } }
private static IWebDriver GetDriverForLocalEnvironment(BrowserType browserToUse) { switch (browserToUse) { case BrowserType.Firefox: FirefoxBinary binary = new FirefoxBinary(Configuration.Configuration.LocalFirefoxBinaryPath); FirefoxProfile profile = new FirefoxProfile(); return(new FirefoxDriver(binary, profile)); case BrowserType.IE: InternetExplorerOptions options = new InternetExplorerOptions { InitialBrowserUrl = "about:blank", IntroduceInstabilityByIgnoringProtectedModeSettings = true, IgnoreZoomLevel = true, RequireWindowFocus = true }; return(new InternetExplorerDriver(Configuration.Configuration.LocalIeDriverServerPath, options)); case BrowserType.Chrome: return(new ChromeDriver(Configuration.Configuration.LocalChromeDriverPath)); default: throw new ArgumentException("Unrecognised browser choice '" + browserToUse + "' when initialising driver for local environment."); } }
/// <summary> /// BROWSER_TYPEの値によって起動するブラウザを変える /// (firefox以外は不安定) /// </summary> /// <param name="webDriver"></param> public static void SelectBrowser(ref IWebDriver webDriver) { switch (AppConfig.GetString(Config.BROWSER_TYPE)) { case "1": // FireFox FirefoxBinary firefoxBinary = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"); FirefoxProfile firefoxProfile = new FirefoxProfile(); webDriver = new FirefoxDriver(firefoxBinary, firefoxProfile); break; case "2": // Chrome webDriver = new ChromeDriver(); break; case "3": // IE // ブラウザのズームレベルを100%にしないと落ちる webDriver = new InternetExplorerDriver(); break; default: throw new OriginalException("BROWSER_TYPEが不正です。1~3の間で設定してください。"); } webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); webDriver.Url = AppConfig.GetString(Config.TEST_URL); }
public FirefoxDriver GetFirefoxDriver() { FirefoxBinary firefox = new FirefoxBinary(PathToFirefox); return(new FirefoxDriver(firefox, new FirefoxProfile())); }
/// <summary> /// Initializes a new instance of the <see cref="ExtensionConnection"/> class. /// </summary> /// <param name="lockObject">An <see cref="ILock"/> object used to lock the mutex port before connection.</param> /// <param name="binary">The <see cref="FirefoxBinary"/> on which to make the connection.</param> /// <param name="profile">The <see cref="FirefoxProfile"/> creating the connection.</param> /// <param name="host">The name of the host on which to connect to the Firefox extension (usually "localhost").</param> public ExtensionConnection(ILock lockObject, FirefoxBinary binary, FirefoxProfile profile, string host) { this.profile = profile; if (binary == null) { this.process = new FirefoxBinary(); } else { this.process = binary; } lockObject.LockObject(this.process.TimeoutInMilliseconds); try { int portToUse = DetermineNextFreePort(host, profile.Port); profile.Port = portToUse; profile.UpdateUserPreferences(); this.process.Clean(profile); this.process.StartProfile(profile, null); SetAddress(host, portToUse); // TODO (JimEvans): Get a better url algorithm. executor = new HttpCommandExecutor(new Uri(string.Format(CultureInfo.InvariantCulture, "http://{0}:{1}/hub/", host, portToUse))); } finally { lockObject.UnlockObject(); } }
public void start() { FirefoxBinary binary = new FirefoxBinary(@"C:\Program Files\Mozilla Firefox\firefox.exe"); driver = new FirefoxDriver(binary, new FirefoxProfile()); wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); }
/// <summary> /// Initializes a new instance of the <see cref="ExtensionConnection"/> class. /// </summary> /// <param name="lockObject">An <see cref="ILock"/> object used to lock the mutex port before connection.</param> /// <param name="binary">The <see cref="FirefoxBinary"/> on which to make the connection.</param> /// <param name="profile">The <see cref="FirefoxProfile"/> creating the connection.</param> /// <param name="host">The name of the host on which to connect to the Firefox extension (usually "localhost").</param> public ExtensionConnection(ILock lockObject, FirefoxBinary binary, FirefoxProfile profile, string host) { this.profile = profile; if (binary == null) { this.process = new FirefoxBinary(); } else { this.process = binary; } lockObject.LockObject(this.process.TimeoutInMilliseconds); try { int portToUse = DetermineNextFreePort(host, profile.Port); profile.Port = portToUse; profile.UpdateUserPreferences(); this.process.Clean(profile); this.process.StartProfile(profile, null); this.SetAddress(host, portToUse); // TODO (JimEvans): Get a better url algorithm. this.executor = new HttpCommandExecutor(new Uri(string.Format(CultureInfo.InvariantCulture, "http://{0}:{1}/hub/", host, portToUse))); } finally { lockObject.UnlockObject(); } }
public void Start() { switch (BaseConfiguration.TestBrowser) { case BrowserType.Firefox: this.driver = new FirefoxDriver(this.FirefoxProfile); break; case BrowserType.FirefoxPortable: var profile = this.FirefoxProfile; var firefoxBinary = new FirefoxBinary(BaseConfiguration.FirefoxPath); this.driver = new FirefoxDriver(firefoxBinary, profile); break; case BrowserType.InternetExplorer: this.driver = new InternetExplorerDriver(this.InternetExplorerProfile); break; case BrowserType.Chrome: this.driver = new ChromeDriver(this.ChromeProfile); break; default: throw new NotSupportedException( string.Format(CultureInfo.CurrentCulture, "Driver {0} is not supported", BaseConfiguration.TestBrowser)); } this.driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(BaseConfiguration.LongTimeout)); this.driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(BaseConfiguration.ShortTimeout)); this.driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(BaseConfiguration.ImplicitlyWaitMilliseconds)); this.driver.Manage().Window.Maximize(); }
private static IWebDriver StartEmbededWebDriver(WebDriverOptions browserOptions) { switch (browserOptions.BrowserName) { case WebDriverOptions.browser_Firefox: path_to_binary = @"C:\Program Files\Mozilla Firefox\firefox.exe"; binary_path_propery = "webdriver.firefox.bin"; FirefoxProfile profile = new FirefoxProfile(); profile.SetPreference(binary_path_propery, path_to_binary); FirefoxBinary binary = new FirefoxBinary(path_to_binary); //return new FirefoxDriver(profile); return(new FirefoxDriver(binary, profile)); case WebDriverOptions.browser_Chrome: return(new ChromeDriver()); case WebDriverOptions.browser_InternetExplorer: return(new InternetExplorerDriver()); case WebDriverOptions.browser_PhantomJS: return(new PhantomJSDriver()); case WebDriverOptions.browser_Safari: return(new SafariDriver()); default: throw new ArgumentException(String.Format(@"<{0}> was not recognized as supported browser. This parameter is case sensitive", browserOptions.BrowserName), "WebDriverOptions.BrowserName"); } }
/// <summary> /// Initializes a new instance of the <see cref="ExtensionConnection"/> class. /// </summary> /// <param name="lockObject">An <see cref="ILock"/> object used to lock the mutex port before connection.</param> /// <param name="binary">The <see cref="FirefoxBinary"/> on which to make the connection.</param> /// <param name="profile">The <see cref="FirefoxProfile"/> creating the connection.</param> /// <param name="host">The name of the host on which to connect to the Firefox extension (usually "localhost").</param> public ExtensionConnection(ILock lockObject, FirefoxBinary binary, FirefoxProfile profile, string host) { this.profile = profile; if (binary == null) { this.process = new FirefoxBinary(); } else { this.process = binary; } lockObject.LockObject(this.process.TimeoutInMilliseconds); try { int portToUse = DetermineNextFreePort(host, profile.Port); profile.Port = portToUse; profile.UpdateUserPreferences(); this.process.Clean(profile); this.process.StartProfile(profile, null); SetAddress(host, portToUse); ConnectToBrowser(this.process.TimeoutInMilliseconds); } finally { lockObject.UnlockObject(); } }
public void Init() { WorkWithPreferencies.LoadPreferenciesFromAppConfig(); String webDriverPath = WorkWithPreferencies.webDriverPath; switch (WorkWithPreferencies.browserType) { case "chrome": driver = new ChromeDriver(webDriverPath); break; case "firefox": FirefoxBinary binary = new FirefoxBinary(webDriverPath); driver = new FirefoxDriver(); break; default: driver = new ChromeDriver(webDriverPath); break; } mp = new MainPage(driver); trbgp = new TechnicalReportsByGroupPage(driver); ddgsp = new DuckDuckGoSearchPage(driver); driver.Manage().Window.Maximize(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); }
private void OpenBrowser(BrowserType browserType = BrowserType.FireFox) { DesiredCapabilities cap = new DesiredCapabilities(); switch (browserType) { case BrowserType.InternetExplorer: //ToDo: Set the Desired capabilities _parallelConfig.Driver = new InternetExplorerDriver(); break; case BrowserType.FireFox: cap.SetCapability(CapabilityType.BrowserName, "firefox"); cap.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows)); var binary = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"); var profile = new FirefoxProfile(); break; case BrowserType.Chrome: cap.SetCapability(CapabilityType.BrowserName, "chrome"); break; } _parallelConfig.Driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), cap); }
public void ordersearch(string ordernnumber) { Thread.Sleep(3000); // Console.WriteLine(driver.s) var binary = new FirefoxBinary(ConfigUtils.Read("FirefoxPath")); // string path = ReadFirefoxProfile(); FirefoxProfile ffprofile = new FirefoxProfile(); // ffprofile.SetPreference("javascript.enabled","false"); IWebDriver driver1 = new FirefoxDriver(binary, ffprofile); // driver = new InternetExplorerDriver(internetExplorerDriverServerDirectory: "\\srv10177\\TEMPSHTIW$\\Desktop\\SIT\\SITSmokeTests\\IEDriverServer.exe"); //driver.Manage().Cookies.DeleteAllCookies(); driver1.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(15)); driver1.Navigate().GoToUrl("https://ofu-sit.azurewebsites.net/orders"); Thread.Sleep(3000); Console.WriteLine(driver1.PageSource); driver1.FindElement(By.XPath(".//div[@class='input-group mb-2 mr-sm-2 mb-sm-0 w-100 quick-search']/input")).SendKeys(ordernnumber); IWebElement element = driver.FindElement(By.XPath("//td[contains(.,'999945 - 1510')]")); String contents = (String)((IJavaScriptExecutor)driver).ExecuteScript("return arguments[0].innerHTML;", element); //extWait //Until(ExpectedConditions.ElementIsVisible(By.XPath(".//td[2]/small/a/span/span[contains(@text(),'"+ordernnumber+"')]"))); //var element = driver.FindElement(By.XPath("//a[contains(.,'999945') and contains(.,'1510')]")); // var element = driver.FindElement(By.XPath(".//div[@class='input-group mb-2 mr-sm-2 mb-sm-0 w-100 quick-search']/input")); IJavaScriptExecutor executor = (IJavaScriptExecutor)driver; try { var s3 = executor.ExecuteScript("document.readyState"); executor.ExecuteScript("document.getElementById('search-result-dropdown').getElementsByTagName('tr')[0].getElementsByTagName('a')[0].href;"); } catch { } try { Console.WriteLine("%%%%%%%%%%%%%%%%%%%%" + executor.ExecuteScript("document.getElementById('search-result-dropdown').getElementsByTagName('tr')[0].getElementsByTagName('a')[0].href;")); }catch { } try { var loca = executor.ExecuteScript("document.getElementById('search-result-dropdown').getElementsByTagName('tr')[0].getElementsByTagName('a')[0].href;"); } catch { } //Actions saction = new Actions(driver); //saction.SendKeys(element,Keys.Enter).Build().Perform(); // .SendKeys(SingleSignon_Email, eMail).Build().Perform(); //driver.FindElement(By.XPath(".//div[@class='input-group mb-2 mr-sm-2 mb-sm-0 w-100 quick-search']/input")).Click(); //driver.FindElement(By.XPath(".//div[@class='input-group mb-2 mr-sm-2 mb-sm-0 w-100 quick-search']/input")).SendKeys(Keys.Enter); // driver.FindElements(By.CssSelector("ng-scope"))[1].Click(); Thread.Sleep(3000); }
public static void Initialize() { FirefoxBinary ffbinary = new FirefoxBinary(@"C:\Program Files\Mozilla Firefox\firefox.exe"); FirefoxProfile ffprofile = new FirefoxProfile(); webDriver = new FirefoxDriver(ffbinary, ffprofile); Goto(""); }
private IWebDriver GetFirefoxDriver() { FirefoxBinary binary = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"); var profile = new FirefoxProfile(); IWebDriver driver = new FirefoxDriver(binary, profile); //IWebDriver driver = new FirefoxDriver(); return(driver); }
public static void Initialize() { var ffbinary = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"); //for Windows 10 Instance = new FirefoxDriver(ffbinary, new FirefoxProfile()); //Instance = new FirefoxDriver(); Instance.Manage() .Timeouts() .ImplicitlyWait(TimeSpan.FromSeconds(5)); }
public WebDriver() { string FireFoxBinaryPath = Properties.Settings.Default.FirefoxBinaryPath; Log.Trace($"Initializing selenium web driver for: {FireFoxBinaryPath}"); FirefoxProfile FirefoxProfile = new FirefoxProfile(); FirefoxBinary FirefoxPortableBinary = new FirefoxBinary(FireFoxBinaryPath); p_Driver = new FirefoxDriver(FirefoxPortableBinary, FirefoxProfile); p_Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); }
public void StartWebBrowser() { InternetExplorerOptions options = new InternetExplorerOptions(); switch (abrowser) { case "Firefox": FirefoxBinary firefoxBinary = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"); FirefoxProfile fireFoxProfile = new FirefoxProfile { AcceptUntrustedCertificates = true }; Driver.CurrentDriver = new FirefoxDriver(firefoxBinary, fireFoxProfile); Driver.CurrentDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); Driver.CurrentDriver.Manage().Window.Maximize(); ngDriver = new NgWebDriver(Driver.CurrentDriver); break; case "Chrome": ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.AddArgument("--ignore-certificate-errors"); Driver.CurrentDriver = new ChromeDriver(); Driver.CurrentDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); Driver.CurrentDriver.Manage().Window.Maximize(); //ngDriver = new NgWebDriver(Driver.CurrentDriver); break; case "IE32": options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; options.EnableNativeEvents = false; options.RequireWindowFocus = true; options.AddAdditionalCapability("ACCEPT_SSL_CERTS", true); Driver.CurrentDriver = new InternetExplorerDriver(); Driver.CurrentDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); Driver.CurrentDriver.Manage().Window.Maximize(); ngDriver = new NgWebDriver(Driver.CurrentDriver); break; case "IE64": options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; options.EnableNativeEvents = false; options.RequireWindowFocus = true; options.AddAdditionalCapability("ACCEPT_SSL_CERTS", true); Driver.CurrentDriver = new InternetExplorerDriver(string.Empty); Driver.CurrentDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); Driver.CurrentDriver.Manage().Window.Maximize(); ngDriver = new NgWebDriver(Driver.CurrentDriver); break; default: System.Console.WriteLine("Browser Selected Not Supported"); break; } }
/// <summary> /// Connect to an instance of the WebDriver Firefox extension. /// </summary> /// <param name="binary">The <see cref="FirefoxBinary"/> in which the extension is hosted.</param> /// <param name="profile">The <see cref="FirefoxProfile"/> in which the extension is installed.</param> /// <param name="host">The host name of the computer running the extension (usually "localhost").</param> /// <returns>An <see cref="ExtensionConnection"/> connected to the WebDriver Firefox extension.</returns> /// <exception cref="WebDriverException">If there are any problems connecting to the extension.</exception> public static ExtensionConnection ConnectTo(FirefoxBinary binary, FirefoxProfile profile, string host) { int profilePort = profile.Port; ExtensionConnection connection = null; using (ILock lockObject = new SocketLock(profilePort - 1)) { connection = new ExtensionConnection(lockObject, binary, profile, host); } return(connection); }
private static void UseLocalWebDriver() { switch (config.Browser) { case "firefox": FirefoxBinary fb = new FirefoxBinary(config.DefaultBrowser); //driverCache = new FirefoxDriver(desFF); break; case "iexplore": var options = new InternetExplorerOptions(); options.IgnoreZoomLevel = true; options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; options.EnsureCleanSession = true; driverCache = new InternetExplorerDriver(config.IeServer, options); break; case "chrome": var chromeOptions = new ChromeOptions(); chromeOptions.AddArguments(new[] { "--start-maximized", "allow-running-insecure-content", "--test-type" }); chromeOptions.Proxy = DriverProxy; driverCache = new ChromeDriver(config.ChromeServer, chromeOptions); driverCache.Navigate().GoToUrl("localhost"); break; case "phantomjs": var phantomjsOptions = new PhantomJSOptions(); driverCache = new PhantomJSDriver(phantomjsOptions); driverCache.Navigate().GoToUrl("localhost"); break; case "safari": driverCache = new SafariDriver(new SafariOptions()); driverCache.Navigate().GoToUrl("localhost"); break; case "opera": break; case "iphone": break; case "ipad": break; } }
private static IWebDriver GetWebDriver() { var profile = new FirefoxProfile(); //Add any arguments based on your network/project/your needs. profile.AcceptUntrustedCertificates = false; profile.AssumeUntrustedCertificateIssuer = false; profile.DeleteAfterUse = false; var binary = new FirefoxBinary(); FirefoxCoypuDriver = new FirefoxDriver(binary, profile); return(FirefoxCoypuDriver); }
public void Run_once_before_anything() { var profile = new FirefoxProfile(); profile.Clean(); var exe = new FirefoxBinary(); browser = new FirefoxDriver(exe, profile); wait = new WebDriverWait(browser, TimeSpan.FromSeconds(10)); }
public FirefoxOptionsEx(FirefoxProfile profile, FirefoxBinary binary) { KnownCapabilityNames.Clear(); if (profile != null) { this.Profile = profile; } if (binary != null) { var executable = typeof(FirefoxBinary).GetField("executable", BindingFlags.NonPublic).GetValue(binary); var s = executable.GetType().GetProperty("ExecutablePath").GetValue(executable) as string; this.BrowserExecutableLocation = s; } }
/// <summary> /// Initializes a new instance of the <see cref="ExtensionConnection"/> class. /// </summary> /// <param name="binary">The <see cref="FirefoxBinary"/> on which to make the connection.</param> /// <param name="profile">The <see cref="FirefoxProfile"/> creating the connection.</param> /// <param name="host">The name of the host on which to connect to the Firefox extension (usually "localhost").</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public ExtensionConnection(FirefoxBinary binary, FirefoxProfile profile, string host, TimeSpan commandTimeout) { this.host = host; this.timeout = commandTimeout; this.profile = profile; if (binary == null) { this.process = new FirefoxBinary(); } else { this.process = binary; } }
private static FirefoxDriverServiceEx CreateOptionsFromCapabilities(ICapabilities capabilities) { FirefoxBinary binary = ExtractBinary(capabilities); DesiredCapabilities capabilities2 = RemoveUnneededCapabilities(capabilities) as DesiredCapabilities; FirefoxDriverServiceEx options = new FirefoxDriverServiceEx(ExtractProfile(capabilities), binary); if (capabilities2 != null) { foreach (KeyValuePair<string, object> pair in capabilities2.ToDictionary()) { options.AddAdditionalCapability(pair.Key, pair.Value); } } return options; }
private static ICommandExecutor CreateExtensionConnection(FirefoxBinary binary, FirefoxProfile profile, TimeSpan commandTimeout) { FirefoxProfile profile2 = profile; string environmentVariable = Environment.GetEnvironmentVariable("webdriver.firefox.profile"); if ((profile2 == null) && (environmentVariable != null)) { profile2 = new FirefoxProfileManager().GetProfile(environmentVariable); } else if (profile2 == null) { profile2 = new FirefoxProfile(); } return new FirefoxDriverCommandExecutor(binary, profile2, "localhost", commandTimeout); }
public void Test_Setup() { FirefoxBinary fb; if (!String.IsNullOrWhiteSpace(Settings.CurrentSettings.FirefoxBinaryPath)) { fb = new FirefoxBinary(Settings.CurrentSettings.FirefoxBinaryPath); } else { fb = new FirefoxBinary(); } CurrentDriver = new FirefoxDriver(); }
private void ChooseDriverInstance(BrowserType browserType) { if (browserType == BrowserType.Chrome) { int lrg = 1920; // Longeur ICI int lng = 1080; // Largeur ICI int lngForScreenShot = lng + (Int32)127; int lrgForScreenShot = lrg + 37; ChromeOptions options = new ChromeOptions(); //options.AddArgument("--headless"); options.AddArgument("--window-size=" + lrg + "," + lngForScreenShot); //options.EnableMobileEmulation("iPhone 6 Plus"); _driver = new ChromeDriver(@"C:/WEBDRIVER", options); _driver.Manage().Window.Maximize(); } else if (browserType == BrowserType.Firefox) { FirefoxBinary binary = new FirefoxBinary(@"C:/Program Files/Mozilla Firefox/firefox.exe"); FirefoxProfile firefoxProfile = new FirefoxProfile(); //FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(); //service.FirefoxBinaryPath = @"C:\\Program Files\\Mozilla Firefox"; //service.HideCommandPromptWindow = true; //service.SuppressInitialDiagnosticInformation = true; //_driver = new FirefoxDriver(); _driver = new FirefoxDriver(binary, firefoxProfile); _driver.Manage().Window.Maximize(); } else if (browserType == BrowserType.IE) { _driver = new InternetExplorerDriver(@"C:/WEBDRIVER"); _driver.Manage().Window.Maximize(); } else if (browserType == BrowserType.Edge) { _driver = new EdgeDriver(@"C:/WEBDRIVER"); _driver.Manage().Window.Maximize(); } else if (browserType == BrowserType.Opera) { _driver = new OperaDriver("C:/WEBDRIVER"); _driver.Manage().Window.Maximize(); } else if (browserType == BrowserType.HeadLess) { _driver = new PhantomJSDriver("C:/WEBDRIVER"); _driver.Manage().Window.Maximize(); } }
public void StartWebBrowser() { FirefoxBinary ffBinary = new FirefoxBinary(ConfigurationSettings.AppSettings["ffBinary"]); // Create a FireFox profile and add the FireBug and FirePath to the browser object FirefoxProfile ffProfile = new FirefoxProfile(); // FireFox Addins are not working when using SpecRun //ffProfile.AddExtension(ConfigurationSettings.AppSettings["firebug"]); //ffProfile.AddExtension(ConfigurationSettings.AppSettings["firepath"]); // Create FireFox Driver object using the profile above Driver.CurrentDriver = new FirefoxDriver(ffBinary, ffProfile); Driver.CurrentDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30)); Driver.CurrentDriver.Manage().Window.Maximize(); }
private IWebDriver SetFirefoxDriver() { try { var binary = new FirefoxBinary(@"C:\Program Files(x86)\Mozilla Firefox\firefox.exe"); var profile = new FirefoxProfile(); profile.AcceptUntrustedCertificates = true; profile.DeleteAfterUse = true; return(new FirefoxDriver(profile)); } catch (Exception) { throw; } }
/// <summary> /// Returns an instance of Firefox based driver. /// </summary> /// <returns>FireFox based driver</returns> private static IWebDriver FireFoxWebDriver() { // Proxy setup starts here OpenQA.Selenium.Proxy proxy = new OpenQA.Selenium.Proxy(); //start fiddler and get the port used int proxyport = FiddlerProxy.StartFiddlerProxy(0); //use SslProxy for https sites proxy.SslProxy = string.Format("127.0.0.1:{0}", proxyport); FirefoxProfile profile = new FirefoxProfile(); profile.AssumeUntrustedCertificateIssuer = false; // get Log Execution Path String getExecutingPath = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName; // set profile preferences profile.SetPreference("FireFox" + DateTime.Now.Ticks + ".log", getExecutingPath); profile.SetPreference("browser.helperApps.alwaysAsk.force", false); profile.SetPreference("browser.download.folderList", 2); profile.SetPreference("browser.download.dir", AutomationConfigurationManager.DownloadFilePath.Replace("file:\\", "")); profile.SetPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false); profile.SetPreference("browser.download.useDownloadDir", true); profile.SetPreference("browser.download.downloadDir", AutomationConfigurationManager.DownloadFilePath.Replace("file:\\", "")); profile.SetPreference("browser.download.defaultFolder", AutomationConfigurationManager.DownloadFilePath.Replace("file:\\", "")); profile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/zip, application/x-zip, application/x-zip-compressed, application/download, application/octet-stream"); profile.EnableNativeEvents = true; profile.SetPreference("browser.cache.disk.enable", false); profile.SetPreference("browser.cache.memory.enable", false); profile.SetPreference("browser.cache.offline.enable", false); profile.SetPreference("network.http.use-cache", false); //set proxyperference profile.SetProxyPreferences(proxy); //to be sure that it picks up 32bit of ff always string sBrowserExe = "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"; FirefoxBinary Bin = new FirefoxBinary(sBrowserExe); IWebDriver webDriver = new FirefoxDriver(); // set page load duration webDriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(TimeOut)); // set cursor position center of the screen Cursor.Position = new Point(Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2); return(webDriver); }
public void SetUp() { var binary = new FirefoxBinary(ConfigUtils.Read("FirefoxPath")); // string path = ReadFirefoxProfile(); FirefoxProfile ffprofile = new FirefoxProfile(); driver = new FirefoxDriver(binary, ffprofile); // driver = new InternetExplorerDriver(internetExplorerDriverServerDirectory: "\\srv10177\\TEMPSHTIW$\\Desktop\\SIT\\SITSmokeTests\\IEDriverServer.exe"); driver.Manage().Cookies.DeleteAllCookies(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(15)); // Before each test wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60)); datafilePath = ConfigUtils.Read("TestDataPath"); sGMethods = new GeneralMethods(); intigrationmon = new MOnitorUI(driver); iccPortal = new ICCBAMPageObj(driver); }