public bool ValidarOpcaoSelecionada(string Opcao) { bool _result = false; try { Thread.Sleep(500); IWebElement ValidarMansagem = ClassDriver.GetInstance().Driver.FindElement(By.XPath("/html/body/material-docs-app/app-component-sidenav/mat-sidenav-container/mat-sidenav-content/div/div/div/app-component-viewer/div/div/component-overview/doc-viewer/div/div[2]/example-viewer/div/div[2]/select-value-binding-example/p")); util.WaitForElementVisible(ValidarMansagem, 30); string teste = ValidarMansagem.Text; if (ValidarMansagem.Displayed && ValidarMansagem.Text.Contains(Opcao)) { Thread.Sleep(500); _result = true; } else { ClassInfo.GetInstance().LogMessage = "Erro ao apresentar a mensagem com a opção " + Opcao + " selecioada!"; } } catch (Exception) { ClassInfo.GetInstance().LogMessage = "Erro ao validar!"; } return(_result); }
public bool ValidarCalendario() { bool _result = false; try { IWebElement ValidarCalendario = ClassDriver.GetInstance().Driver.FindElement(By.XPath("//*[@id='mat-datepicker-0']")); util.WaitForElementVisible(ValidarCalendario, 30); Thread.Sleep(500); if (ValidarCalendario.Displayed) { ValidarCalendario.Click(); _result = true; } else { ClassInfo.GetInstance().LogMessage = "Erro ao apresentar o calendário!"; } } catch (Exception) { ClassInfo.GetInstance().LogMessage = "Erro ao validar!"; } return(_result); }
//Pegar conteúdo de uma variável Local public static String getItemFromLocalStorage(String key) { IJavaScriptExecutor js = ClassDriver.GetInstance().Driver as IJavaScriptExecutor; return((String)js.ExecuteScript(String.Format( "return window.localStorage.getItem('tokenPES');", key))); }
public bool SelecionarOpcao(string Option) { bool _result = false; try { Thread.Sleep(500); IWebElement SelectOption = ClassDriver.GetInstance().Driver.FindElement(By.XPath("//*[@class='cdk-overlay-pane']//mat-option/span[contains(text(),'" + Option + "')]")); util.WaitForElementVisible(SelectOption, 30); if (SelectOption.Displayed && SelectOption.Enabled) { Thread.Sleep(500); util.ClickJS(SelectOption); _result = true; } else { ClassInfo.GetInstance().LogMessage = "Erro ao selecionar a opção" + Option; } } catch (Exception) { ClassInfo.GetInstance().LogMessage = "Erro ao validar!"; } return(_result); }
public bool ClicarCalendario() { bool _result = false; try { Thread.Sleep(3000); IWebElement IconCalendar = ClassDriver.GetInstance().Driver.FindElement(By.XPath("/html/body/material-docs-app/app-component-sidenav/mat-sidenav-container/mat-sidenav-content/div/div/div/app-component-viewer/div/div/component-overview/doc-viewer/div/div[1]/example-viewer/div/div[2]/datepicker-overview-example/mat-form-field/div/div[1]/div[2]/mat-datepicker-toggle/button")); util.WaitForElementVisible(IconCalendar, 30); if (IconCalendar.Displayed && IconCalendar.Enabled) { IconCalendar.Click(); Thread.Sleep(1000); _result = true; } else { ClassInfo.GetInstance().LogMessage = "Erro ao clicar no calendário!"; } } catch (Exception) { ClassInfo.GetInstance().LogMessage = "Erro ao validar!"; } return(_result); }
public bool ValidarMsgEmailIncorreto() { bool _result = false; try { Thread.Sleep(1000); IWebElement ValidarMsgError = ClassDriver.GetInstance().Driver.FindElement(By.XPath("//*[@id='mat-error-1']")); util.WaitForElementVisible(ValidarMsgError, 30); if (ValidarMsgError.Displayed && ValidarMsgError.Enabled) { _result = true; } else { ClassInfo.GetInstance().LogMessage = "Erro ao apresentar a mensagem de email incorreto"; } } catch (Exception) { ClassInfo.GetInstance().LogMessage = "Erro ao validar!"; } return(_result); }
public bool InserirEmail(string email) { bool _result = false; try { Thread.Sleep(1000); IWebElement InputEmail = ClassDriver.GetInstance().Driver.FindElement(By.XPath("//div[@class='mat-form-field-infix']/input[@placeholder='Email']")); util.WaitForElementVisible(InputEmail, 30); if (InputEmail.Displayed && InputEmail.Enabled) { Thread.Sleep(500); util.ScrollPage(2); InputEmail.SendKeys(email); _result = true; } else { ClassInfo.GetInstance().LogMessage = "Erro ao inserir o email!"; } } catch (Exception) { ClassInfo.GetInstance().LogMessage = "Erro ao validar!"; } return(_result); }
public bool ClicarSelectAnOption() { bool _result = false; try { Thread.Sleep(500); IWebElement SelectAnOption = ClassDriver.GetInstance().Driver.FindElement(By.XPath("//*[@id='mat-select-1']/div/div[1]/span")); util.WaitForElementVisible(SelectAnOption, 30); if (SelectAnOption.Displayed && SelectAnOption.Enabled) { Thread.Sleep(500); util.ScrollPage(2); util.ClickJS(SelectAnOption); _result = true; } else { ClassInfo.GetInstance().LogMessage = "Erro ao clicar em Select An Option!"; } } catch (Exception) { ClassInfo.GetInstance().LogMessage = "Erro ao validar!"; } return(_result); }
public void ScrollPage(int num) { int scroll = num * 300; js = (IJavaScriptExecutor)ClassDriver.GetInstance().Driver; js.ExecuteScript("window.scrollBy(0, " + scroll + ")", ""); }
public void ScreenshotPrepare() { screenshots = @"C:\Users\leonardo.barcellos\Desktop\Screenshots\"; CultureInfo cult = new CultureInfo("pt-BR"); string dta = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss", cult); Screenshot(ClassDriver.GetInstance().Driver, screenshots + "error_" + Cont++ + ".png"); }
public static void BeforeFeature(FeatureInfo featureInfo) { //featureName = extent.CreateTest<Feature>(FeatureContext.Current.FeatureInfo.Title); string typeBrowser = featureInfo.Title.Contains("-") ? featureInfo.Title.Split('-')[0] : null; ClassDriver.GetInstance().StartDriver(typeBrowser); }
public void SendKeyJS(IWebElement element, string value) { try { IJavaScriptExecutor js = ClassDriver.GetInstance().Driver as IJavaScriptExecutor; js.ExecuteScript("arguments[0].setAttribute('value', '" + value + "')", element); } catch (Exception) { } }
public void ClickJS(IWebElement element) { try { IJavaScriptExecutor js = ClassDriver.GetInstance().Driver as IJavaScriptExecutor; js.ExecuteScript("arguments[0].click()", element); } catch (Exception) { } }
public bool AcessarAplicacao(string url) { bool _result = false; try { ClassDriver.GetInstance().Driver.Navigate().GoToUrl(url); _result = true; } catch (Exception) { ClassInfo.GetInstance().LogMessage = "Erro ao validar!"; } return(_result); }
public void ScrollElementoPage(IWebElement element) { try { Point point = new Point(); if (element != null) { point = element.Location; IJavaScriptExecutor js = ClassDriver.GetInstance().Driver as IJavaScriptExecutor; js.ExecuteScript("arguments[0].scrollIntoView(true);", element); } } catch (Exception) { } }
public bool ValidarCarregamento() { bool _result = false; try { IWebElement LogoHome = ClassDriver.GetInstance().Driver.FindElement(By.XPath("/html/body/material-docs-app/app-component-sidenav/mat-sidenav-container/mat-sidenav-content/div/component-page-header/div/h1")); util.WaitForElementVisible(LogoHome, 60); if (LogoHome.Displayed) { _result = true; } else { ClassInfo.GetInstance().LogMessage = "Erro ao acessar a aplicação!"; } } catch (Exception) { ClassInfo.GetInstance().LogMessage = "Erro ao validar!"; } return(_result); }
public static void BeforeFeature(FeatureInfo featureInfo) { ClassDriver.GetInstance().StartDriver(); }
public void FormControls() { PageFactory.InitElements(ClassDriver.GetInstance().Driver, this); }
public static void BeforeFeature(FeatureInfo featureInfo) { string typeBrowser = featureInfo.Title.Contains("-") ? featureInfo.Title.Split('-')[0] : null; ClassDriver.GetInstance().StartDriver(typeBrowser); }
public static void AfterFeature() { ClassDriver.GetInstance().QuitDriver(); }
public void AccessPage() { PageFactory.InitElements(ClassDriver.GetInstance().Driver, this); }
public static void AfterStep() { string errorImage = ClassUtilities.PegarDataHora(); var stepType = ScenarioStepContext.Current.StepInfo.StepDefinitionType.ToString(); if (ScenarioContext.Current.ScenarioExecutionStatus.ToString() == "StepDefinitionPending") { if (stepType == "Given") { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step pendente"); } else if (stepType == "When") { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step pendente"); } else if (stepType == "Then") { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text).Skip("Step pendente"); } } else { if (ScenarioContext.Current.TestError == null) { if (stepType == "Given") { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "When") { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "Then") { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text); } else if (stepType == "And") { scenario.CreateNode <And>(ScenarioStepContext.Current.StepInfo.Text); } } else if (ScenarioContext.Current.TestError != null) { if (stepType == "Given") { scenario.CreateNode <Given>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message) .Fail("<br/>Screenshot <br/><br/>", MediaEntityBuilder.CreateScreenCaptureFromPath(GetScreenShot.Capture(ClassDriver.GetInstance().Driver, errorImage)).Build()); } else if (stepType == "When") { scenario.CreateNode <When>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message) .Fail("<br/>Screenshot <br/><br/>", MediaEntityBuilder.CreateScreenCaptureFromPath(GetScreenShot.Capture(ClassDriver.GetInstance().Driver, errorImage)).Build()); } else if (stepType == "Then") { scenario.CreateNode <Then>(ScenarioStepContext.Current.StepInfo.Text).Fail(ScenarioContext.Current.TestError.Message) .Fail("<br/>Screenshot <br/><br/>", MediaEntityBuilder.CreateScreenCaptureFromPath(GetScreenShot.Capture(ClassDriver.GetInstance().Driver, errorImage)).Build()); } } } }