public void InjectionAttackMethod()
        {
            ChromeDriver chrome = new ChromeDriver();

            // Test attack on the Safe page, attack should fail
            chrome.Navigate().GoToUrl("http://localhost/Security/SafeWebForm.aspx");

            chrome.FindElement(By.XPath("//input[@type = 'text'][@name = 'nameBox']")).SendKeys("Bob', 2); update students set Name='All your base are belong to us';--");
            chrome.FindElement(By.XPath("//input[@type = 'text'][@name = 'gpaBox']")).SendKeys("2");
            chrome.FindElement(By.XPath("//input[@type = 'submit'][@name = 'submit']")).Click();

            chrome.Navigate().GoToUrl("http://localhost/Security/SafeRead.aspx");

            foreach (IWebElement iwe in chrome.FindElementsByName("nameBox"))
            {
                Assert.AreEqual("All your base are belong to us", iwe.Text, "Injection attack parameter has been found: prepared statements have failed, this page is not safe vs Injection attacks.");
            }

            // Test attack on the Unsafe page, attack should pass
            chrome.Navigate().GoToUrl("http://localhost/Security/UnsafeWebForm.aspx");

            chrome.FindElement(By.XPath("//input[@type = 'text'][@name = 'nameBox']")).SendKeys("Bob', 2); update students set Name='All your base are belong to us';--");
            chrome.FindElement(By.XPath("//input[@type = 'text'][@name = 'gpaBox']")).SendKeys("2");
            chrome.FindElement(By.XPath("//input[@type = 'submit'][@name = 'submit']")).Click();

            chrome.Navigate().GoToUrl("http://localhost/Security/SafeRead.aspx");

            foreach (IWebElement iwe in chrome.FindElementsByName("nameBox"))
            {
                Assert.AreNotEqual("All your base are belong to us", iwe.Text, "Injection attack parameter has not been found: this page is safe vs Injection attacks and should not be.");
            }
        }
Example #2
0
        public void OpenBrowser()
        {
            var driver = new ChromeDriver();

            driver.Navigate().GoToUrl("https://app.pluralsight.com/id?redirectTo=/");

            var element = driver.FindElementsByName("Username").Single();

            element.SendKeys("suneelkumarv");

            element = driver.FindElementsByName("Password").Single();
            element.SendKeys("password1!");

            element.Submit();

            driver.Close();
        }
Example #3
0
        static void Auth(ChromeDriver chromeDriver, string value1, string value2)
        {
            List <IWebElement> webElements = (from item in chromeDriver.FindElementsByName(value1) where item.Displayed select item).ToList();

            if (!webElements.Any())
            {
                return;
            }
            webElements[0].SendKeys(value2);
        }
Example #4
0
        public void WhenIClickOnTheSortByDropdown(string p0)
        {
            var elements = driver.FindElementsByName("sortOptions");

            Assert.IsTrue(elements.Count == 1, "Expected to find 1 sortOptions element but found " + elements.Count);

            var sortDropdownSelection = new SelectElement(elements[0]);

            sortDropdownSelection.SelectByText(p0);
            sortOrderSelected = p0;
        }
Example #5
0
        /// <summary>
        /// Navigates browser to Radio search page. Verifies FOPS login via URL check.
        /// Attmepts login if not already there. Redirects back to Radio page if not logged in.
        /// </summary>
        /// <param name="browser"></param>
        /// <returns type='string'></returns>
        public string GetRadioIP(ChromeDriver browser, string customerNumber)
        {
            Console.WriteLine("Searching for Radio...");
            var    GetRadio   = new Radio();
            string Radio_Info = "";

            try
            {
                browser.Navigate().GoToUrl(FOPS_HomeUrl + FOPS_RadioUrl);
            }
            catch (TimeoutException e)
            {
                Console.WriteLine($"Timed out getting to SU Config...ref:\n{e.ToString()}");
                return(Radio_Info);
            }
            catch (Exception e)
            {
                return(Radio_Info = $"Some other error: {e.ToString()}");
            }
            if (browser.Url.ToString().Contains(FOPS_LoginUrl) == true)
            {
                FOPS_Login(browser, FOPS_HomeUrl + FOPS_RadioUrl);
            }
            try
            {
                var custNumber = browser.FindElementByName("customer_number");
                var RadioForm  = browser.FindElementsByName("B1");
                //var RadioForm = browser.FindElementByXPath(@"//*[@id='div_3_contents']/form");
                custNumber.SendKeys(customerNumber);
                RadioForm[2].Submit();

                Console.WriteLine(browser.Url);


                //Radio IP should always be first item in td for given table...will need to handle if multiple radios are presented.
                //again need to test via ping if radio is up or not.
                //need to determine radio type via webpage DOM
                var RadioTable = browser.FindElementByTagName("td");
                Console.WriteLine($"Found Radio IP: {RadioTable.Text}");
                //created to avoid stale refrence exception on later call.
                string radioIP = RadioTable.Text;
                //Uri RadioIP = RadioTable.Text;
                //logic to ping radio goes here.

                if (RadioTable.Text.Contains("Nothing"))
                {
                    return(Radio_Info += "No IP found for radio");
                }
                browser.Navigate().GoToUrl($"http://{RadioTable.Text}");
                Console.WriteLine(browser.Url);
                //go to ping/crawl radio.
                Radio_Info += PingTest.PingBuilder(browser, "radio", radioIP);


                return(Radio_Info);
            }
            catch (Exception e)
            {
                return(Radio_Info = $"error: {e.ToString()}");
            }
        }
