public void CN001_Alunos_ValidarCadastroAlunos() { var faker = new Faker("en"); var nameMock = new Bogus.DataSets.Name(); var firstName = nameMock.FirstName(Bogus.DataSets.Name.Gender.Male); var lastName = nameMock.LastName(Bogus.DataSets.Name.Gender.Male); aluno = new AlunoMock() { CPF = faker.Random.Long(11111111111, 99999999999).ToString(), RG = faker.Random.Long(1111111, 9999999).ToString(), Telefone = faker.Phone.PhoneNumber(), DataNascimento = "01/01/1991", UserName = faker.Internet.UserName(firstName, lastName), Email = faker.Internet.Email(firstName, lastName, "portabilis.com"), Senha = faker.Internet.Password(8, true), Name = firstName + " " + lastName }; this.CN001_Alunos_AcessarCadastro(); this.CN001_Alunos_CadastrarAluno(); this.CN001_Alunos_AcessarCadastro(); this.CN001_Alunos_CadastrarAluno(); this.CN001_Alunos_ValidarAlunoCPFDuplicado(); this.CN001_Alunos_FazerLoginAluno(); this.CN001_Alunos_BuscarIdAluno(); driver.Close(); }
protected void WaitExecute(FirefoxDriver driver) { if (NextExecute != null && DateTime.Now.Ticks < NextExecute.Value.Ticks) { Thread.Sleep(500); WaitExecute(driver); } LastExecute = DateTime.Now; NextExecute = LastExecute.Value.AddMilliseconds(PageNavigationTimeout); if (IPExceptionsString != null) foreach (var str in IPExceptionsString) { if (driver.PageSource.Contains(str)) { driver.Close(); driver.Quit(); } } if (BlockedExceptionsString != null) foreach (var str in BlockedExceptionsString) { if (driver.PageSource.Contains(str)) { driver.Close(); driver.Quit(); } } }
public void checkPatients() { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl(link); Thread.Sleep(3000); driver.FindElement(By.XPath("/html/body/app-root/div/app-login/div/div/div/div[4]/form/div[1]/app-input/div/input")).Click(); driver.FindElement(By.XPath("/html/body/app-root/div/app-login/div/div/div/div[4]/form/div[1]/app-input/div/input")).SendKeys("root"); driver.FindElement(By.XPath("/html/body/app-root/div/app-login/div/div/div/div[4]/form/div[2]/app-input/div/input")).Click(); driver.FindElement(By.XPath("/html/body/app-root/div/app-login/div/div/div/div[4]/form/div[2]/app-input/div/input")).SendKeys("password"); driver.FindElement(By.XPath("/html/body/app-root/div/app-login/div/div/div/div[5]/div[1]/app-button/button")).Click(); Thread.Sleep(5000); driver.FindElement(By.XPath("//div[contains(@class,'organization-container')]/div[2]")).Click(); Thread.Sleep(3000); driver.FindElement(By.XPath("//div[contains(@class, 'nav-items flex-main-start')]/div[2]")).Click(); Thread.Sleep(8000); IList <IWebElement> consentlist = driver.FindElements(By.XPath("//app-tc[contains(@class,'email-cell flex')]")); int consent_count = consentlist.Count(); System.Diagnostics.Debug.WriteLine("Consents: " + consent_count); if (consent_count == 0) { driver.Close(); driver.Quit(); } else if (consent_count == 1) { System.Diagnostics.Debug.WriteLine("Consents: " + consent_count); driver.Close(); driver.Quit(); } else { for (int j = 1; j <= consent_count; j++) { driver.FindElement(By.XPath("//div[contains(@class,'body-container flex')]/app-tr[" + j + "]/div/div/div/app-tc[4]/div")).Click(); Thread.Sleep(5000); driver.FindElement(By.XPath("//span[contains(@class,'font-medium')]")).Click(); Thread.Sleep(5000); } } driver.Close(); driver.Quit(); }
public void Like(IWebElement b) { By ahref = By.TagName("a"); var href = b.FindElement(ahref); By imgTag = By.TagName("img"); var img = href.FindElement(imgTag); var typeLike = b.FindElements(By.TagName("td"))[4].FindElement(By.TagName("span")).Text; img.Click(); By time = By.ClassName("time"); var windows = _fd.WindowHandles.ToList(); int timeClock = (int.Parse(b.FindElement(time).Text)); while (timeClock > 0) { Dispatcher.Invoke(() => { TaskTime.Content = "Task:" + index + "|Ended after: " + timeClock + "s."; } ); Thread.Sleep(1000); timeClock--; } try { _fd.SwitchTo().Window(windows[1]); var buttonPanel = _fd.FindElementById("top-level-buttons"); var buttons = buttonPanel.FindElements(By.TagName("ytd-toggle-button-renderer")); if (typeLike == "Лайк") { buttons[0].Click(); } else { buttons[1].Click(); } _fd.Close(); } catch (Exception ex) { } _fd.SwitchTo().Window(windows[0]); By agree = By.ClassName("btn"); try { var elementClick = b.FindElement(agree); elementClick.Click(); } catch (Exception ex) { } }
/// <summary> /// Extrae descargables en caso de que exista actualizacion /// </summary> /// <returns>objeto tipo FileInfo</returns> public FileInfo [] ExtraerInformacionPaginaSoporte() { try { FirefoxOptions profile = new FirefoxOptions(); profile.SetPreference("browser.download.folderlist", 2); profile.SetPreference("browser.download.dir", ConfigurationManager.AppSettings["carpetaDescargar"].ToString()); profile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream"); FirefoxDriver driver = new FirefoxDriver(@"\\Mac\Home\Downloads\geckodriver-v0.23.0-win64", profile); string rutEncriptado = Utilitario.CCryptorEngine.Encriptar(ConfigurationManager.AppSettings["rut"].ToString()); string claveEncriptado = Utilitario.CCryptorEngine.Encriptar(ConfigurationManager.AppSettings["clave"].ToString()); driver.Navigate().GoToUrl("http://www.cepet.cl/soporte/soportelogin.php"); driver.FindElementById("rutclie").SendKeys(Utilitario.CCryptorEngine.Desencriptar(rutEncriptado)); driver.FindElementById("numclie").SendKeys(Utilitario.CCryptorEngine.Desencriptar(claveEncriptado)); driver.FindElement(By.XPath("//img[@src='imagenes/ingresar.png']")).Click(); driver.Navigate().GoToUrl("http://www.cepet.cl/soporte/menu_dinamico.php"); IList <IWebElement> listaTodosTd = driver.FindElements(By.XPath(".//td[@class='Texto_verdana']//ul[@class='Texto_verdana']//li//img[@src='imagenes/new2.gif']")); if (listaTodosTd.Count > 0) { foreach (var lista in listaTodosTd) { lista.FindElement(By.XPath("//td[@class='Texto_verdana']//ul[@class='Texto_verdana']//li//a")).Click(); if (!Directory.Exists(ConfigurationManager.AppSettings["carpetaDescargar"].ToString())) { Directory.CreateDirectory(ConfigurationManager.AppSettings["carpetaDescargar"].ToString()); } IWebElement elemento = driver.FindElement(By.XPath("//input[@type='submit']")); elemento.Click(); DirectoryInfo d = new DirectoryInfo(ConfigurationManager.AppSettings["carpetaDescargar"].ToString()); //Assuming Test is your Folder files = d.GetFiles("*.exe"); //Getting Text files driver.Close(); } } else { driver.Close(); } return(files); } catch (Exception ex) { throw ex; } }
public void withdrawConsentDetail() { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl(link); Thread.Sleep(3000); driver.FindElement(By.XPath("//input[@placeholder='Username']")).Click(); driver.FindElement(By.XPath("//input[@placeholder='Username']")).SendKeys("*****@*****.**"); driver.FindElement(By.XPath("//input[@placeholder='Password']")).Click(); driver.FindElement(By.XPath("//input[@placeholder='Password']")).SendKeys("12345678"); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); driver.FindElement(By.XPath("//span[contains(@class,'font-bold') and contains(text(), 'Log in')]")).Click(); Thread.Sleep(5000); driver.FindElement(By.XPath("//span[text()='Given']")).Click(); Thread.Sleep(2000); IList <IWebElement> consentlist = driver.FindElements(By.XPath("//button[contains(@class, 'btnOutline btnDark')]")); int consent_count = consentlist.Count(); System.Diagnostics.Debug.WriteLine("Consents: " + consent_count); if (consent_count == 0) { driver.Close(); driver.Quit(); } else if (consent_count == 1) { driver.FindElement(By.XPath("//button[contains(@class, 'btnOutline btnDark')]")).Click(); Thread.Sleep(2000); driver.FindElement(By.XPath("//button[contains(@class, 'btnDanger btnOutline')]")).Click(); Thread.Sleep(4000); } else { driver.FindElement(By.XPath("//div[contains(@class, 'consent-list')]/div[2]/app-consent-card/div/div/div[contains(@class, 'content-button-double flex-cross-center')]/span[2]/app-button/button[contains(@class, 'btnOutline btnDark')]")).Click(); Thread.Sleep(2000); IWebElement withdrawConsent = driver.FindElement(By.XPath("//button[contains(@class, 'btnDanger btnOutline')]")); ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView();", withdrawConsent); driver.FindElement(By.XPath("//button[contains(@class, 'btnDanger btnOutline')]")).Click(); Thread.Sleep(3000); driver.FindElement(By.XPath("//button[contains(@class, 'btnDanger btnOutline')]")).Click(); Thread.Sleep(4000); Thread.Sleep(5000); } driver.Close(); driver.Quit(); }
public void checkRequests() { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl(link); Thread.Sleep(3000); driver.FindElement(By.XPath("//input[@placeholder='Username']")).Click(); driver.FindElement(By.XPath("//input[@placeholder='Username']")).SendKeys("*****@*****.**"); driver.FindElement(By.XPath("//input[@placeholder='Password']")).Click(); driver.FindElement(By.XPath("//input[@placeholder='Password']")).SendKeys("12345678"); Thread.Sleep(2000); driver.FindElement(By.XPath("//span[contains(@class,'font-bold') and contains(text(), 'Log in')]")).Click(); Thread.Sleep(5000); driver.FindElement(By.XPath("//span[text()='Requests']")).Click(); Thread.Sleep(2000); IList <IWebElement> consentlist = driver.FindElements(By.XPath("//div[contains(@class, 'content-button flex-main-center')]/app-button/button[contains(@class, 'btnSuccess')]")); int consent_count = consentlist.Count(); consent_count -= 1; System.Diagnostics.Debug.WriteLine("Consents: " + consent_count); if (consent_count == 0) { driver.Close(); driver.Quit(); } else if (consent_count == 1) { driver.FindElement(By.XPath("//button[contains(@class, 'btnSuccess')]")).Click(); Thread.Sleep(2000); driver.FindElement(By.XPath("//div[contains(@class, 'left-wrapper flex-center clickable')]")).Click(); Thread.Sleep(4000); } else { for (int j = 1; j <= consent_count; j++) { driver.FindElement(By.XPath("//div[contains(@class, 'consent-list')]/div[" + j + "]/app-consent-card/div/div/div/app-button/button[contains(@class, 'btnSuccess')]")).Click(); Thread.Sleep(2000); driver.FindElement(By.XPath("//div[contains(@class, 'left-wrapper flex-center clickable')]")).Click(); Thread.Sleep(4000); } Thread.Sleep(5000); } driver.Close(); driver.Quit(); }
public void VisualizarCursos() { try { CommonCode(); Assert.NotNull(driver.FindElement(By.Id("tabela-cursos"))); driver.Close(); driver.Dispose(); } finally { driver.Quit(); } }
static void Main(string[] args) { using (IWebDriver driver = new FirefoxDriver()) { try { driver.Manage().Timeouts().ImplicitWait.Add(TimeSpan.FromSeconds(30)); driver.Manage().Timeouts().PageLoad.Add(TimeSpan.FromSeconds(30)); //get capital of country driver.Navigate().GoToUrl("https://www.iplocation.net/"); string MyRegion = driver.FindElement(By.XPath("//table[1]//tbody/tr[1]/td[4]")).Text; driver.Navigate().GoToUrl("https://www.momondo.by/"); // Find the text input element by its name IList <IWebElement> countries = driver.FindElements(By.ClassName("locale-link")); foreach (var country in countries) { string linkGermany = country.GetAttribute("href"); if (linkGermany.EndsWith(".dk/", StringComparison.OrdinalIgnoreCase)) { driver.Navigate().GoToUrl(linkGermany); break; } } IList <IWebElement> inputboxes = driver.FindElements(By.TagName("input")); IWebElement capitalfrom = inputboxes.First(g => g.GetAttribute("value").StartsWith(MyRegion)); if (capitalfrom == null) { throw new Exception("No input with your capital"); } else { Console.WriteLine("Succes"); } } catch (Exception e) { driver.Close(); Console.WriteLine(e.Message); } driver.Close(); }; }
public void giveConsent() { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl(link); Thread.Sleep(3000); driver.FindElement(By.XPath("//input[@placeholder='Username']")).Click(); driver.FindElement(By.XPath("//input[@placeholder='Username']")).SendKeys("*****@*****.**"); driver.FindElement(By.XPath("//input[@placeholder='Password']")).Click(); driver.FindElement(By.XPath("//input[@placeholder='Password']")).SendKeys("12345678"); Thread.Sleep(2000); driver.FindElement(By.XPath("/html/body/app-root/div/app-login/div/div/form/div[2]/app-button[1]/button")).Click(); Thread.Sleep(5000); IList <IWebElement> consentlist = driver.FindElements(By.XPath("//div[contains(@class, 'consent-card')]")); int consent_count = consentlist.Count(); consent_count -= 1; Console.WriteLine("Consents: " + consent_count); if (consent_count >= 2) { driver.FindElement(By.XPath("//div[contains(@class, 'consent-list')]/div[2]/app-consent-card/div/div/div/app-button/button[contains(@class, 'btnSuccess')]")).Click(); Thread.Sleep(2000); IWebElement giveConsent = driver.FindElement(By.XPath("//button[contains(@class, 'btnSuccess btnOutline')]")); ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView();", giveConsent); driver.FindElement(By.XPath("//div[contains(@class, 'checkbox flex-center cboxSuccess')]")).Click(); Thread.Sleep(3000); driver.FindElement(By.XPath("//button[contains(@class, 'btnSuccess btnOutline')]")).Click(); Thread.Sleep(3000); } else { driver.Close(); driver.Quit(); } driver.Close(); driver.Quit(); }
public void IngresarPaginaAmazon(string Producto, out string Precio) { ////INGRESAR A LA PAGINA WEB DESDE FIREFOX IWebDriver driver = new FirefoxDriver(); driver.Navigate().GoToUrl("https://www.amazon.com/"); driver.Manage().Window.Maximize(); //* //ESCRIBIR EN EL BUSCADOR //masthead-search-term IWebElement input = driver.FindElement(By.Id("twotabsearchtextbox")); input.SendKeys(Producto); //DAR CLICK EN BUSCADOR //search-btn IWebElement btnSearch = driver.FindElement(By.Id("nav-search-submit-button")); btnSearch.Click(); //TRAER PRECIO PRIMER RESULTADO IWebElement output = driver.FindElement(By.ClassName("a-price")); Precio = output.Text; driver.Close(); }
static bool PlayMusicTest(out string status) { IWebDriver ffdriver = new FirefoxDriver(); try { ffdriver.Navigate().GoToUrl("https://gloryordeathrecords.bandcamp.com/album/bow-to-your-masters-volume-1-thin-lizzy"); var player = ffdriver.FindElement(By.ClassName("inline_player")); var playbutton = player.FindElement(By.TagName("a")); if (playbutton.GetAttribute("role") == "button") { Console.WriteLine("PlayButton"); playbutton.Click(); Thread.Sleep(2000); var playingStatus = player.FindElement(By.ClassName("playbutton playing")); } else { status = "wrong button status"; return(false); } status = "pass"; return(true); } catch (Exception exception) { status = exception.Message; return(false); } finally { ffdriver.Close(); } }
public void FirstTest() { RemoteWebDriver driver = null; try { var driverOptions = new FirefoxOptions(); driverOptions.BrowserExecutableLocation = ""; driver = new FirefoxDriver(driverOptions); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("http://www.github.com"); var home = new GithubHome(driver); var results = home.Search("quake"); results.ClickResult(0); } finally { driver?.Close(); } }
static void openFacebook() { IWebDriver driver = new FirefoxDriver(); driver.Url = "http://www.facebook.com"; driver.Manage().Window.Maximize(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); // acesso com usuario e senha driver.FindElement(By.Id("email")).SendKeys("*****@*****.**"); driver.FindElement(By.Id("pass")).SendKeys("Sanc622!" + Keys.Enter); // abrir link de amigos - friends driver.FindElement(By.XPath("/html/body/div[1]/div[3]/div[1]/div/div[2]/div[1]/div/div/div/div/div[1]/ul/li/a")).Click(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); Actions action = new Actions(driver); action.SendKeys(Keys.Alt + "n").Build().Perform(); action.SendKeys(Keys.Escape).Build().Perform(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); driver.FindElement(By.XPath("/html/body/div[1]/div[3]/div[1]/div/div[2]/div[2]/div[1]/div/div[1]/div/div[3]/div/div[2]/div[2]/ul/li[3]/a")).Click(); action.SendKeys(Keys.Escape); IList <IWebElement> iWebElement = driver.FindElements(By.XPath("*//div[@class='fsl fwb fcb']/a")); Console.WriteLine("Total de links de amigos: " + iWebElement.Count()); for (int i = 0; i < iWebElement.Count(); i++) { Console.WriteLine(iWebElement[i].Text); } driver.Close(); }
static bool FileUploadTest(out string status) { IWebDriver ffdriver = new FirefoxDriver(); try { ffdriver.Navigate().GoToUrl("https://imgur.com/upload"); var fileInput = ffdriver.FindElement(By.Id("global-files-button")); fileInput.SendKeys("/Users/xdegtyarev/Dropbox/Pictures/avatar.png"); Console.WriteLine("Uploading"); Thread.Sleep(200000); Thread.Sleep(200000); Console.WriteLine("Waited"); status = "pass"; return(true); } catch (Exception exception) { status = exception.Message; return(false); } finally { ffdriver.Close(); } }
public void TestAlbiclaFirefox() { IWebDriver driver = new FirefoxDriver(); driver.Url = "https://albicla.com/zarejestruj"; IWebElement firstnameAlbi = driver.FindElement(By.Id("inputName")); firstnameAlbi.SendKeys("Mateusz"); IWebElement emailAlbi = driver.FindElement(By.Id("inputEmail")); emailAlbi.SendKeys("*****@*****.**"); IWebElement pwAlbi = driver.FindElement(By.XPath("//input[@name='pass']")); pwAlbi.SendKeys("parufka"); IWebElement pw2Albi = driver.FindElement(By.XPath("//input[@name='pass2']")); pw2Albi.SendKeys("parufka"); SelectElement countryAlbi = new SelectElement(driver.FindElement(By.Id("country"))); countryAlbi.SelectByValue("PL"); IWebElement osobaAlbi = driver.FindElement(By.Id("type1")); osobaAlbi.Click(); IWebElement regulaminAlbi = driver.FindElement(By.Id("regulamin")); regulaminAlbi.Click(); Thread.Sleep(3000); driver.Close(); }
public Magazine AnalyzeData(Magazine derStandard) { try { FirefoxOptions options = new FirefoxOptions(); options.SetPreference("dom.push.enabled", false); foreach (Resort item in derStandard) { try { using (IWebDriver driver = new FirefoxDriver("../", options)) { AnalyzeResort(item, driver); driver.Close(); driver.Dispose(); } } catch (Exception e) { e.LogErrorToTSV("while analyzing resort " + item.name); } } } catch (Exception e) { e.LogErrorToTSV("generally unknown Error"); } return(derStandard); }
public void CheckNavBar_GetElements() { _output.WriteLine("Step 00 : 准备测试数据。"); var testDatas = new List <string>() { "首页", "精华", "候选", "新闻" }; //准备测试数据 _output.WriteLine("Step 01 : 启动浏览器并打开博客园首页。"); IWebDriver driver = new FirefoxDriver(); driver.Url = "http://www.cnblogs.com"; _output.WriteLine("Step 02 : 寻找需要检查的页面元素。"); var divMain = driver.FindElement(By.Id("main")); var lnkNavList = driver.FindElements(By.XPath(".//ul[@class='post_nav_block']/li[1]/a")); _output.WriteLine("Step 03 : 检查导航条文字信息。"); for (var i = 0; i < lnkNavList.Count; i++) { Assert.Equal <string>(testDatas[i], lnkNavList[i].Text); } _output.WriteLine("Step 04 : 关闭浏览器。"); driver.Close(); }
public void Test() { IWebDriver driver = new FirefoxDriver(); driver.Url = "http://www.demoqa.com"; driver.Close(); }
public void TestFirefoxCap() { IWebDriver driver = null; try { FirefoxOptions options = new FirefoxOptions(); options.LogLevel = FirefoxDriverLogLevel.Info; // options.Profile = new FirefoxProfile("profile-name"); options.UseLegacyImplementation = false; driver = new FirefoxDriver(options); driver.Url = "http://www.softpost.org"; driver.Manage().Window.Maximize(); driver.Navigate(); Console.WriteLine("Success"); } catch (Exception e) { Console.WriteLine("Exception ....*********" + e.ToString()); } finally { Thread.Sleep(2000); driver.Close(); driver.Quit(); } }
//авторизоваться, зайти в первую группу, зайти к случайному участнику, заблокировать его, и разблокировать public void VK_LoginThenBlockAndUnlockUserFromFirstGroup_ExceptionShouldNotOccur() { using (var driver = new FirefoxDriver(FireFoxDriversDirectory)) { Helper.FixDriverCommandExecutionDelay(driver); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20); driver.Url = "https://vk.com/"; driver.FindElement(By.Id("index_email")).SendKeys(_VkCredentials.Login); driver.FindElement(By.Id("index_pass")).SendKeys(_VkCredentials.Password); driver.FindElement(By.Id("index_login_button")).Click(); driver.FindElement(By.Id("l_gr")).Click(); //открываем страницу с группами driver.FindElement(By.XPath("//*[@id=\"groups_list_groups\"]/div[1]/a")).Click(); //жмем на первую группу в списке driver.FindElement(By.XPath("//*[contains(@id,'_followers')]/a/div")).Click(); //открываем список участников driver.FindElement(By.XPath("//*[@id=\"fans_rowsmembers\"]/div[1]/div[1]")).Click(); //жмем на первого участника var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//*[@id=\"narrow_column\"]/div[1]/aside/div/div[2]/div[2]/div[1]"))).Click(); //раскрываем меню дополнительных функций у пользователя //Thread.Sleep(1000); wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//*[@id=\"narrow_column\"]/div[1]/aside/div/div[2]/div[2]/div[2]/div[2]/a[4]"))).Click(); //кликаем на пункт о блокировке пользователя Thread.Sleep(2000); wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//*[@id=\"narrow_column\"]/div[1]/aside/div/div[2]/div[2]/div[2]/div[2]/a[4]"))).Click(); //кликаем на пункт о разблокировке пользователя Thread.Sleep(5000); driver.Close(); } }
//авторизоватся и оставить пост на своей стене public void VK_LoginAndMakePost_ExceptionShouldNotOccur() { using (IWebDriver driver = new FirefoxDriver(FireFoxDriversDirectory)) { Helper.FixDriverCommandExecutionDelay(driver); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20); driver.Url = "https://vk.com/"; driver.FindElement(By.Id("index_email")).SendKeys(_VkCredentials.Login); //вставляем логин driver.FindElement(By.Id("index_pass")).SendKeys(_VkCredentials.Password); //вставляем пароль driver.FindElement(By.Id("index_login_button")).Click(); //жмем кнопку входа driver.FindElement(By.Id("l_pr")).Click(); //открываем страницу нашего профиля var input = driver.FindElement(By.Id("post_field")); driver.Scripts().ExecuteScript("arguments[0].scrollIntoView()", input); //скроллим окно до элемента input.SendKeys("умею быстро придумывать числа: " + new Random().Next(100000, 9999999).ToString()); //вводим текст в поле нового поста var button = driver.FindElement(By.Id("send_post")); driver.Scripts().ExecuteScript("arguments[0].click();", button); //отправляем пост на стену Thread.Sleep(5000); driver.Close(); } }
//авторизоваться, найти страницу Евгения, открыть его аватарку, поставить лайк и оставить комментарий public void VK_LoginThenLikeAndCommentEugene_ExceptionShouldNotOccur() { using (var driver = new FirefoxDriver(FireFoxDriversDirectory)) { Helper.FixDriverCommandExecutionDelay(driver); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20); driver.Url = "https://vk.com/"; driver.FindElement(By.Id("index_email")).SendKeys(_VkCredentials.Login); driver.FindElement(By.Id("index_pass")).SendKeys(_VkCredentials.Password); driver.FindElement(By.Id("index_login_button")).Click(); driver.FindElement(By.Id("l_fr")).Click(); //открываем страницу с друзьями Thread.Sleep(500); //фоновые скрипты должны прогрузиться, в противном случае текстовое поле не реагирует на изменения driver.FindElement(By.Id("s_search")).SendKeys("Евгений Касперский"); //вводим Евгения в поиск driver.FindElement(By.Id("s_search")).SendKeys(Keys.Enter); //подтверждаем. driver.FindElement(By.XPath("//*[@id=\"friends_search_cont\"]/div[1]/div[1]/div[3]/div[1]/a")).Click(); //жмем на первого человека в списке driver.FindElement(By.XPath("//*[@id=\"profile_photo_link\"]/img")).Click(); //открываем аватарку Евгения driver.FindElement(By.XPath("//*[@id=\"pv_narrow\"]/div[1]/div[1]/div/div/div[1]/div[3]/div/div[1]/a[1]/div[1]")).Click(); //ставим лайк на аватарку Евгению driver.FindElement(By.XPath("//*[starts-with(@id,'reply_field')]")).SendKeys("отличное фото"); //набираем ему комментарий под фото driver.FindElement(By.ClassName("addpost_button_wrap")).Click(); //отправляем комментарий Евгению Thread.Sleep(5000); driver.Close(); } }
private void InternalTestLogic(string cityFrom, string CityTo, bool needVerifyQvt, bool isInland) { FirefoxDriver driver = new FirefoxDriver(); driver.Navigate().GoToUrl("http://flight.qunar.com/"); PageObjectFactory.UIMapFilePath = @"..\..\..\QunaWebTestFramework\UIMaps"; HomePage homePage = PageObjectFactory.InitPage <HomePage>(driver); DateTime serverDaysAfter = DateTime.Now.AddDays(7); homePage.OneWaySearch(cityFrom, CityTo, serverDaysAfter.ToString("yyyy-MM-dd")); Thread.Sleep(1000 * 10); SearchResultPage searchResultPage = PageObjectFactory.InitPage <SearchResultPage>(driver); int maxRetryTimes = 0; while (searchResultPage.ResultInfo != null) { if (maxRetryTimes == 60) { Assert.Fail("Fail to get search result!!"); } Thread.Sleep(1000); try { if (searchResultPage.ResultInfo.Text.Contains("搜索结束")) { break; } } catch (Exception) { } searchResultPage = PageObjectFactory.InitPage <SearchResultPage>(driver); maxRetryTimes++; } if (isInland) { searchResultPage.ClickOrderButtonForInland(0); } else { searchResultPage.ClickOrderButton(0); } if (needVerifyQvt) { Assert.IsTrue(searchResultPage.QvtWarning(0, isInland)); Assert.IsTrue(searchResultPage.VerifyTransfer(0, isInland)); } else { Assert.IsTrue(searchResultPage.VerifyPriceRange(0)); } this.AddTestCleanup("Close Browser", () => { driver.Close(); }); }
public void changeContact() { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl(link); Thread.Sleep(3000); driver.FindElement(By.XPath("//input[@placeholder='Username']")).Click(); driver.FindElement(By.XPath("//input[@placeholder='Username']")).SendKeys("*****@*****.**"); driver.FindElement(By.XPath("//input[@placeholder='Password']")).Click(); driver.FindElement(By.XPath("//input[@placeholder='Password']")).SendKeys("12345678"); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); driver.FindElement(By.XPath("//span[contains(@class,'font-bold') and contains(text(), 'Log in')]")).Click(); Thread.Sleep(5000); driver.FindElement(By.XPath("//div[contains(@class, 'settings-wrapper clickable flex-center')]")).Click(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(3); driver.FindElement(By.XPath("//input[contains(@type, 'tel')]")).SendKeys("99924"); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); driver.FindElement(By.XPath("//button[contains(@class, 'btnOutline btnDark')]")).Click(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); driver.Close(); driver.Quit(); }
public void UrlTest(string url) { GoTo(url); if (_browser.Url != url) { try { Assert.AreEqual(_browser.Url, url); } finally { _browser.Close(); } } }
public void ElementComands() { IWebDriver driver = new FirefoxDriver(); //open webpage in firefox driver.Url = "http://toolsqa.wpengine.com/automation-practice-form/"; //fill in first name IWebElement firstName = driver.FindElement(By.Name("firstname")); firstName.SendKeys("Megan"); //Fill in last name IWebElement lastName = driver.FindElement(By.Name("lastname")); lastName.SendKeys("Styles"); //Click submit IWebElement submit = driver.FindElement(By.Id("submit")); submit.Click(); //Close Browser driver.Close(); }
public void TestMultipleSelection() { IWebDriver driver = new FirefoxDriver(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMinutes(3); driver.Url = "http://toolsqa.wpengine.com/automation-practice-form"; SelectElement oSelection = new SelectElement(driver.FindElement(By.Name("selenium_commands"))); oSelection.SelectByIndex(0); Thread.Sleep(2000); oSelection.DeselectByIndex(0); oSelection.SelectByText("Navigation Commands"); Thread.Sleep(2000); oSelection.DeselectByText("Navigation Commands"); IList <IWebElement> oSize = oSelection.Options; int iListSize = oSize.Count; for (int i = 0; i < iListSize; i++) { String sValue = oSelection.Options.ElementAt(i).Text; Console.WriteLine("Value of the Item is : " + sValue); oSelection.SelectByIndex(i); Thread.Sleep(2000); } oSelection.DeselectAll(); driver.Close(); }
public void FBSignUpNegative() { ExcelLib.PopulateInCollection(@"C:\Users\fukha\documents\visual studio 2017\Projects\FinSuite\FinSuite\ExcelFile\FB.xlsx"); IWebDriver driver = new FirefoxDriver(); driver.Url = "https://www.facebook.com/"; driver.Manage().Window.Maximize(); //driver.Manage().Timeouts().i(TimeSpan.FromSeconds(10)); driver.FindElement(By.Id("u_0_l")).SendKeys(ExcelLib.ReadData(2, "FirstName")); driver.FindElement(By.Id("u_0_n")).SendKeys(ExcelLib.ReadData(2, "LastName")); driver.FindElement(By.Id("u_0_q")).SendKeys(ExcelLib.ReadData(2, "MobileNo")); driver.FindElement(By.Id("u_0_x")).SendKeys(ExcelLib.ReadData(2, "Password")); SelectElement day = new SelectElement(driver.FindElement(By.Id("day"))); day.SelectByText("3"); SelectElement month = new SelectElement(driver.FindElement(By.Id("month"))); month.SelectByIndex(1); SelectElement year = new SelectElement(driver.FindElement(By.Id("year"))); year.SelectByText("1980"); driver.FindElement(By.XPath("//div[@id='reg_form_box']//span[@class='_5k_3']/span[1]/input[@name='sex']")).Click(); Thread.Sleep(3000); //driver.FindElement(By.Id("u_0_15")).Click(); Thread.Sleep(2000); driver.Close(); driver.Quit(); }
public static void Main(string[] args) { // Initialize RecognitionEngine RecognitionEngine recogEngine = new RecognitionEngine(); recogEngine.SetupRecognitionEngine(); // Initialize SpeechSynthesizer SpeechSynthesizer synthEngine = new SpeechSynthesizer(); synthEngine.SetOutputToDefaultAudioDevice(); // Initialize FirefoxDriver string GeckoDriverPath = @"C:\Users\adity\source\repos\SpeechRecogTest\geckodriver-v0.21.0-win64"; IWebDriver driver = new FirefoxDriver(GeckoDriverPath); /* * string recognizedText = recogEngine.GetRecognizedText(synthEngine); * synthEngine.Speak("You have said " + recognizedText + "which I have successfully detected"); */ BankBazaar.HomePageClass.run(recogEngine, synthEngine, driver); //Youtube.HomePageClass.run(recogEngine, synthEngine, driver); driver.Close(); driver.Quit(); }