private static void InitializeWebDriver() { switch (Configuration.BrowserType) { case BrowserType.Firefox: WebDriver = new FirefoxDriver(); break; case BrowserType.InternetExplorer: var ieOptions = new InternetExplorerOptions { EnableNativeEvents = true, EnablePersistentHover = true, EnsureCleanSession = true, UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Dismiss }; WebDriver = new InternetExplorerDriver("./", ieOptions); break; case BrowserType.Chrome: var chromeOptions = new ChromeOptions(); chromeOptions.AddArguments("test-type"); WebDriver = new ChromeDriver("./", chromeOptions); break; default: throw new ArgumentException("Unknown browser type is specified!"); } WebDriver.Manage().Window.Maximize(); WebDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(Configuration.ImplicitWaitTime)); }
private static void ExecuteScript(IWebDriver wd) { try { //wd.Manage().Window.Maximize(); //Console.WriteLine("Browser Maximizado"); wd.Navigate().GoToUrl("http://www.minhaseconomias.com.br"); Console.WriteLine("Acessado o Site Minhas Economias"); wd.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); wd.FindElement(By.ClassName("login")).Click(); wd.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); Console.WriteLine("Clicado no Botão de 'Entrar'"); wd.FindElement(By.Id("email")).SendKeys("*****@*****.**"); Console.WriteLine("Digitado o Login (E-mail)"); wd.FindElement(By.Id("senha")).SendKeys("abc@123"); Console.WriteLine("Digitada a Senha"); wd.FindElement(By.Id("login")).FindElement(By.Name("OK")).Click(); Console.WriteLine("Clicado no botão 'Entrar'"); } finally { wd.Close(); } }
public DocfxSeedSiteFixture() { JObject token = JObject.Parse(File.ReadAllText(ConfigFile)); var folder = (string)token.SelectToken("site"); var port = (int)token.SelectToken("port"); Driver = new FirefoxDriver(); Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); Driver.Manage().Window.Maximize(); try { var fileServerOptions = new FileServerOptions { EnableDirectoryBrowsing = true, FileSystem = new PhysicalFileSystem(folder), }; Url = $"{RootUrl}:{port}"; WebApp.Start(Url, builder => builder.UseFileServer(fileServerOptions)); } catch (System.Reflection.TargetInvocationException) { Console.WriteLine($"Error serving \"{folder}\" on \"{Url}\", check if the port is already being in use."); } }
public void TestInit() { _driver = new FirefoxDriver(); _driver.Manage().Window.Maximize(); _driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); _driver.Navigate().GoToUrl(Facebook); }
public static void logout(IWebDriver driver) { driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(0)); System.Collections.ObjectModel.ReadOnlyCollection<IWebElement> e = driver.FindElements(By.LinkText("Logout")); if (e.Count > 0) e.First().Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(Config.implicitTimeout)); }
public void HomepageTabsTickle(Datarow datarow, IWebDriver driver, string url) { try { driver.Navigate().GoToUrl(url); Thread.Sleep(0xbb8); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10.0)); driver.FindElement(By.XPath("//body[@id='page-home-index']/div/div[2]/div/ul/li/div/div/a/h2")); driver.FindElement(By.XPath("//body[@id='page-home-index']/div/div[2]/div/ul/li/div/div/a/h2")).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10.0)); driver.FindElement( By.XPath("//body[@id='page-categories-details']/div/div[2]/div/ul/li/div/div/a/h2")); driver.FindElement(By.XPath("//body[@id='page-categories-details']/div/div[2]/div/ul/li/div/div/a/h2")) .Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10.0)); driver.FindElement(By.XPath("//body[@id='page-categories-details']/div/div[2]/div/ul/li/div/div/a/p")); driver.FindElement(By.XPath("//body[@id='page-categories-details']/div/div[2]/div/ul/li/div/div/a/p")) .Click(); } catch (Exception exception) { var actual = exception.ToString(); datarow.Newrow("Exception", "Not Expected", actual, "FAIL", driver); } }
public void StartupBase() { driver = new FirefoxDriver(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(Constants.MidleDelay)); driver.Manage().Window.Maximize(); Driver.SetDriver(driver); }
public void InitDriver() { if (!Directory.Exists(@"P:\LabsDeploymentItems")) throw new Exception(@"Unable to locate P:\LabsDeploymentItems"); switch (Properties.Settings.Default.BROWSER) { case BrowserType.Chrome: WebDriver = new ChromeDriver(driversLocation); break; case BrowserType.Ie: InternetExplorerOptions opts = new InternetExplorerOptions(); opts.EnsureCleanSession = true; opts.IntroduceInstabilityByIgnoringProtectedModeSettings = true; WebDriver = new InternetExplorerDriver(driversLocation, opts); break; case BrowserType.Firefox: WebDriver = new FirefoxDriver(); break; default: throw new ArgumentException("Invalid BROWSER Setting has been used"); } WebDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(Properties.Settings.Default.IMPLICIT_WAIT_SECONDS)); WebDriver.Manage().Window.Maximize(); }
public DocfxSeedSiteFixture() { JObject token = JObject.Parse(File.ReadAllText(ConfigFile)); var folder = (string)token.SelectToken("site"); var port = (int)token.SelectToken("port"); Driver = new FirefoxDriver(); Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); Driver.Manage().Window.Maximize(); try { var contentTypeProvider = new FileExtensionContentTypeProvider(); // register yaml MIME as OWIN doesn't host it by default. // http://stackoverflow.com/questions/332129/yaml-mime-type contentTypeProvider.Mappings[".yml"] = "application/x-yaml"; var fileServerOptions = new FileServerOptions { EnableDirectoryBrowsing = true, FileSystem = new PhysicalFileSystem(folder), StaticFileOptions = { ContentTypeProvider = contentTypeProvider } }; Url = $"{RootUrl}:{port}"; WebApp.Start(Url, builder => builder.UseFileServer(fileServerOptions)); } catch (System.Reflection.TargetInvocationException) { Console.WriteLine($"Error serving \"{folder}\" on \"{Url}\", check if the port is already being in use."); } }
private static IWebDriver OptimizeDriver(IWebDriver driver) { driver.Manage().Window.Maximize(); driver.Manage().Cookies.DeleteAllCookies(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30)); return driver; }
public void Initialize() { _driver = new FirefoxDriver(); _actions = new Actions(_driver); _driver.Url = "http://www.ramyamlab.com/"; _driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); _driver.Manage().Window.Maximize(); }
public void SetUp() { _driver = DriverSetup.Driver; _driver.Manage().Window.Maximize(); _driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); _driver.Navigate().GoToUrl(TestConfiguration.ApplicationUrl); homePage = new HomePage(_driver); }
// Use method to initialize drivers // driver - Selenium webdriver // browser- Selenium webdriver wrapped with protractor - for angular files public static void TestBaseInitialize() { browser = new ChromeDriver(ConfigurationManager.AppSettings["ChromeDriverPath"]); driver = new NgWebDriver(browser); var timeout = Convert.ToInt32(ConfigurationManager.AppSettings["DriverScriptTimeout"], CultureInfo.InvariantCulture); driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(timeout)); driver.Manage().Window.Maximize(); }
public void ClassInitialize() { launcher.Start(); driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Manage().Cookies.DeleteAllCookies(); driver.Navigate().GoToUrl("https://accounts.google.com/ServiceLogin?service=mail&continue=https://mail.google.com/mail/#identifier"); }
public SeleniumRunner() { Driver = new DriverService().GetBrowserForDriver(ConfigurationManager.AppSettings["DefaultBrowser"]); Driver.Navigate().GoToUrl(ConfigurationManager.AppSettings["DefaultUrl"]); double defaultWaitTime = Convert.ToDouble(ConfigurationManager.AppSettings["DefaultImplicitlyWait"]); Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(defaultWaitTime)); Driver.Manage().Window.Maximize(); }
public static void Initialize() { baseUrl = "http://52Projects.dev.mymissionsapp.com"; webDriver = new FirefoxDriver(new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\Firefox.exe"), new FirefoxProfile(), TimeSpan.FromMinutes(defaultTimeout)); //webDriver = new ChromeDriver(); webDriver.Manage().Window.Maximize(); webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(defaultTimeout)); }
public static void Initialize() { Instance = new FirefoxDriver(); // TurnOnWait(); Instance.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); // Instance.Manage().Window.Size = new Size(1024, 768); // for specific browser size Instance.Manage().Window.Maximize(); // full screen }
public void SetUp() { driver = new FirefoxDriver(); driver.Manage().Window.Size = new System.Drawing.Size(800, 600); driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(60)); ngDriver = new NgWebDriver(driver); wait = new WebDriverWait(driver, TimeSpan.FromSeconds(wait_seconds)); actions = new Actions(driver); }
public tstObject(int typNum) { brwsrType = typNum; switch (typNum) { //create a Chrome object case 1: { var options = new ChromeOptions(); //set the startup options to start maximzed options.AddArguments("start-maximized"); //start Chrome maximized driver = new ChromeDriver(@Application.StartupPath, options); //Wait 10 seconds for an item to appear driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4)); break; } //create an IE object case 2: { //var options = new InternetExplorerOptions(); //set the startup options to start maximzed //options.ToCapabilities(); driver = new InternetExplorerDriver(@Application.StartupPath); //maximize window driver.Manage().Window.Maximize(); //Wait 4 seconds for an item to appear driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4)); break; } default: { FirefoxProfile profile = new FirefoxProfile(); profile.SetPreference("webdriver.firefox.profile", "cbufsusm.default"); profile.AcceptUntrustedCertificates = true; driver = new FirefoxDriver(profile); //profile //maximize window driver.Manage().Window.Maximize(); //Wait 4 seconds for an item to appear driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4)); break; } } }
/// <summary> /// Function to Inoke the Application URL /// </summary> /// <param name="Driver"></param> public void InvokeURL(IWebDriver Driver) { Driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 5)); Driver.Url = ConfigurationManager.AppSettings["AuthDevUrl"]; Driver.Navigate().GoToUrl(Driver.Url); Driver.Manage().Window.Maximize(); Driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 5)); }
public void Init() { driver = new FirefoxDriver(); // Open web page driver.Navigate().GoToUrl("https://e.mail.ru/login"); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); driver.Manage().Window.Maximize(); Assert.AreEqual("Вход - Почта Mail.Ru", driver.Title); }
public static void Initialize() { Driver = new FirefoxDriver(); ICookieJar cookieJar = Driver.Manage().Cookies; cookieJar.DeleteAllCookies(); Driver.Manage().Window.Maximize();//Раскрытие веб окна на весь экран TurnOnWait(); }
public void Start() { Driver = new WebDriverFactory().CreateDriver(Settings.Browser); Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3)); Driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(3)); Driver.Manage().Cookies.DeleteAllCookies(); _mainWindow = Driver.CurrentWindowHandle; }
public static IWebDriver GetInstance() { if (driver == null) { driver = CreateDriver(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30)); driver.Manage().Window.Maximize(); } return driver; }
public static IWebDriver GetInstance() { if (driver == null) { //driver = new FirefoxDriver(); driver = new ChromeDriver(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); driver.Manage().Window.Maximize(); } return driver; }
public BaseObject(IWebDriver driver) { Driver = driver; Driver.Manage() .Timeouts() .ImplicitlyWait( TimeSpan.FromSeconds(30.0)); Driver.Manage().Window.Maximize(); }
protected override bool Run(IWebDriver driver) { var testSuccessful = false; Log("testSuccessful: " + testSuccessful.ToString()); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30)); driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(30)); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30)); try { driver.Navigate().GoToUrl(baseURL + "/index.html"); driver.FindElement(By.CssSelector("dd.foto > a > img")).Click(); driver.FindElement(By.LinkText("comprar")).Click(); //Se for um produto que tenha serviço, não seleciona nenhum [serviço] e vai embora if (driver.Url.IndexOf("DetalheServico.aspx") > -1) { Log("É página de serviço"); Log("Checkbox ckbLiConcordoGarantia:" + driver.IsElementPresent(By.Id("ckbLiConcordoGarantia")).ToString()); driver.FindElement(By.Id("ckbLiConcordoGarantia")).Click(); Log("Checkbox ckbLiConcordoGarantia:" + driver.IsElementPresent(By.ClassName("btAvancar")).ToString()); driver.FindElement(By.ClassName("btAvancar")).Click(); } driver.FindElement(By.CssSelector("img.bt_limpar")).Click(); driver.FindElement(By.Id("txtEmail")).Clear(); driver.FindElement(By.Id("txtEmail")).SendKeys("*****@*****.**"); driver.FindElement(By.Id("txtSenha")).Clear(); driver.FindElement(By.Id("txtSenha")).SendKeys("321321"); driver.FindElement(By.CssSelector("a.btOk.enviaForm > span")).Click(); driver.FindElement(By.Id("182638")).Click(); driver.FindElement(By.XPath("//a[contains(@rel,'boletoItau')]")).Click(); driver.FindElement(By.CssSelector("input.txtcpfcnpjboleto")).Clear(); driver.FindElement(By.CssSelector("input.txtcpfcnpjboleto")).SendKeys("34238009843"); driver.FindElement(By.CssSelector("img[alt=\"Clique aqui para Finalizar a compra\"]")).Click(); testSuccessful = driver.IsElementPresent(By.Id("nrPedido")); driver.FindElement(By.CssSelector("#btVoltar > img")).Click(); driver.FindElement(By.LinkText("sair")).Click(); Log("testSuccessful: " + testSuccessful.ToString()); return testSuccessful; } catch (Exception ex) { Log("Exception -> " + ex.Message); return false; } }
public void TestInit() { _iwd = new FirefoxDriver(); _iwd.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); _iwd.Manage().Window.Maximize(); _iwd.Navigate().GoToUrl("qaworks.com"); Assert.AreEqual("Home Page - QAWorks", _iwd.Title); _iwd.FindElement(By.LinkText("Contact")).Click(); Assert.AreEqual("Contact Us - QAWorks", _iwd.Title); }
public void Deleteshop(IWebDriver driver) { driver.FindElement(By.LinkText("MoShop")).Click(); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30000)); driver.FindElement(By.CssSelector("#IndexMenuLeaf3 > a")).Click(); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30000)); driver.FindElement(By.LinkText("testshop")).Click(); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30000)); driver.FindElement(By.LinkText("Delete")).Click(); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30000)); driver.FindElement(By.CssSelector("p.submit.submitInline > input.button")).Click(); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30000)); }
//public LoginHelper LoginHelper { get; set; } public Driver() { _instance = new FirefoxDriver(new FirefoxBinary(), new FirefoxProfile(), TimeSpan.FromMinutes(3)); Log.Info(string.Format("Web Driver initializes")); _instance.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(50)); _instance.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(50)); Log.Info(string.Format("Web Driver sets up timeouts")); _instance.Manage().Cookies.DeleteAllCookies(); Log.Info(string.Format("Web Driver deletes cokies")); _instance.Manage().Window.Maximize(); Log.Info(string.Format("Web Driver maximizes window")); //LoginHelper =new LoginHelper(_instance); }
public override void AddCookie(System.Net.Cookie cookie) { base.AddCookie(cookie); // 如果 Downloader 在运行中, 需要把 Cookie 加到 Driver 中 _driver?.Manage().Cookies.AddCookie(new OpenQA.Selenium.Cookie(cookie.Name, cookie.Value, cookie.Domain, cookie.Path , null)); }
protected override void AddCookieToDownloadClient(System.Net.Cookie cookie) { if (!_domains.Contains(cookie.Domain)) { _domains.Add(cookie.Domain); } _webDriver?.Manage().Cookies.AddCookie(new Cookie(cookie.Name, cookie.Value, cookie.Domain, cookie.Path, null)); }
/// <summary> /// Sets the browser timeout to 1 minute when nothing is mentioned. /// </summary> /// <param name="span">Time out to wait for an element or operation</param> private void SetBrowserTimeOut(TimeSpan?span = null) { IOptions options = _webDriver?.Manage(); ITimeouts timeouts = options?.Timeouts(); if (timeouts != null) { TimeSpan waitAMinute = span ?? new TimeSpan(0, 1, 0); timeouts.ImplicitlyWait(waitAMinute); } }
public static void Init(Microsoft.VisualStudio.TestTools.UnitTesting.TestContext context) { // driver.Navigate().GoToUrl("http://jupiter.cloud.planittesting.com"); driver.Manage().Window.Maximize(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15); }
public void LaunchApplication() { _driver?.Navigate().GoToUrl(HomeUrl); _driver?.Manage().Window.Maximize(); }
public Google(IWebDriver driver) { _driver = driver; _driver.Manage().Window.Maximize(); }
public void BeforeScenario() { driver = new ChromeDriver("F:\\ChromeDR"); driver.Manage().Window.Maximize(); }
public static void WindowMaximise() { driver.Manage().Window.Maximize(); }
public void WaitForLoad() { _driver?.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); }
private static void Main(string[] args) { // Retrieve the user variables, these should be set through github secrets _username = Environment.GetEnvironmentVariable("epicname"); _password = Environment.GetEnvironmentVariable("epicpass"); _captcha = Environment.GetEnvironmentVariable("captcha"); // optional: search in telegram for the bot "epic games yoinker, send him a message after a while he send you the id" _telegram = Environment.GetEnvironmentVariable("telegram"); // Check if the arguments are valid. if (ValidateArguments() == false) { return; } // create an instance of the webdriver _driver = new ChromeDriver(); // create an instance of the webdriver waiter. _wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(50)); // maximize the window. _driver.Manage().Window.Maximize(); // if the cookie was not retrieved successfully. if (GetCookie(_captcha) == false) { Console.WriteLine("Failed to retrieve authentication cookie."); return; } // Try to login. if (Login(_username, _password) == false) { return; } Thread.Sleep(5000); // Retrieve the game urls. foreach (var url in GetFreeGamesUrls()) { var status = Status.Failed; for (var i = 0; i < 5; i++) { status = ClaimGame(url); if (status == Status.Success) { SendTelegram(url, status); break; } if (status == Status.Owned) { break; } } if (status == Status.Failed) { SendTelegram(url, status); } } Console.WriteLine("process finished"); }
[TestInitialize] // this will be the 1st to run public void SetUpTest() { _driver = new ChromeDriver(); _driver.Manage().Window.Maximize(); _driver.Navigate().GoToUrl("http://demo.nopcommerce.com/"); }
public ValidCandidateCase OpenSite(IWebDriver webDriver, string url) { webDriver.Manage().Window.Maximize(); webDriver.Navigate().GoToUrl(url); return(this); }
public void openApplication(String appUrl, int implicitWait) { driver.Manage().Window.Maximize(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(implicitWait); driver.Navigate().GoToUrl(appUrl); }
public void BeforeScenarioMain() { //Set the Driver using the options set in the pre-step IWebDriver Driver; scenarioContext.TryGetValue("Browser", out var browser); //Get options by browser, instantiate and register drivers switch (browser) { case "BrowserStack_iOS11": var browserstackIOS11 = scenarioContext.Get <SafariOptions>("options"); Driver = new RemoteWebDriver( new Uri("https://hub-cloud.browserstack.com/wd/hub/"), browserstackIOS11); try { Driver.Manage().Cookies.DeleteAllCookies(); } catch (NotImplementedException) { } objectContainer.RegisterInstanceAs(Driver); break; case "Grid_Android_Chrome": var gridAndroidChrome = scenarioContext.Get <AppiumOptions>("options"); Driver = new AndroidDriver <IWebElement>(EnvironmentConfig.Instance.SGrid.RemoteHubURI, gridAndroidChrome); objectContainer.RegisterInstanceAs(Driver); break; case "Grid_OperaBlink": var op = scenarioContext.Get <DesiredCapabilities>("options"); Driver = new RemoteWebDriver(EnvironmentConfig.Instance.SGrid.RemoteHubURI, op); Driver.Manage().Cookies.DeleteAllCookies(); objectContainer.RegisterInstanceAs(Driver); break; case "Grid_Firefox": var gffo = scenarioContext.Get <FirefoxOptions>("options"); Driver = new RemoteWebDriver(EnvironmentConfig.Instance.SGrid.RemoteHubURI, gffo); Driver.Manage().Cookies.DeleteAllCookies(); objectContainer.RegisterInstanceAs(Driver); break; case "Grid_Chrome_Headless": case "Grid_Chrome": var gco = scenarioContext.Get <ChromeOptions>("options"); Driver = new RemoteWebDriver(EnvironmentConfig.Instance.SGrid.RemoteHubURI, gco); Driver.Manage().Cookies.DeleteAllCookies(); objectContainer.RegisterInstanceAs(Driver); break; case "Firefox": var ffo = scenarioContext.Get <FirefoxOptions>("options"); //Known issue with geckodriver and Net Core, refer to: https://stackoverflow.com/questions/53629542/selenium-geckodriver-executes-findelement-10-times-slower-than-chromedriver-ne var svc = FirefoxDriverService.CreateDefaultService(); svc.Host = "::1"; Driver = new FirefoxDriver(svc, ffo); Driver.Manage().Cookies.DeleteAllCookies(); objectContainer.RegisterInstanceAs(Driver); break; case "Chrome": case "Headless": default: var co = scenarioContext.Get <ChromeOptions>("options"); Driver = new ChromeDriver(co); Driver.Manage().Cookies.DeleteAllCookies(); objectContainer.RegisterInstanceAs(Driver); break; } }
public void openRealestatePage() { realestateCategory.Click(); browser.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); showRealestate.Click(); browser.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); }
public void startBrowser() { driver = new ChromeDriver(); driver.Manage().Window.Maximize(); }
public void TestInizialize() { driver = new ChromeDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://www.ultimateqa.com/simple-html-elements-for-automation/"); }
public static void SendEnter(string inputId) { IWebElement element = webDriver.FindElement(By.Id(inputId)); webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3)); element.SendKeys(Keys.Enter); }
/// <summary> /// 尝试保存一个image元素到本地 /// </summary> /// <param name="strIDOrXPath"></param> /// <param name="strFilename"></param> /// <returns></returns> public bool SaveImageBySnapshot(string strIDOrXPath, string strFilename) { try { IWebElement webElem = null; do { try { webElem = (m_Driver as RemoteWebDriver).FindElementById(strIDOrXPath); if (webElem != null) { break; } } catch {} try { webElem = (m_Driver as RemoteWebDriver).FindElementByXPath(strIDOrXPath); if (webElem != null) { break; } } catch {} // 其他获取方法在此扩展 } while (false); if (webElem == null) { Console.WriteLine($"[Error] WebDriver snapshot save iamge by id failed. Error = can not find {strIDOrXPath}"); return(false); } if ((m_Driver as RemoteWebDriver) != null) { var shotDriver = (m_Driver as ITakesScreenshot); if (shotDriver == null) { Console.WriteLine($"[Error] WebDriver snapshot save iamge by id failed. shotDriver is null"); return(false); } else { m_Driver.Manage().Window.Maximize(); //shotDriver.GetScreenshot().SaveAsFile("C:\\f**k.jpg", ImageFormat.Jpeg); } // 截取全屏,然后拆出元素部分保存 Point ElemPoint = webElem.Location; Point WindowPoint = (m_Driver as RemoteWebDriver).Manage().Window.Position; int nElemWidth = webElem.Size.Width; int nElemHeight = webElem.Size.Height; var ss = shotDriver.GetScreenshot(); int nWebBrowserWidth = (m_Driver as RemoteWebDriver).Manage().Window.Size.Width; int nWebBrowserHeight = (m_Driver as RemoteWebDriver).Manage().Window.Size.Height; Bitmap fullScreenImg = (Bitmap)Image.FromStream(new MemoryStream(ss.AsByteArray)); Size imageSize = new Size(Math.Min(nElemWidth, fullScreenImg.Width), Math.Min(nElemHeight, fullScreenImg.Height)); Rectangle rect = new Rectangle(ElemPoint, imageSize); Image final = fullScreenImg.Clone(rect, fullScreenImg.PixelFormat); final.Save(strFilename, ImageFormat.Bmp); final.Dispose(); /* * // 灰度->二值化->降噪处理 * Bitmap bitmap = new Bitmap(final); * Bitmap afterGray = FKImageLibrary.Gray.GrayScale(bitmap, 1); * Bitmap afterBinary = FKImageLibrary.Gray.BinaryZation(afterGray, binaryPara); * Bitmap afterDenoise = FKImageLibrary.Gray.NoiseReduction(afterBinary); * * afterDenoise.Save(strFilename, ImageFormat.Bmp); * afterDenoise.Dispose(); */ if (!File.Exists(strFilename)) { Console.WriteLine($"[Error] WebDriver snapshot save iamge by id failed. file not exist"); return(false); } return(true); } } catch (Exception e) { Console.WriteLine($"[Error] WebDriver snapshot save iamge by id failed. Error = {e.ToString()}"); return(false); } return(false); }
public MainPage() { driver = new ChromeDriver(); PageFactory.InitElements(driver, this); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); }
public void OpenTicketsPage() { TicketsPageButton.Click(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); }
public void TestCleanUp() { driver.Manage().Cookies.DeleteAllCookies(); }
public static void SetupDriver() { driver = new ChromeDriver(); driver.Manage().Window.Maximize(); }
public void SetUp() { driver = GetDriver(_settings.Browser); driver.Manage().Window.Maximize(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(IMPLICIT_TIMEOUT); }
public static void WindowsMaximize() { _Driver.Manage().Window.Maximize(); }
long Form1_Load(string sPrimaryProject, string sPrimaryIP, string sSecondaryProject, string sSecondaryIP, string sTestLogFolder, string sBrowser, string sUserEmail, string sLanguage) { bPartResult = true; baseUrl = "http://" + sPrimaryIP; if (bPartResult == true) { EventLog.AddLog("Open browser for selenium driver use"); sw.Reset(); sw.Start(); try { if (sBrowser == "Internet Explorer") { EventLog.AddLog("Browser= Internet Explorer"); InternetExplorerOptions options = new InternetExplorerOptions(); options.IgnoreZoomLevel = true; driver = new InternetExplorerDriver(options); driver.Manage().Window.Maximize(); } else { EventLog.AddLog("Not support temporary"); bPartResult = false; } } catch (Exception ex) { EventLog.AddLog(@"Error opening browser: " + ex.ToString()); bPartResult = false; } sw.Stop(); PrintStep("Open browser", "Open browser for selenium driver use", bPartResult, "None", sw.Elapsed.TotalMilliseconds.ToString()); } //Login test if (bPartResult == true) { EventLog.AddLog("Login WebAccess homepage"); sw.Reset(); sw.Start(); try { driver.Navigate().GoToUrl(baseUrl + "/broadWeb/bwRoot.asp?username=admin"); driver.FindElement(By.XPath("//a[contains(@href, '/broadWeb/bwconfig.asp?username=admin')]")).Click(); driver.FindElement(By.Id("userField")).Submit(); Thread.Sleep(3000); driver.FindElement(By.XPath("//a[contains(@href, '/broadWeb/bwMain.asp?pos=project') and contains(@href, 'ProjName=" + sPrimaryProject + "')]")).Click(); } catch (Exception ex) { EventLog.AddLog(@"Error occurred logging on: " + ex.ToString()); bPartResult = false; } sw.Stop(); PrintStep("Login", "Login project manager page", bPartResult, "None", sw.Elapsed.TotalMilliseconds.ToString()); Thread.Sleep(1000); } //Create Real Time Trend if (bPartResult == true) { EventLog.AddLog("Create Real Time Trend"); sw.Reset(); sw.Start(); try { driver.SwitchTo().Frame("rightFrame"); driver.FindElement(By.XPath("//a[contains(@href, '/broadWeb/bwMainRight.asp') and contains(@href, 'pos=RTrendList')]")).Click(); if (wcf.IsTestElementPresent(driver, "XPath", "//a[contains(@href, '/broadWeb/rtrend/deletertrend.asp') and contains(@href, 'GroupNbr=1')]")) { EventLog.AddLog("Delete the group 1 real time trend"); driver.FindElement(By.XPath("//a[contains(@href, '/broadWeb/rtrend/deletertrend.asp') and contains(@href, 'GroupNbr=1')]")).Click(); Thread.Sleep(1000); driver.SwitchTo().Alert().Accept(); Thread.Sleep(1000); } EventLog.AddLog("Create the group 1 real time trend"); CreateRealTimeTrend(); } catch (Exception ex) { EventLog.AddLog(@"Error occurred Create Real Time Trend: " + ex.ToString()); bPartResult = false; } sw.Stop(); PrintStep("Create", "Create Real Time Trend", bPartResult, "None", sw.Elapsed.TotalMilliseconds.ToString()); Thread.Sleep(1000); } driver.Dispose(); #region Result judgement if (bFinalResult && bPartResult) { Result.Text = "PASS!!"; Result.ForeColor = Color.Green; EventLog.AddLog("Test Result: PASS!!"); return(0); } else { Result.Text = "FAIL!!"; Result.ForeColor = Color.Red; EventLog.AddLog("Test Result: FAIL!!"); return(-1); } #endregion }
public void BeforeBase() { driver = new ChromeDriver(); driver.Manage().Window.Maximize(); // driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); }
public void openHomePageTest() { driver.Navigate().GoToUrl(setup.url); driver.Manage().Window.Maximize(); // maximizes window output.WriteLine("inside GoogleHomePageTest4::openHomePageTest()"); }
public void Setup() { driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://www.saucedemo.com/index.html"); }
public void GivenChromeBrowserOpened() { driver.Manage().Window.Maximize(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); driver.Navigate().GoToUrl("https://app.test.e-bate.net/login"); }