static void Main(string[] args) { var driver = new FirefoxDriver() { Url = "http://google.pl" //"http://localhost/selenium/index.php" }; //Zadanie 1 //var element = driver.FindElementByName("imie"); //element.SendKeys("Jan"); //var element3 = driver.FindElementByName("nazwisko"); //element3.SendKeys("Kowalski"); //var element2 = driver.FindElementByName("submit"); //element2.Click(); //Thread.Sleep(5000); //driver.Close(); var element = driver.FindElementByCssSelector("#lst-ib"); element.SendKeys("jak zbudować helikopter \n"); Thread.Sleep(3000); var lista = driver.FindElementsByCssSelector("div > h3 > a"); Console.WriteLine("Znaleziono: " + lista.Count); foreach (var zmienna in lista) { Console.WriteLine(zmienna.GetAttribute("innerText") + " "); Console.WriteLine(zmienna.GetAttribute("href") + " "); } for (int n = 3; n < 5; n++) { var element2 = driver.FindElementByCssSelector($"#nav > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child({n}) > a:nth-child(1)"); lista = driver.FindElementsByCssSelector("div > h3 > a"); Console.WriteLine("Znaleziono: " + lista.Count); foreach (var zmienna in lista) { Console.WriteLine(zmienna.GetAttribute("innerText") + " "); Console.WriteLine(zmienna.GetAttribute("href") + " "); } var element3 = driver.FindElementByCssSelector("#pnnext > span:nth-child(2)"); element3.Click(); Thread.Sleep(3000); } }
public void TestRegEmail() { firefox.Navigate().GoToUrl("https://yandex.ru/"); firefox.FindElement(By.ClassName("desk-notif-card__login-mail-promo")).Click(); firefox.FindElement(By.Id("firstname")).SendKeys("Иванов"); firefox.FindElement(By.Id("lastname")).SendKeys("Иванов"); firefox.FindElement(By.Id("login")).SendKeys("Ivanoinavon"); firefox.FindElement(By.Id("password")).SendKeys("Ivanoinavon"); firefox.FindElement(By.Id("password_confirm")).SendKeys("Ivanoinavon"); firefox.FindElement(By.XPath("//form/div[4]/button")).Click(); System.Threading.Thread.Sleep(3500); String actualt = firefox.FindElementByCssSelector("html.is-js_yes.is-inlinesvg_yes body.pointerfocus div#root.layout div.layout-inner div.grid div.main-container main.registration__wrapper.registration__wrapper_desktop div.registration__block div div form.registration__form.registration__form_desktop div div.form__field.field__password.form__field_filled.field__error div.reg-field__popup div.form__popup-error div.error-message").Text; Assert.AreEqual("Пароль не может совпадать с логином", actualt); }