static void Main(string[] args) { ChromeOptions options = new ChromeOptions(); options.AddArguments(@"user-data-dir=C:\Users\raton\AppData\Local\Google\Chrome\User Data"); ChromeDriver driver = new ChromeDriver(options); driver.Navigate().GoToUrl("https://discord.com/invite/pokimane"); System.Threading.Thread.Sleep(1000); driver.FindElement(By.ClassName("contents-18-Yxp")).Click(); System.Threading.Thread.Sleep(6200); var captureds = driver.FindElementsByXPath("//div[@class='name-3_Dsmg overflow-WK9Ogt']"); captureds.First(x => x.Text == "verification").Click(); System.Threading.Thread.Sleep(1000); driver.SwitchTo().ActiveElement().SendKeys("!verify"); driver.SwitchTo().ActiveElement().SendKeys(Keys.Enter); driver.FindElementByClassName("homeIcon-tEMBK1").Click(); driver.FindElementByClassName("overflow-WK9Ogt").Click(); System.Threading.Thread.Sleep(300); driver.SwitchTo().ActiveElement().SendKeys("dqjYN"); driver.SwitchTo().ActiveElement().SendKeys(Keys.Enter); System.Threading.Thread.Sleep(300); driver.FindElementByClassName("wrapper-1BJsBx").Click(); Console.WriteLine("thank you!"); Console.WriteLine("thank you!"); System.Threading.Thread.Sleep(30000); var captured = "oi"; }
/// <summary> /// 爬虫 /// </summary> /// <param name="arrStrings"></param> static void ChromeMethod(string[] arrStrings) { ChromeOptions op = new ChromeOptions(); // op.AddArguments("--headless");//开启无gui模式 // op.AddArguments("--no-sandbox");//停用沙箱以在Linux中正常运行 ChromeDriver cd = new ChromeDriver(op); cd.Navigate().GoToUrl(arrStrings[4] + arrStrings[0]); var userNameEle = cd.FindElementById("id"); var passwordEle = cd.FindElementById("passwd"); var loginEle = cd.FindElementByClassName("MdBtn03Login"); userNameEle.SendKeys(arrStrings[1]); passwordEle.SendKeys(arrStrings[2]); Console.WriteLine("回车登录"); Console.ReadLine(); loginEle.Click(); Console.WriteLine("选择enterprise菜单"); Console.ReadLine(); var enterpriseEle = cd.FindElementByClassName("_center_merchant_list"); enterpriseEle.Click(); Console.ReadLine(); cd.Quit(); Console.ReadLine(); }
public static void Main(string[] args) { var options = new ChromeOptions(); options.AddArguments("--disable-gpu"); var chromeDriver = new ChromeDriver(options); //go to webite chromeDriver.Navigate().GoToUrl("https://facebook.com"); //login chromeDriver.FindElementByName("email").SendKeys("*****@*****.**"); chromeDriver.FindElementByName("pass").SendKeys("bobjoebob1"); chromeDriver.FindElementByClassName("login_form_login_button").Click(); //go to profile chromeDriver.FindElementByClassName("_3ixn").Click(); chromeDriver.FindElementById("home_birthdays").Click(); chromeDriver.FindElementByClassName("enter_submit").SendKeys("happy birthday"); //var friendsName = chromeDriver.FindElementByClassName("fsm") //Console.WriteLine(friendsName); }
public List <string> Search() { ChromeDriverService service = ChromeDriverService.CreateDefaultService(); service.HideCommandPromptWindow = true; var driver = new ChromeDriver(service); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://www.kinopoisk.ru"); Thread.Sleep(1000); var inp = driver.FindElement(By.ClassName("header-fresh-search-partial-component__field")); inp.SendKeys(filmName); inp.Submit(); var film = driver.FindElementByClassName("name").FindElement(By.ClassName("js-serp-metrika")); film.Click(); var info = driver.FindElementsByCssSelector(".info tbody tr td a"); var name = driver.FindElementByClassName("moviename-title-wrapper"); string infoAboutFilm = $"Название фильма - {name.Text}\n" + $"Год выпуска {info[0].Text}\n" + $"Страна производства {info[1].Text}\n" + $"Режисёр {info[2].Text}"; List <string> data = new List <string>(); data.Add(infoAboutFilm); var img = driver.FindElementByCssSelector("a.popupBigImage img"); string src = img.GetAttribute("src"); data.Add(src); return(data); }
public void SignIn() { //Login Page _driver.Navigate().GoToUrl(this.startURL); for (var i = 0; i < 10; i++) { if (_driver.FindElement(By.Id("username")) != null) { break; } Thread.Sleep(1000); } var userName = _driver.FindElementById("username"); var userPassword = _driver.FindElementById("password"); var loginButton = _driver.FindElementByClassName("btn"); userName.SendKeys(""); userPassword.SendKeys(""); loginButton.Click(); System.Threading.Thread.Sleep(1000); //var dontaskmeagaincheck = driver.FindElementByPartialLinkText("Don't ask me again"); var notifyMe = _driver.FindElementByClassName("css-1nnnf3h"); //dontaskmeagaincheck.Click(); notifyMe.Click(); //Now we're on the dashboard _driver.Manage().Window.Maximize(); }
public void TestMethod1() { ChromeDriver Driver = new ChromeDriver(); Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20); Driver.Manage().Window.Maximize(); Driver.Navigate().GoToUrl("https://www.hm.se"); /*driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);*/ IWebElement SearchFunction = Driver.FindElementById("main-search"); SearchFunction.Click(); Driver.FindElementById("main-search").SendKeys("kofta"); Driver.FindElementByClassName("menu__search_submit").Click(); Driver.FindElementByXPath("//button[@class='close icon-close-white js-close']").Click(); Driver.FindElementByClassName("item-image").Click(); //första koftan Driver.FindElementByXPath("//button[contains(@class,'picker-trigger js-picker-trigger small notify-if-back')]//span[contains(@class,'value')][contains(text(),'Välj storlek')]").Click(); Driver.FindElementByXPath("//ul/li[2]/div/button/span").Click(); //XS //Driver.FindElementByXPath("#main-content > div.product.parbase > div.layout.pdp-wrapper.product-detail.sticky-footer-wrapper.js-reviews > div.module.product-description.sticky-wrapper > div.sub-content.product-detail-info.inner.sticky-on-scroll.semi-sticky > div > div.product-item-buttons > div.product-button-wrapper > button").Click(); /* Actions action = new Actions(Driver); * ChromeWebElement mobileElement = Driver.FindElementByCssSelector(".icon-shopping-bag-white"); * Action.moveToElement(mobileElement).build().perform();*/ Driver.FindElementByCssSelector(".icon-shopping-bag-white").Click(); Driver.Close(); Driver.Quit(); /*Actions action = new Actions(Driver); * WebElement mobileElement = Driver.findElement(By.linkText("Mobile & Accessories")); * action.moveToElement(mobileElement).build().perform();*/ //ändring }
public CreateStoriesAndVotingProcess VotingProcessQuickPlay(string storyName) { wait.Until(ExpectedConditions.ElementToBeClickable(By.Name("inputName"))); driver.FindElementByName("inputName").SendKeys(storyName); IWebElement ClickSaveAndClose = driver.FindElementByXPath("//*[@ng-bs-click='createAndClose']"); ClickSaveAndClose.Click(); wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//*[@data-role='end']"))); IWebElement clickEndTour = driver.FindElementByXPath("//*[@data-role='end']"); clickEndTour.Click(); wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("btn-start"))); IWebElement clickStart = driver.FindElementById("btn-start"); clickStart.Click(); wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//button[contains(@ng-bs-click, 'resetTimer')]"))); IWebElement clickOnTheCard = driver.FindElementByXPath("//*[text()='2']"); clickOnTheCard.Click(); wait.Until(ExpectedConditions.ElementExists(By.Id("finalEstimate"))); SelectElement element = new SelectElement(driver.FindElementById("finalEstimate")); element.SelectByValue("3"); driver.FindElementByClassName("btn-one").Click(); return(new CreateStoriesAndVotingProcess(driver)); }
public void TestRegistration() { Driver.Navigate().GoToUrl(URL + "Registracija"); Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); Driver.FindElementById("Ime").SendKeys("Karen"); Driver.FindElementById("Priimek").SendKeys("Erdelji"); Driver.FindElementById("datepicker").Clear(); var js = (IJavaScriptExecutor)Driver; js.ExecuteScript("document.getElementById('datepicker').value='10/7/2000'"); Driver.FindElementById("EMSO").SendKeys("1106999500176"); Driver.FindElementByClassName("amount").SendKeys("20"); Driver.FindElementById("Naslov").SendKeys("Koroška 108"); Driver.FindElementByName("PostnaStevilka").SendKeys("2000"); Driver.FindElementById("Posta").SendKeys("Maribor"); Driver.FindElementById("Drzava").SendKeys("SVN"); Driver.FindElementById("EPosta").SendKeys("*****@*****.**"); Driver.FindElementById("Geslo").SendKeys("Dexter123?"); Driver.FindElementById("PonovnoGeslo").SendKeys("Dexter123?"); Driver.FindElementByCssSelector("input.btn.btn-outline-primary").Click(); Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); Driver.Navigate().GoToUrl(URL + "Clan"); Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); Assert.IsTrue(Driver.PageSource.Contains("Karen Erdelji")); }
public static void Main(string[] args) { // download and unzip driver in project folder http://chromedriver.storage.googleapis.com/index.html?path=2.27/ var driver = new ChromeDriver("."); try { driver.Navigate().GoToUrl(CARJOJO_URL); driver.FindElementByClassName("brand").Click(); Task.Delay(1000).Wait(); driver.FindElementByClassName("model").Click(); // Task.Delay(2000).Wait(); // driver.FindElementByXPath("//*button[@class='button expand carjojo-button strange-limey-yellow']").Click(); // Task.Delay(1000).Wait(); // driver.FindElementByXPath("//*[contains(text(), 'SHOW VEHICLES')]").Click(); // sample code existed. } catch (System.Exception ex) { System.Console.WriteLine(ex.ToString()); System.Console.WriteLine("Closing browser in 3 sec ..."); } finally { // Close the browser after 3 sec Task.Delay(3000).Wait(); driver.Quit(); } }
static void Main(string[] args) { using (var driver = new ChromeDriver()) { // driver.Navigate().GoToUrl("http://tmparts.ru"); driver.Navigate().GoToUrl("http://krsk.rossko.ru/"); var searchFld = driver.FindElementByClassName("Eqbi2-7"); var lookBtn = driver.FindElementByClassName("_3wDmteG"); //var userPasswordField = driver.FindElementById("pwd"); // var loginButton = driver.FindElementByXPath("//input[@value='Login']"); // Type user name and password searchFld.SendKeys("cvm6"); //userPasswordField.SendKeys("12345"); // and click the login button lookBtn.Click(); WaitForReady(driver, By.ClassName("_3fkU7Sg")); /* * // Extract the text and save it into result.txt * var result = driver.FindElementByXPath("//div[@id='case_login']/h3").Text; * File.WriteAllText("result.txt", result); */ // Take a screenshot and save it into screen.png driver.GetScreenshot().SaveAsFile(@"screen.png", ScreenshotImageFormat.Png); } }
static void Disconnect(ChromeDriver driver, bool doubleClick = true) { var b = driver.FindElementByClassName("o-esc"); var discMessage = driver.FindElementByClassName("log-disconnected"); if (discMessage.GetAttribute("style").Contains("block")) { Console.WriteLine("Sleeping before reconnecting..."); Thread.Sleep(new Random().Next(0, 5000)); b.Click(); return; } // Disconnect because the other person is still connected b.Click(); b.Click(); Console.WriteLine("Sleeping before reconnecting..."); Thread.Sleep(new Random().Next(0, 5000)); // Find someone new b.Click(); //b.Click(); //if(doubleClick) // b.Click(); }
protected void Type(string path, string pathType, string value) { if (pathType == "id") { IWebElement element = driver.FindElementById(path); element.Clear(); element.SendKeys(value); TestCase.Log("Entered " + value + " at element with id=" + path); } if (pathType == "name") { IWebElement element = driver.FindElementByName(path); element.Clear(); element.SendKeys(value); TestCase.Log("Entered " + value + " at element with name=" + path); } if (pathType == "class") { IWebElement element = driver.FindElementByClassName(path); element.Clear(); element.SendKeys(value); TestCase.Log("Entered " + value + " at element with class=" + path); } if (pathType == "xpath") { IWebElement element = driver.FindElementByXPath(path); element.Clear(); element.SendKeys(value); TestCase.Log("Entered " + value + " at element with xpath=" + path); } }
public void CheckUserCanJoin() { ChromeDriver driver = GetUserConnection(); IWebElement hostButton = driver.FindElementById("host-button"); hostButton.Click(); Task.Delay(5000).Wait(); IWebElement groupDriver = driver.FindElementByClassName("group"); string groupId = groupDriver.Text.Split(null)[2]; ChromeDriver navigator = GetUserConnection(); IWebElement groupField = navigator.FindElementById("join-input"); groupField.SendKeys(groupId); Task.Delay(5000).Wait(); IWebElement joinButton = navigator.FindElementById("join-button"); joinButton.Click(); Task.Delay(5000).Wait(); IWebElement groupNavigator = driver.FindElementByClassName("group"); Assert.Equal(groupDriver.Text, groupNavigator.Text); driver.Quit(); navigator.Quit(); }
public void CN003_Matriculas_ValidarMatriculaDuplicada() { Thread.Sleep(1000); var divInput = driver.FindElementByClassName("alert-info"); Assert.AreEqual("Este aluno já está matriculado neste curso, no mesmo ano e período.", divInput.Text); }
public void parrotNameSite_EmptyEmail_ErrorText() { SendRequest(string.Empty, radioBoyLocator); var errorText = Driver.FindElementByClassName("form-error"); Assert.IsTrue(errorText.Displayed, "Не отображается текст ошибки \"Введите email\""); Assert.AreEqual("Введите email", errorText.Text, "Неверный текст ошибки"); }
static void Main(string[] args) { string url = "https://web.whatsapp.com"; List <string> contatos = new List <string>() { "Teste Bot Whatsapp" }; //Instancia do ChromeDriver ChromeDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl(url); driver.Manage().Window.Maximize(); //Espera um tempo para escanear o QR Code do WhatsApp Thread.Sleep(7000); //Abre as conversas //Manda mensagem para todos os contatos foreach (var contato in contatos) { //Quando estamos na tela de pesquisa //<div class="_3FRCZ copyable-text selectable-text" contenteditable="true" data-tab="3" dir="ltr"></div> var pesquisaEl = driver.FindElementByClassName("_3FRCZ"); //if (contato.ToString() == "Mãe"){ pesquisaEl.SendKeys(contato); //} //Tempo entre a digitação e a pesquisa Thread.Sleep(10000); //<span dir="auto" title="Teste Bot Whatsapp" class="_3ko75 _5h6Y_ _3Whw5">Teste Bot Whatsapp</span> //<div class="_3CneP"><span class="_357i8"><span dir="auto" title="Mãe" class="_3ko75 _5h6Y_ _3Whw5"><span class="matched-text _3Whw5">Mãe</span></span><div class="_3XFan"></div></span></div> var contatoElemento = driver.FindElementByXPath("//span[@title='Teste Bot Whatsapp']"); //Clicka no contato: contatoElemento.Click(); //Thread.Sleep(3000); //Clicka na caixa de entrada de texto //<div tabindex="-1" class="_3uMse"><div tabindex="-1" class="_2FVVk _2UL8j"><div class="_2FbwG" style="visibility: visible;">Digite uma mensagem</div><div class="_3FRCZ copyable-text selectable-text" contenteditable="true" data-tab="1" dir="ltr" spellcheck="true"></div></div></div> var chatElemento = driver.FindElementByClassName("_3uMse"); chatElemento.Click(); Thread.Sleep(3000); //Digita o texto chatElemento.SendKeys("Olá, eu sou um robô!"); //Envia o texto //<div class="_1JNuk"><button class="_1U1xa"><span data-icon="send" class=""><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="currentColor" d="M1.101 21.757L23.8 12.028 1.101 2.3l.011 7.912 13.623 1.816-13.623 1.817-.011 7.912z"></path></svg></span></button></div> // var enviaElemento = driver.FindElementByClassName("_1JNuk"); // enviaElemento.Click(); //<span data-icon="send" class=""><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="currentColor" d="M1.101 21.757L23.8 12.028 1.101 2.3l.011 7.912 13.623 1.816-13.623 1.817-.011 7.912z"></path></svg></span> var buttonSend = driver.FindElementByXPath($"//span[@data-icon='send']"); buttonSend.Click(); } }
public void GetRates() { ChromeOptions option = new ChromeOptions(); option.AddArgument("--headless"); using (var driver = new ChromeDriver(option)) { driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(20); driver.Navigate().GoToUrl("https://www.firstchoicepower.com/"); var zipCodeField = driver.FindElementByClassName("zipcode"); var searchButton = driver.FindElementByClassName("submitOrder"); zipCodeField.SendKeys(Zipcode); searchButton.Click(); for (var i = 1; i <= 3; i++) { for (var j = 1; j <= 3; j++) { Rate currentRate = new Rate(); currentRate.RatePerKWH = driver.FindElementByXPath($"//*[@id=\"tab_11\"]/div[{i}]/div[{j}]/div/div/div[2]/h4/span").GetAttribute("innerText"); currentRate.Product = driver.FindElementByXPath($"//*[@id=\"tab_11\"]/div[{i}]/div[{j}]/div/div/h3/span").GetAttribute("innerText"); for (var x = 1; x <= 2; x++) { string description = driver.FindElementByXPath($"//*[@id=\"tab_11\"]/div[{i}]/div[{j}]/div/div/ul/li[{x}]/div").GetAttribute("innerText"); currentRate.PromotionDesc.Add(description); } if (currentRate.Product[0] == 'Y') { currentRate.Term = currentRate.Product.Substring(currentRate.Product.Length - 2); } else if (currentRate.Product[0] == 'M') { currentRate.Term = "Month to Month"; } else { currentRate.Term = "Prepaid"; } //currentRate.Term = "0"; currentRate.EnrollURL = "#"; currentRate.FactsURL = driver.FindElementByXPath($"//*[@id=\"tab_11\"]/div[{i}]/div[{j}]/div/div/div[3]/a[3]").GetAttribute("href"); Rates.Add(currentRate); } } empty = false; } }
/// <summary> /// Browser test recaptcha invisible /// </summary> private static void browser_test_invisible() { Console.WriteLine("[=] BROWSER TEST STARTED (INVISIBLE CAPTCHA) [=]"); var s = ChromeDriverService.CreateDefaultService(); s.HideCommandPromptWindow = true; ChromeDriver d = new ChromeDriver(s); try { d.Navigate().GoToUrl(TEST_PAGE_INVISIBLE); // go to normal test page // complete regular data d.FindElementByName("username").SendKeys("my-username"); d.FindElementByName("password").SendKeys("password-here"); Console.WriteLine("[+] Completed regular info"); // --------------------- // get sitekey string site_key = d.FindElementByClassName("g-recaptcha").GetAttribute("data-sitekey"); string callback_method = d.FindElementByClassName("g-recaptcha").GetAttribute("data-callback"); Console.WriteLine(string.Format("[+] Site key: {0}", site_key)); Console.WriteLine(string.Format("[+] Callback method: {0}", callback_method)); // complete captcha Console.WriteLine("[+] Waiting for recaptcha to be solved ..."); ImageTypersAPI i = new ImageTypersAPI(IMAGETYPERS_TOKEN); Dictionary <string, string> p = new Dictionary <string, string>(); p.Add("page_url", TEST_PAGE_NORMAL); p.Add("sitekey", site_key); p.Add("type", "2"); string recaptcha_id = i.submit_recaptcha(p); // submit recaptcha info // while in progress, sleep for 10 seconds while (i.in_progress(recaptcha_id)) { Thread.Sleep(10000); } string g_response_code = i.retrieve_captcha(recaptcha_id); //Console.Write("CODE:"); Console.ReadLine(); string g_response_code = File.ReadAllText("g-response.txt"); // get manually Console.WriteLine(string.Format("[+] Got g-response-code: {0}", g_response_code)); // set g-response-code in page source (with javascript) IJavaScriptExecutor e = (IJavaScriptExecutor)d; string javascript_code = string.Format("document.getElementById('g-recaptcha-response').innerHTML = '{0}';", g_response_code); e.ExecuteScript(javascript_code); Console.WriteLine("[+] Code set in page"); // submit form e.ExecuteScript(string.Format("{0}(\"{1}\");", callback_method, g_response_code)); Console.WriteLine("[+] Callback function executed"); } finally { Thread.Sleep(5000); d.Quit(); // quit browser Console.WriteLine("[=] BROWSER TEST FINISHED [=]"); } }
static void Main(string[] args) { ChromeDriver myBrowser = new ChromeDriver(); //**************************************************************************** myBrowser.Navigate().GoToUrl("http://www.hwpl.org/databases/"); myBrowser.FindElementByLinkText("ABI/INFORM Complete").Click(); myBrowser.FindElementById("barcode").SendKeys("21327001023680"); myBrowser.FindElementById("barcodeSubmit").Click(); var searchPageUrl = myBrowser.Url; myBrowser.FindElementById("searchTerm").SendKeys("(907) 225-1494"); myBrowser.FindElementById("expandedSearch").Click(); var items = myBrowser.FindElementByClassName("resultItems").FindElements(By.TagName("li")); bool found = false; foreach (var item in items) { var sourceItems = item.FindElement(By.ClassName("item")).FindElements(By.ClassName("titleAuthorETC")); foreach (var scrItem in sourceItems) { if (scrItem.Text.Contains("Experian Commercial Risk Database")) { found = true; break; } } if (found) { item.FindElement(By.TagName("h3")).FindElement(By.TagName("a")).Click(); break; } } if (!found) { myBrowser.Navigate().GoToUrl(searchPageUrl); } while (myBrowser.FindElementsById("emailLink").Count == 0) { Thread.Sleep(500); } Thread.Sleep(1000); myBrowser.FindElementById("emailLink").Click(); while (myBrowser.FindElementsByClassName("emailBccTextField").Count == 0) { Thread.Sleep(500); } Thread.Sleep(1000); myBrowser.FindElementByClassName("emailBccTextField").FindElement(By.TagName("input")).SendKeys("*****@*****.**"); myBrowser.FindElementByClassName("clsEmlUsrNm").SendKeys("Danyal"); myBrowser.FindElementByLinkText("Continue").Click(); Thread.Sleep(1000); myBrowser.Navigate().GoToUrl(searchPageUrl); }
private void button2_Click(object sender, EventArgs e) { new Thread(() => { link.Enabled = false; button2.Enabled = false; soLuong.Enabled = false; if (link.Text.Equals("")) { MessageBox.Show("Vui lòng nhập link"); } else { if (soLuong.Text.Equals("")) { MessageBox.Show("Vui lòng nhập số lượng chap cần tải"); } else { chrome = new ChromeDriver(); chrome.Url = link.Text; chrome.Navigate(); for (int i = 0; i < Int16.Parse(soLuong.Text); i++) { WaitToLoad(chrome, By.ClassName("lazy")); chrome.ExecuteScript("console.log('Load Page Done');"); createDirectory(chrome); getImage(chrome, i); string size = "\\" + xuli(chrome.FindElementByClassName("detail-title").Text); path.Text = path.Text.Substring(0, path.Text.Length - size.Length); try { chrome.Url = chrome.FindElementByClassName("link-next-chap").GetAttribute("href"); chrome.Navigate(); } catch (Exception) { MessageBox.Show("Không Tìm Thấy Link Chap Mới. Kêt Thúc Việc Tải"); break; } } chrome.Close(); chrome.Quit(); } } link.Enabled = true; button2.Enabled = true; soLuong.Enabled = true; MessageBox.Show("Done"); }) { IsBackground = true }.Start(); }
private static string RealizaComentario(ChromeDriver driver) { driver.FindElementByClassName("Ypffh").Click(); var inputComentario = driver.FindElementByClassName("Ypffh"); var comentario = MarcarPessoas(inputComentario); Thread.Sleep(1000); driver.FindElementByXPath("//button[contains(text(), 'Publicar')]").Click(); return(comentario); }
private void Search(int row) { string valueToSearch = handle.GetNext(row, col); if (valueToSearch != null) { string textboxName = "ctl00$ctl00$ctl00$BodyContent$ContentPlaceHolder1$MainContentPlaceHolder$ResourceHostControl1$resContainer$rptContainers$ctl00$rptColumn1$ctl00$ctl01$Wrapper$txtSearchString"; string attributeDropdown = "ctl00$ctl00$ctl00$BodyContent$ContentPlaceHolder1$MainContentPlaceHolder$ResourceHostControl1$resContainer$rptContainers$ctl00$rptColumn1$ctl00$ctl01$Wrapper$lbxNodeProperty"; string searchBtnId = "ctl00_ctl00_ctl00_BodyContent_ContentPlaceHolder1_MainContentPlaceHolder_ResourceHostControl1_resContainer_rptContainers_ctl00_rptColumn1_ctl00_ctl01_Wrapper_btnSearch"; chrome.Navigate().GoToUrl("https://solarwindscs.dell.com/Orion/SummaryView.aspx?ViewID=1"); while (IsElementPresent(textboxName, false, true) == false) { Thread.Sleep(25); } try { OpenQA.Selenium.IWebElement searchBox = chrome.FindElementByName(textboxName); OpenQA.Selenium.IWebElement dropBox = chrome.FindElementByName(attributeDropdown); OpenQA.Selenium.IWebElement searchBtn = chrome.FindElementById(searchBtnId); OpenQA.Selenium.Support.UI.SelectElement select = new OpenQA.Selenium.Support.UI.SelectElement(dropBox); //Console.WriteLine("HHHHHHH"); searchBox.SendKeys(valueToSearch); //Console.WriteLine("HHHHHHH"); select.SelectByIndex(attributeIndex); // Console.WriteLine("uyguygufuov"); searchBtn.Click(); // Console.WriteLine("HHHHHHH"); while (IsElementPresent("StatusMessage", true, false) == false) { Thread.Sleep(25); } string result = chrome.FindElementByClassName("StatusMessage").Text; if (result.Contains("Nodes with ") && result.Contains(" similar to ")) { ReadOnlyCollection <OpenQA.Selenium.IWebElement> amount = chrome.FindElementsByClassName("StatusIcon"); //Console.WriteLine(amount.Count); handle.AddResult(row, valueToSearch, "Y", (amount.Count - 1).ToString()); } else { handle.AddResult(row, valueToSearch, "N", "0"); } } catch (Exception e) { throw new WebSearchException(Thread.CurrentThread.ManagedThreadId.ToString()); } } }
static void getCountries() { var c = d.FindElementByClassName("countryOption"); string s = ""; foreach (var l in c.FindElements(By.TagName("li"))) { string country = l.FindElement(By.ClassName("countryName")).Text.Trim(); country += ":" + l.FindElement(By.TagName("input")).GetAttribute("value"); s += country + "\n"; } }
public void NavigateToPage() { var username = user; var password = pass; _chrome.Navigate().GoToUrl("http://localhost:5000/Authentication/Login"); _chrome.FindElementById("Username").SendKeys(username); _chrome.FindElementById("Password").SendKeys(password); _chrome.FindElementById("Login").Click(); Assert.Contains(username.ToLower(), _chrome.FindElementById("DashboardMsg").Text.ToLower()); _chrome.FindElementByLinkText("Register Demographics").Click(); Assert.Contains("Voter Demographics", _chrome.FindElementByClassName("form-signin-heading").Text); _chrome.Close(); }
public void VerifyVotersErrorTest(string id) { var username = "******"; var password = "******"; _chrome.Navigate().GoToUrl("http://localhost:5000/Authentication/Login"); _chrome.FindElementById("Username").SendKeys(username); _chrome.FindElementById("Password").SendKeys(password); _chrome.FindElementById("Login").Click(); Assert.Contains(username, _chrome.FindElementById("DashboardMsg").Text); _chrome.FindElementByLinkText("Verify Voters").Click(); _chrome.FindElementByClassName("btn").Click(); Assert.Contains("required", _chrome.FindElementById(id).Text); _chrome.Close(); }
public void VerifyNavigatorEditorUpdates() { ChromeDriver driver = GetDriverConnection(); string url = driver.Url; ChromeDriver navigator = GetNavigatorConnection(url); IWebElement driverEditor = driver.FindElementById("code-editor"); string expected = "Make_sure_that_the_text_appears_on_the_navigator's_screen"; Actions actions = new Actions(driver); actions.MoveToElement(driverEditor); actions.Click(); actions.SendKeys(expected); actions.Build().Perform(); //Wait 5 seconds before reading the text Task.Delay(5000).Wait(); IWebElement line = navigator.FindElementByClassName("ace_line"); Assert.Equal(expected, line.Text); driver.Quit(); navigator.Quit(); }
public void VerifyNavigatorUnableToWrite() { ChromeDriver driver = GetDriverConnection(); string url = driver.Url; ChromeDriver navigator = GetNavigatorConnection(url); IWebElement navigatorEditor = navigator.FindElementById("code-editor"); string text = "Test_to_see_if_the_navigator_can_write"; Actions actions = new Actions(navigator); actions.MoveToElement(navigatorEditor); actions.Click(); actions.SendKeys(text); actions.Build().Perform(); Task.Delay(5000).Wait(); IWebElement line = driver.FindElementByClassName("ace_line"); Assert.Equal("", line.Text); driver.Quit(); navigator.Quit(); }
public void VerifyStringHighlight() { ChromeDriver driver = GetDriverConnection(); string url = driver.Url; ChromeDriver navigator = GetNavigatorConnection(url); IWebElement driverEditor = driver.FindElementById("code-editor"); Actions actions = new Actions(driver); actions.MoveToElement(driverEditor); actions.Click(); actions.SendKeys("\"hello\""); actions.Build().Perform(); Task.Delay(5000).Wait(); IWebElement driverWord = driver.FindElementByClassName("ace_string"); IWebElement navigatorWord = navigator.FindElementByClassName("ace_string"); //Wait 5 seconds before trying to see if the line was highlighted Task.Delay(5000).Wait(); Assert.Equal("rgba(223, 0, 2, 1)", driverWord.GetCssValue("color")); Assert.Equal("rgba(223, 0, 2, 1)", navigatorWord.GetCssValue("color")); driver.Quit(); navigator.Quit(); }
public void VerifyNavigatorCanHighlight() { ChromeDriver driver = GetDriverConnection(); string url = driver.Url; ChromeDriver navigator = GetNavigatorConnection(url); IWebElement driverEditor = driver.FindElementById("code-editor"); Actions actions = new Actions(driver); actions.MoveToElement(driverEditor); actions.Click(); actions.SendKeys("test"); actions.Build().Perform(); Task.Delay(5000).Wait(); IWebElement line = navigator.FindElementByClassName("ace_gutter-cell"); line.Click(); //Wait 5 seconds before trying to see if the line was highlighted Task.Delay(5000).Wait(); IWebElement selectedElement = driver.FindElementByClassName("yellow-marker"); Assert.Equal("rgba(255, 255, 0, 1)", selectedElement.GetCssValue("background-color")); driver.Quit(); navigator.Quit(); }
public void JupiterToysSearch() { using (var driver = new ChromeDriver(@".\")) { driver.Manage().Timeouts().ImplicitWait = (TimeSpan.FromSeconds(10)); driver.Navigate().GoToUrl("http://jupiter.cloud.planittesting.com/"); driver.Manage().Window.Maximize(); HomePage homePage = new HomePage(driver); // TODO: Verify we are actually on the Jupiter Toys home page Assert.Equal("Jupiter Toys", (driver.FindElementByClassName("brand").Text)); ContactPage contactPage = homePage.clickContact(); // TODO: Check that the status msg is what we expect: "We welcome your feedback - tell it how it is." Assert.Equal("We welcome your feedback - tell it how it is.", contactPage.getMsgBeforeFeedback()); contactPage.EnterForename("kapil"); contactPage.EnterSurname("Batra"); contactPage.EnterEmail("*****@*****.**"); contactPage.EnterTelephone("045363738"); contactPage.EnterMessage("test message"); contactPage.clickSubmit(); // TODO: Check that the status message is "Thanks kapil, we appreciate your feedback" Assert.Equal("Thanks kapil, we appreciate your feedback.", contactPage.getMsgAfterFeedback()); //Assert.Equal(,""); //driver.FindElementByCssSelector("li#nav-login").Click; // driver.FindElementByCssSelector("div.hero-unit h1"); driver.Quit(); } }