Example #6
0
        public static void Main(string[] args)
        {
            var driver = new ChromeDriver();

            driver.Manage().Window.Maximize();
            driver.Navigate().GoToUrl("http://ru-stage-job.dodopizza.io/");

            IWebElement applicationForm = driver.FindElementByClassName("header-button");

            applicationForm.Click();

            IWebElement cities     = driver.FindElementByName("localityId");
            var         cityOption = new SelectElement(cities);

//            cityOption.SelectByText("Волгоград");
            cityOption.SelectByIndex(26);

            IWebElement surname = driver.FindElementByName("SecondName");

            surname.SendKeys("Уик");

            IWebElement firstName = driver.FindElementByName("FirstName");

            firstName.SendKeys("Джон");

            IWebElement birthdayDay     = driver.FindElementById("birthday_day");
            var         birthDayOptions = new SelectElement(birthdayDay);

            birthDayOptions.SelectByIndex(2);

            IWebElement birthdayMonth     = driver.FindElementById("birthday_month");
            var         birthMonthOptions = new SelectElement(birthdayMonth);

            birthMonthOptions.SelectByIndex(9);

            IWebElement birthdayYear     = driver.FindElementById("birthday_year");
            var         birthYearOptions = new SelectElement(birthdayYear);

            birthYearOptions.SelectByValue("1964");

            IWebElement address = driver.FindElementByName("Address");

            address.SendKeys("г. Нью-Йорк, 5-я авеню, д.123");

            IWebElement phone = driver.FindElementByName("PhoneNumber");

            phone.SendKeys("89085552332");

            var    selPizzeria = driver.FindElementsByName("UnitId");
            Random rand        = new Random();

            selPizzeria[rand.Next(0, selPizzeria.Count)].Click();

            Thread.Sleep(1000);

            var    selPositions = driver.FindElementsByCssSelector("#vacancies .col-sm-5 label");
            Random rand1        = new Random();

            selPositions[rand1.Next(0, selPositions.Count)].Click();

            var    worktime = driver.FindElementsByName("ShiftTypes");
            Random rand2    = new Random();

            worktime[rand2.Next(0, worktime.Count)].Click();

//            foreach (var time in worktime)
//            {
//               time.Click();
//            }

            IWebElement medbook = driver.FindElementById("med");

            medbook.Click();

            IWebElement knowledgeSources = driver.FindElementById("applicantSource");
            var         knowledgeSource1 = new SelectElement(knowledgeSources);

            knowledgeSource1.SelectByValue("SocialNetworks");

            /*
             * var knowledgeSource4 = new SelectElement(knowledgeSources);
             * knowledgeSource4.SelectByValue("Other");
             * Thread.Sleep(1500);
             *
             * IWebElement discription = driver.FindElementByName("ApplicantSourceDescription");
             * discription.SendKeys("От друзей");
             */

            IWebElement workPeriods = driver.FindElementByName("ExpectedWorkPeriod");
            var         workPeriod  = new SelectElement(workPeriods);

            workPeriod.SelectByValue("Always");

            IWebElement expirience = driver.FindElementByName("WorkExperience");

            expirience.SendKeys("Бывший наёмный убийца");

            IWebElement hobby = driver.FindElementByName("Hobby");

            hobby.SendKeys("У меня есть собака, я ее очень люблю. Меня радуют тишина и покой");

            IWebElement link = driver.FindElementByName("SocialLink");

            link.SendKeys("https://en.wikipedia.org/wiki/John_Wick");

            IWebElement oferta = driver.FindElementByName("Oferta");

            oferta.Click();

            IWebElement sendApplication = driver.FindElementById("send");

            sendApplication.Click();

            var searchText = "Спасибо!";
            var realText   = driver.FindElementByTagName("h1").Text;

            Assert.Equal(searchText, realText);

            //string searchText = "Ваша анкета уже летит управляющему";
            //  Assert.NotStrictEqual(searchText, realText);

            Thread.Sleep(2000);

            driver.Quit();

            Console.WriteLine("Success!");

            Console.ReadKey();
        }
