public BaseScreen(IConfiguration configuration, Browser browser) { _configuration = configuration; _browser = browser; _webdriver = WebDriverFactory.CreateWebDriver(browser, configuration.GetSection("Selenium:Drivers:Path").Value, false); }
public FeatureNamePage(Browser browser) { _browser = browser; string driverPath = null; switch (browser) { case Browser.Firefox: driverPath = ConfigurationSettings.AppSettings["FirefoxDriverPath"]; break; case Browser.Chrome: driverPath = ConfigurationSettings.AppSettings["ChromeDriverPath"]; break; case Browser.Edge: driverPath = ConfigurationSettings.AppSettings["EdgeDriverPath"]; break; case Browser.InternetExplorer: driverPath = ConfigurationSettings.AppSettings["InternetExplorerDriverPath"]; break; } _driver = WebDriverFactory.CreateWebDriver(_browser, driverPath); }
public TelaConversaoDistancias(IConfiguration configuration, Browser browser) { _configuration = configuration; _browser = browser; string caminhoDriver = null; if (browser == Browser.Firefox) { caminhoDriver = _configuration.GetSection("Selenium:CaminhoDriverFirefox").Value; } else if (browser == Browser.Chrome) { caminhoDriver = _configuration.GetSection("Selenium:CaminhoDriverChrome").Value; } else if (browser == Browser.Edge) { caminhoDriver = _configuration.GetSection("Selenium:CaminhoDriverEdge").Value; } else if (browser == Browser.InternetExplorer) { caminhoDriver = _configuration.GetSection("Selenium:CaminhoDriverInternetExplorer").Value; } _driver = WebDriverFactory.CreateWebDriver( browser, caminhoDriver); }
static void Main(string[] args) { var username = Configuration.GetKeyAppSettings("usuario"); var password = Configuration.GetKeyAppSettings("senha"); IWebDriver webDriver = WebDriverFactory.CreateWebDriver(Browser.Chrome, @"/Volumes/Dev2/Estudo/bot/Driver"); try { webDriver.LoadPage(TimeSpan.FromSeconds(30), "https://www.facebook.com/"); webDriver.FindElement(By.XPath("/html/body/div[1]/div[2]/div[1]/div/div/div/div[2]/div/div[1]/form/div[1]/div[1]/input")).SendKeys(username); //webDriver.SetText(By.Name("password"), username); //webDriver.Submit(By.TagName("button")); } catch (Exception err) { Console.WriteLine(err.ToString()); } Console.ReadKey(); }
public void GivenChromeBrowserIsOpened() { driver = WebDriverFactory.CreateWebDriver(WebBrowser.Chrome); driver.Manage().Window.Maximize(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); driver.Navigate().GoToUrl("https://app.test.e-bate.net/login"); }
public override CrawlerStatus Execute() { try { using (var driver = WebDriverFactory.CreateWebDriver(WebBrowser.Firefox)) { driver.Navigate().GoToUrl(String.Format("https://www.google.com/search?hl=pt-BR&q={0}&oq={0}", Busca)); // page 1 - Capturar dados Console.WriteLine("ExampleCrawler resultado"); driver.Close(); Console.WriteLine("ExampleCrawler OK"); return(CrawlerStatus.Success); } } catch (NotSupportedException e) { Console.WriteLine("Fail loading browser caught: {0}", e.Message); SetErrorMessage("ExampleCrawler", e.Message); return(CrawlerStatus.Skipped); } catch (Exception e) { Console.WriteLine("Exception caught: {0}", e.Message); SetErrorMessage("ExampleCrawler", e.Message); return(CrawlerStatus.Error); } }
public Login( IConfiguration configuration, Browser browser) { _configuration = configuration; _browser = browser; string pathDriver = null; if (browser == Browser.Firefox) { pathDriver = _configuration.GetSection("Selenium:PathDriverFirefox").Value; } else if (browser == Browser.Chrome) { pathDriver = _configuration.GetSection("Selenium:PathDriverChrome").Value; } _driver = WebDriverFactory.CreateWebDriver( browser, pathDriver, true); _wait = new WebDriverWait( _driver, TimeSpan.FromSeconds(10)); }
public TelaConversaoDistancias(Browser browser) { _browser = browser; string caminhoDriver = null; if (browser == Browser.Firefox) { caminhoDriver = ConfigurationManager.AppSettings["CaminhoDriverFirefox"]; } else if (browser == Browser.Chrome) { caminhoDriver = ConfigurationManager.AppSettings["CaminhoDriverChrome"]; } else if (browser == Browser.Edge) { caminhoDriver = ConfigurationManager.AppSettings["CaminhoDriverEdge"]; } _driver = WebDriverFactory.CreateWebDriver( browser, caminhoDriver); }
public void Setup() { var driver = WebDriverFactory.CreateWebDriver(Browser.Chrome); _searchPage = new SearchPage(driver); _searchPage.NavigateToUrl(); }
public async Task <Registration> CheckRegistration(RegistrationInfo regInfo) { using (var driver = WebDriverFactory.CreateWebDriver()) { driver.Navigate().GoToUrl(LoginUrl); var firstName = driver.FindElement(By.Id("FirstName")); var lastName = driver.FindElement(By.Id("LastName")); var month = driver.FindElement(By.Id("Month")); var day = driver.FindElement(By.Id("Day")); var year = driver.FindElement(By.Id("Year")); firstName.SendKeys(regInfo.FirstName); lastName.SendKeys(regInfo.LastName); month.SendKeys(regInfo.DateOfBirth.Month.ToString()); day.SendKeys(regInfo.DateOfBirth.Day.ToString()); year.SendKeys(regInfo.DateOfBirth.Year.ToString()); driver.FindElement(By.Id("btn-login")).Click(); WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 0, 5)); wait.Until(drv => drv.FindElement(By.CssSelector(StatusCss))); var statusLabel = driver.FindElement(By.CssSelector(StatusCss)); var status = statusLabel.FindElement(By.XPath("following-sibling::div")); return(new Registration { Active = status.Text.Equals("Active") }); } }
public override CrawlerStatus Execute() { try { using (var driver = WebDriverFactory.CreateWebDriver(WebBrowser.Firefox)) { driver.Navigate().GoToUrl(@"http://ec2-18-231-116-58.sa-east-1.compute.amazonaws.com/siel/login.html"); // page 1 - Login // Inserir usuário e senha -> Clicar em Enviar driver.FindElement(By.CssSelector("div.mioloInterna.apps > form > table > tbody > tr:nth-child(1) > td:nth-child(2) > input[type=text]")).SendKeys(Usuario); driver.FindElement(By.CssSelector("div.mioloInterna.apps > form > table > tbody > tr:nth-child(2) > td:nth-child(2) > input[type=password]")).SendKeys(Senha); driver.FindElement(By.CssSelector("div.mioloInterna.apps > form > table > tbody > tr:nth-child(3) > td:nth-child(2) > input[type=submit]")).Click(); // page 2 - Pesquisa // Inserir Nome e Número do processo -> Clicar em Enviar if (!string.IsNullOrEmpty(NomeCompleto) && !string.IsNullOrEmpty(NomeDaMae) && !string.IsNullOrEmpty(DataNascimento)) { driver.FindElement(By.CssSelector("form.formulario > fieldset:nth-child(1) > table > tbody > tr:nth-child(1) > td:nth-child(2) > input[type=text]")).SendKeys(NomeCompleto); driver.FindElement(By.CssSelector("form.formulario > fieldset:nth-child(1) > table > tbody > tr:nth-child(2) > td:nth-child(2) > input[type=text]")).SendKeys(NomeDaMae); driver.FindElement(By.CssSelector("form.formulario > fieldset:nth-child(1) > table > tbody > tr:nth-child(3) > td:nth-child(2) > input[type=text]")).SendKeys(DataNascimento); } if (!string.IsNullOrEmpty(TituloEleitor)) { driver.FindElement(By.CssSelector("form.formulario > fieldset:nth-child(1) > table > tbody > tr:nth-child(4) > td:nth-child(2) > input[type=text]")).SendKeys(TituloEleitor); } driver.FindElement(By.Id("num_processo")).SendKeys(NumeroProcesso); driver.FindElement(By.CssSelector("form.formulario > table > tbody > tr > td:nth-child(2) > input")).Click(); // page 3 - Capturar dados var resultados = driver.FindElements(By.CssSelector(".lista tbody > tr > td:nth-child(2)")); foreach (IWebElement resultado in resultados) { Console.WriteLine("SielCrawler resultado {0}", resultado.Text); } driver.Close(); Console.WriteLine("SielCrawler OK"); return(CrawlerStatus.Success); } } catch (NotSupportedException e) { Console.WriteLine("Fail loading browser caught: {0}", e.Message); SetErrorMessage("SielCrawler", e.Message); return(CrawlerStatus.Skipped); } catch (Exception e) { Console.WriteLine("Exception caught: {0}", e.Message); SetErrorMessage("SielCrawler", e.Message); return(CrawlerStatus.Error); } }
public void InitializeBrowser() { driver = WebDriverFactory.CreateWebDriver(browser); if (browser != WebBrowser.Chrome) { driver.Manage().Window.Maximize(); } }
public void GivenINavigateToLoginScreen() { driver = WebDriverFactory.CreateWebDriver(WebBrowser.Chrome); driver.Manage().Window.Maximize(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); driver.Navigate().GoToUrl("https://app.test.e-bate.net/login"); loginTabPageObject = new LoginTabPageObject(driver); }
public void Setup() { Log4netHelper.ConfigureLog4net(TestContext.CurrentContext.Test.FullName, Path.Combine(TestContext.CurrentContext.WorkDirectory, $"{TestContext.CurrentContext.Test.FullName}.txt")); log = Log4netHelper.GetLogger(); log.Info($"Preparing {browser} driver"); driver = WebDriverFactory.CreateWebDriver(browser); screenshotHelper = new ScreenshotHelper((ITakesScreenshot)driver); scrollHelper = new ScrollHelper(driver); }
public BaseScreen() { if (_webDriver == null) { var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json"); _configuration = builder.Build(); _webDriver = WebDriverFactory.CreateWebDriver(BrowserUtil.Chrome, $"{Directory.GetCurrentDirectory()}\\Driver", false); _webDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15); } }
public void ReloadWebDriver() { Log.TestLog.Warn("Reloading WebDriver."); if (_driver != null && _driver.IsValueCreated) { _driver.Value.Quit(); _driver.Value.Dispose(); } _driver.Value = WebDriverFactory.CreateWebDriver(Configuration, Log); Log.TestLog.Warn("WebDriver reloaded."); }
public override CrawlerStatus Execute() { try { using (var driver = WebDriverFactory.CreateWebDriver(WebBrowser.Firefox)) { driver.Navigate().GoToUrl(@"http://ec2-18-231-116-58.sa-east-1.compute.amazonaws.com/arpensp/login.html"); // page 1 driver.FindElement(By.CssSelector("#main > div.container > div:nth-child(2) > div:nth-child(2) > div > a")).Click(); // page 2 //driver.FindElement(By.Id("arrumaMenu")).Click(); driver.FindElement(By.CssSelector("#wrapper > ul > li.item3 > a")).Click(); driver.FindElement(By.CssSelector("#wrapper > ul > li.item3 > ul > li:nth-child(1) > a")).Click(); // page 3 driver.FindElement(By.CssSelector("#principal > div > form > table > tbody > tr:nth-child(2) > td:nth-child(2) > input[name='numero_processo']")).SendKeys(NumeroProcesso); var campoVara = new SelectElement(driver.FindElement(By.Id("vara_juiz_id"))); campoVara.SelectByValue("297"); driver.FindElement(By.Id("btn_pesquisar")).Click(); // page 4 - Capturar dados var resultadoConjuge1 = driver.FindElement(By.CssSelector("#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(2) > td:nth-child(2)")).Text; var resultadoConjuge2 = driver.FindElement(By.CssSelector("#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(4) > td:nth-child(2)")).Text; var resultadoDataCasamento = driver.FindElement(By.CssSelector("#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(6) > td:nth-child(2)")).Text; Console.WriteLine("ArpenspCrawler resultado primeiro Conjuge {0}, segundo Conjuge {1}; casados em {2}", resultadoConjuge1, resultadoConjuge2, resultadoDataCasamento); driver.Close(); Console.WriteLine("ArpenspCrawler OK"); return(CrawlerStatus.Success); } } catch (NotSupportedException e) { Console.WriteLine("Fail loading browser caught: {0}", e.Message); SetErrorMessage("ArpenspCrawler", e.Message); return(CrawlerStatus.Skipped); } catch (Exception e) { Console.WriteLine("Exception caught: {0}", e.Message); SetErrorMessage("ArpenspCrawler", e.Message); return(CrawlerStatus.Error); } }
public TelaConversaoTemperaturas(Browser browser) { _browser = browser; string caminhoDriver = null; if (browser == Browser.Chrome) { caminhoDriver = ConfigurationManager.AppSettings["CaminhoDriverChrome"]; } _driver = WebDriverFactory.CreateWebDriver( browser, caminhoDriver); }
static void Main(string[] args) { var username = Configuration.GetKeyAppSettings("usuario"); var password = Configuration.GetKeyAppSettings("senha"); IWebDriver webDriver = WebDriverFactory.CreateWebDriver(Browser.Chrome, @"C:\_dev\robos\Bot\Driver"); try { webDriver.LoadPage(TimeSpan.FromSeconds(10), "https://www.instagram.com/accounts/login/"); webDriver.SetText(By.Name("username"), username); webDriver.SetText(By.Name("password"), password); webDriver.Submit(By.TagName("button")); Thread.Sleep(TimeSpan.FromSeconds(10)); webDriver.LoadPage(TimeSpan.FromSeconds(10), @"https://www.instagram.com/ionicclub/"); //webDriver.FindElement(By.XPath("//button[contains(text(), 'Seguir')]")).Click(); IWebElement btnSeguir = null; try { btnSeguir = webDriver.FindElement(By.XPath("//button[contains(text(), 'Seguir')]")); btnSeguir.Click(); } catch (NoSuchElementException ex) { Console.WriteLine("Já está seguindo o usuário"); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { webDriver.Close(); webDriver.Dispose(); } Console.ReadKey(); }
static void Main(string[] args) { var webDriver = WebDriverFactory.CreateWebDriver(Browser.Chrome, AppDomain.CurrentDomain.BaseDirectory, false, true); webDriver.LoadPage(TimeSpan.FromSeconds(10), @"https://www.google.com"); webDriver.SetText(By.Name("q"), "ilovecode.com.br"); webDriver.Submit(By.Name("btnK")); webDriver.WaitFindElement(By.Id("teste")); //webDriver.SendKeys(By.Id(""), Keys.End); Thread.Sleep(20000); webDriver.Close(); }
static void Main(string[] args) { var usuario = Configuration.GetKeyAppSettings("username"); var password = Configuration.GetKeyAppSettings("password"); //Local do driver do navegador usado para o selenium. IWebDriver webDriver = WebDriverFactory.CreateWebDriver(Browser.Chrome, @"E:\00.ESTUDOS\00.GITHUB"); try { webDriver.LoadPage(TimeSpan.FromSeconds(10), "http://www.instagram.com/accounts/login/"); webDriver.SetText(By.Name("username"), usuario); webDriver.SetText(By.Name("password"), password); webDriver.Submit(By.TagName("button")); Thread.Sleep(TimeSpan.FromSeconds(10)); // xxxxx = Perfil a ser acessado webDriver.LoadPage(TimeSpan.FromSeconds(10), "http://www.instagram.com/xxxxx/"); //webDriver.FindElement(By.XPath("//button[contains(text(), 'Seguir')]")).Click(); IWebElement btnSeguir = null; try { btnSeguir = webDriver.FindElement(By.XPath("//button[contains(text(), 'Seguir')]")); btnSeguir.Click(); } catch (NoSuchElementException ex) { Console.WriteLine("Usuário já seguido!"); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { webDriver.Close(); webDriver.Dispose(); } Console.ReadKey(); }
static void Main(string[] args) { IWebDriver webDriver = WebDriverFactory.CreateWebDriver(Browser.Chrome, @"C:\Users\Paulo\Documents\GitHub\prmToolkit.Selenium\Driver", true, true); webDriver.LoadPage(TimeSpan.FromSeconds(10), @"https://www.google.com"); webDriver.SetText(By.Name("q"), "ilovecode.com.br"); webDriver.Submit(By.Name("btnK")); webDriver.WaitFindElement(By.Id("teste")); //webDriver.SendKeys(By.Id(""), Keys.End); Thread.Sleep(20000); webDriver.Close(); }
public TesteGoogle(IConfiguration configuration, Browser browser) { _configuration = configuration; _browser = browser; string pathDriver = null; if (_browser == Browser.Firefox) { pathDriver = _configuration.GetSection("Selenium:PathDriverFirefox").Value; } else if (_browser == Browser.Chrome) { pathDriver = _configuration.GetSection("Selenium:PathDriverChrome").Value; } _driver = WebDriverFactory.CreateWebDriver(browser, pathDriver); }
public AutomationManager(IConfiguration configuration, Browser browser) { _configuration = configuration; string driverPath = null; switch (browser) { case Browser.Firefox: driverPath = _configuration.GetSection("Selenium:FirefoxDriver").Value; break; case Browser.Chrome: driverPath = _configuration.GetSection("Selenium:ChromeDriver").Value; break; } _driver = WebDriverFactory.CreateWebDriver(browser, driverPath); }
public TelaCadastroUsuarioTest(IConfiguration configuration, Browser browser) { _browser = browser; _configuration = configuration; string caminhoDriver = null; if (browser == Browser.Edge) { caminhoDriver = _configuration.GetSection("Selenium:CaminhoDriverEdge").Value; } else if (browser == Browser.Chrome) { caminhoDriver = _configuration.GetSection("Selenium:CaminhoDriverChrome").Value; } _webDriver = WebDriverFactory.CreateWebDriver(browser, caminhoDriver); }
static void Main(string[] args) { IWebDriver webDriver = WebDriverFactory.CreateWebDriver(Browser.Chrome, @"C:\_dev\robos\Bot\Driver"); try { Console.WriteLine("Acessando o video"); webDriver.LoadPage(TimeSpan.FromSeconds(20), "https://www.youtube.com/watch?v=r0A4-82uujg&list=PLDcxAw7lE_46q-Tqi0ePPAVJmJ6oJvkm1"); Thread.Sleep(TimeSpan.FromSeconds(20)); Console.WriteLine("Verificar se tem anuncio"); IWebElement btnPularAnuncio = null; try { btnPularAnuncio = webDriver.FindElement(By.ClassName("videoAdUiFixedPaddingSkipButtonText")); Console.WriteLine("Fechando o anuncio"); btnPularAnuncio.Click(); Thread.Sleep(TimeSpan.FromSeconds(30)); } catch (NoSuchElementException ex) { Console.WriteLine(ex.ToString()); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { webDriver.Close(); webDriver.Dispose(); } Console.ReadKey(); }
public ConsultaVeiculoDFService(IConfiguration configuration, Browser browser, bool remote = true) { _configuration = configuration; var browserConfiguration = new BrowserConfiguration(_configuration, browser); if (!remote) { var driverBrowser = browserConfiguration.DriverBrowser(); _webDriver = WebDriverFactory.CreateWebDriver(browser, driverBrowser); } else { var remoteBrowser = browserConfiguration.RemoteBrowser(); remoteBrowser.SetCapability("acceptSslCerts", true); _webDriver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), remoteBrowser); } }
static void Main(string[] args) { IWebDriver webD = WebDriverFactory.CreateWebDriver(Browser.Chrome, @"D:\Projetos2020\Bots\Driver"); try { webD.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); webD.LoadPage("https://www.instagram.com/accounts/login/"); webD.SetText(By.Name("username"), ConfigurationManager.AppSettings["usuario"]); webD.SetText(By.Name("password"), ConfigurationManager.AppSettings["senha"]); webD.Submit(By.TagName("button")); Thread.Sleep(TimeSpan.FromSeconds(10)); webD.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); webD.LoadPage("https://www.instagram.com/ionicclub/"); IWebElement btnSeguir = null; try { btnSeguir = webD.FindElement(By.XPath("//button[contains(text(), 'Seguir')]")); btnSeguir.Click(); } catch (NoSuchElementException ex) { Console.WriteLine("Já esta seguindo usuario!"); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { //webD.Close(); //webD.Dispose(); } Console.ReadKey(); }
/// <summary> /// Main entry point of the application. /// </summary> /// <param name="args">Command line arguments of the application.</param> static void Main(string[] args) { UrlBuilder builder = new UrlBuilder(); IWebDriver driver = WebDriverFactory.CreateWebDriver(BrowserKind.Chrome); driver.Url = builder.BuildUrl("dynamic_loading/1"); driver.FindElement(By.CssSelector("button")).Click(); IWebElement finishElement = OnlyFindElement(driver); //IWebElement finishElement = ImplicitWaitFindElement(driver); //IWebElement finishElement = ExplicitWaitFindElement(driver); //IWebElement finishElement = CustomWaitFindElement(driver); Console.WriteLine("Finish element text is: {0}", finishElement.Text); driver.Quit(); Console.WriteLine("Complete! Press <Enter> to exit."); Console.ReadLine(); }
public TelaConversaoDistancias( IConfiguration configuration, Browser browser) { _configuration = configuration; _browser = browser; string caminhoDriver = null; if (browser == Browser.Firefox) { caminhoDriver = _configuration.GetSection("Selenium:CaminhoDriverFirefox").Value; } else if (browser == Browser.Chrome) { caminhoDriver = _configuration.GetSection("Selenium:CaminhoDriverChrome").Value; } _driver = WebDriverFactory.CreateWebDriver( browser, caminhoDriver, true); // Ativando o modo headless }