public static void GoToDesiredUrl() { string Url = JsonConfig.GetJsonValue("BaseUrl"); try { var driver = _threadDriver.Value; driver.Navigate().GoToUrl(Url); } catch (Exception e) { } }
public void SetUp() { _homePage = UnityWrapper.Resolve <IHomePage>(); _loginPage = _homePage.ClickOnLoginLink <LoginPage>(); var email = JsonConfig.GetJsonValue("Email"); var password = JsonConfig.GetJsonValue("Password"); _loginPage.EnterEmail(email); _loginPage.EnterPassword(password); _loginPage.CheckRememberMeRadioButton(); _userAccountPage = _loginPage.ClickOnlogInButton <UserAccountPage>(); }
public void SetUp() { _homePage = UnityWrapper.Resolve <IHomePage>(); _random = new Random(); telNumber = _random.Next(100000, 200000000); var value = _random.Next(100, 20000); _loginPage = _homePage.ClickOnLoginLink <LoginPage>(); var email = JsonConfig.GetJsonValue("Email"); var password = JsonConfig.GetJsonValue("Password"); newEmail = $"nsntestaccount{value}@yahoo.com"; _loginPage.EnterEmail(email); _loginPage.EnterPassword(password); _loginPage.CheckRememberMeRadioButton(); _userAccountPage = _loginPage.ClickOnlogInButton <UserAccountPage>(); }
internal static IWebDriver InitializeDriver(string browserType) { string hubIpAddress = JsonConfig.GetJsonValue("HubIpAddress"); remoteWebDriverWaitTime = JsonConfig.GetJsonValue("RemoteWebdriverWait"); elementLoadWaitTime = JsonConfig.GetJsonValue("ElementWaitTime"); pageLoadWaitTime = JsonConfig.GetJsonValue("PageLoad"); IWebDriver _driver = null; var browser = browserType.ToLower(); try { switch (browser) { case "ie": option = new InternetExplorerOptions(); option.AddAdditionalCapability("--window-size=1920,1080", true); option.AddAdditionalCapability("--start-maximized", true); option.AddAdditionalCapability("", true); break; case "chrome": chromeOptions = new ChromeOptions(); //chromeOptions.PlatformName = "LINUX"; chromeOptions.AddArgument("no-sandbox"); chromeOptions.AddArgument("--headless"); //chromeOptions.AddArgument("--start-maximized"); break; case "firefox": option = new FirefoxOptions(); //option.PlatformName = "LINUX"; break; case "edge": option = new EdgeOptions(); option.AddAdditionalCapability("--window-size=1920,1080", true); option.AddAdditionalCapability("--start-maximized", true); break; case "localhost": _driver = new FirefoxDriver(); _driver.Manage().Window.Size = new Size(1920, 1080); _driver.Manage().Window.Maximize(); break; } if (browser.Equals("chrome")) { _driver = new RemoteWebDriver(new Uri($"{hubIpAddress}"), chromeOptions.ToCapabilities(), TimeSpan.FromSeconds(int.Parse(remoteWebDriverWaitTime))); _driver.Manage().Window.Size = new Size(1920, 1080); _driver.Manage().Window.Maximize(); } else if (browser.Equals("firefox")) { _driver = new RemoteWebDriver(new Uri($"{hubIpAddress}"), option.ToCapabilities(), TimeSpan.FromSeconds(int.Parse(remoteWebDriverWaitTime))); _driver.Manage().Window.Size = new Size(1920, 1080); _driver.Manage().Window.Maximize(); } } catch (Exception e) { throw e; } _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(int.Parse(elementLoadWaitTime)); _driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(int.Parse(pageLoadWaitTime)); _driver.Manage().Cookies.DeleteAllCookies(); var allowsDetection = (OpenQA.Selenium.IAllowsFileDetection)_driver; allowsDetection.FileDetector = new LocalFileDetector(); return(_driver); }