Example #7
0
 public ReadOnlyCollection <IWebElement> ObterElementosPorName(string nameFind, string nameElementWait)
 {
     Wait.Until(ExpectedConditions.ElementIsVisible(By.Name(nameElementWait)));
     return(driver.FindElementsByName(nameFind));
 }
Example #8
0
        public static List <Materia> BuscarProvas(string usuario, string senha)
        {
            try
            {
                List <Materia> listaMaterias = new List <Materia>();
                List <string>  onClicks      = new List <string>();

                string driverPath           = Environment.CurrentDirectory + @"\..\..\..\packages\Selenium.WebDriver.ChromeDriver.2.42.0.1\driver\win32";
                ChromeDriverService service = ChromeDriverService.CreateDefaultService(driverPath);
                service.HideCommandPromptWindow = true;


                var options = new ChromeOptions();
                options.AddArgument("--window-position=-32000,-32000");



                using (var driver = new ChromeDriver(service, options))
                {
                    driver.Navigate().GoToUrl("https://www.furb.br/dion/aluno/diario.xhtml");

                    var inputUsuario = driver.FindElementsByName("j_username")[0];
                    var inputSenha   = driver.FindElementsByName("j_password")[0];

                    inputUsuario.SendKeys(usuario);
                    inputSenha.SendKeys(senha);
                    driver.FindElement(By.XPath("//button[text() = 'Confirmar']")).Click();

                    var divMaterias = driver.FindElementsByClassName("icon-book");
                    foreach (var materias in divMaterias)
                    {
                        var    pai         = materias.FindElement(By.XPath(".."));
                        string nomeMateria = pai.GetAttribute("innerText");
                        nomeMateria = nomeMateria.Split('-')[0].Trim();
                        Materia materia = new Materia();
                        materia.Nome = nomeMateria;
                        listaMaterias.Add(materia);
                        var onclick = pai.GetAttribute("onclick");
                        onClicks.Add(onclick);
                    }

                    for (int i = 0; i < onClicks.Count; i++)
                    {
                        ((IJavaScriptExecutor)driver).ExecuteScript(onClicks[i]);
                        var tabela = driver.FindElementById("formDiarioAluno:apDiarioAluno:j_idt49_data");
                        var linhas = tabela.FindElements(By.XPath(".//tr"));
                        foreach (var linha in linhas)
                        {
                            var td = linha.FindElements(By.XPath(".//td"));
                            if (td.Count >= 4)
                            {
                                Prova prova = new Prova();
                                //prova.Materia = listaMaterias[i];
                                //prova.Data = DateTime.Parse(td[0].GetAttribute("innerText"));
                                prova.Data       = td[0].GetAttribute("innerText").Trim();
                                prova.Descricao  = td[1].GetAttribute("innerText").Trim();
                                prova.Abreviacao = td[2].GetAttribute("innerText").Trim();
                                string stringNota = td[3].GetAttribute("innerText").Trim();
                                float  valorNota  = -1;
                                try
                                {
                                    valorNota = float.Parse(stringNota, CultureInfo.InvariantCulture);
                                }
                                catch (Exception) { }
                                if (valorNota != -1)
                                {
                                    prova.Valor = valorNota;
                                }
                                //notas.Add(nota);
                                listaMaterias[i].Prova.Add(prova);
                            }
                        }
                    }

                    return(listaMaterias);
                }
            }
            catch (Exception e)
            {
                return(null);
            }
        }