Пример #1
0
        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);
        }
Пример #2
0
        public static void MarcarPonto(string login, string senha)
        {
            var logger = new Logger(login);

            try
            {
                var appPath    = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
                var driverpath = Path.GetDirectoryName(appPath).Remove(0, 6);

                var options = new ChromeOptions();
                options.AddArguments(new string[] { "--headless", "--disable-gpu", "--remote-debugging-port=9222" });

                ChromeDriver driver = new ChromeDriver(driverpath, options);

                try
                {
                    var limiteTentativas = 30;
                    var i = 0;
                    do
                    {
                        i++;
                        driver.Url = @"http://forponto.quality.com.br/forponto/FptoWeb.exe/PiEntraMarcacao";
                        System.Threading.Thread.Sleep(1000);
                        driver.Navigate().Refresh();
                        driver.FindElementByName("deEdtUsuCodigoAD").SendKeys(login);
                        driver.FindElementByName("deEdtUsaSenhaAD").SendKeys(senha);
                        driver.FindElementByName("ok").Click();
                    } while (!driver.Title.Contains("Marcação Aceita") && i < limiteTentativas);

                    if (driver.Title.Contains("Aviso"))
                    {
                        logger.Log(driver.FindElementByClassName("fonteavisos").Text);
                    }
                    else
                    {
                        logger.Log("Marcação Aceita");
                    }
                }
                catch (Exception e)
                {
                    while (e.InnerException != null)
                    {
                        e = e.InnerException;
                    }
                    logger.Log(e.Message.Replace(Environment.NewLine, " "));
                }
                finally
                {
                    driver.Quit();
                }
            }
            catch (Exception e)
            {
                while (e.InnerException != null)
                {
                    e = e.InnerException;
                }
                logger.Log(e.Message.Replace(Environment.NewLine, " "));
            }
        }
Пример #3
0
        public CommunicationsResponse RetrieveSelectedBankAccountDetails(BankCommsCapsule capsule)
        {
            string address = "https://online.mbank.pl/pl/Login";
            CommunicationsResponse response = new CommunicationsResponse();

            ChromeDriver driver = new ChromeDriver();

            driver.Navigate().GoToUrl(address);

//            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            Thread.Sleep(3000);

            IWebElement login    = driver.FindElementByName("userID");
            IWebElement password = driver.FindElementByName("pass");

            login.SendKeys(capsule._login);
            password.SendKeys(capsule._password);

            password.Submit();


            driver.Navigate().GoToUrl("https://online.mbank.pl/pl#/accounts");
            Thread.Sleep(3000);
            // IWebElement account = driver.FindElementByName

            driver.Quit();
            return(response);
        }
Пример #4
0
 public void TestMethod1()
 {
     using (var driver = new ChromeDriver())
     {
         // driver.Manage().Window.Maximize();
         driver.Navigate().GoToUrl("https://capstproj2021.azurewebsites.net");
         new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(
             d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete")
             );
         var loginbtn = driver.FindElementByXPath("//a[@href='/Identity/Account/Login']");
         Assert.IsNotNull(loginbtn);//   Console.Read();
         loginbtn.Click();
         new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(
             d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete")
             );
         var Email = driver.FindElementByName("Input.Email");
         Assert.IsNotNull(Email);
         Email.SendKeys("*****@*****.**");
         var passw = driver.FindElementByName("Input.Password");
         Assert.IsNotNull(passw);
         passw.SendKeys("*****@*****.**");
         var rbtn = driver.FindElementByXPath("//button[contains(text(), 'Log in')]");
         Assert.IsNotNull(rbtn);
         rbtn.Click();
         new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(
             d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete")
             );
         var pagetitle = driver.PageSource.Contains("Hello");
         Assert.IsTrue(pagetitle);
         var pagetitle2 = driver.PageSource.Contains("My Orders");
         Assert.IsTrue(pagetitle2);
         //Enter diff email id for everytime while testing
     }
 }
Пример #5
0
        public void ProductCreate()

        {
            WebDriverWait wait  = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            string        spath = "../../../../selenium-test-project/png.JPG";
            string        localpath;

            localpath = Path.GetFullPath(spath);

            //Заходим и логинимся
            driver.Url = "http://localhost/litecart/admin";
            driver.FindElement(By.Name("username")).SendKeys("admin");
            driver.FindElement(By.Name("password")).SendKeys("admin");
            driver.FindElement(By.Name("login")).Click();

            //Переходим в меню создания товаров
            driver.FindElement(By.XPath("//*[@id='box-apps-menu']/li[2]")).Click();
            driver.FindElement(By.XPath("//*[@href='http://localhost/litecart/admin/?category_id=0&app=catalog&doc=edit_product']")).Click();
            driver.FindElement(By.CssSelector("#tab-general input[value='1'][type = 'radio']")).Click();

            //Заполняем все поля, сохраняем и проверяем,что в списке есть товар с таким же названием
            driver.FindElement(By.Name("name[en]")).SendKeys("graphics card");
            driver.FindElement(By.Name("code")).SendKeys("789654");
            driver.FindElement(By.CssSelector("#tab-general input[type='checkbox'][data-name='Rubber Ducks'] ")).Click();
            driver.FindElement(By.XPath("//*[@id='tab-general']//tr[7]//tr[2]/td[1]")).Click();
            driver.FindElement(By.XPath("//*[@name='quantity']")).Clear();
            driver.FindElement(By.XPath("//*[@name='quantity']")).SendKeys("45");
            driver.FindElementByName("new_images[]").SendKeys(localpath);
            driver.FindElement(By.XPath("//*[@name='date_valid_from']")).SendKeys("13.05.2018");
            driver.FindElement(By.XPath("//*[@name='date_valid_to']")).SendKeys("15.05.2018");
            driver.FindElementByName("save").Click();
            driver.FindElement(By.XPath("//*[@id='content']//a[contains(text(), 'graphics card')]"));
        }
Пример #6
0
        public void CrearPreguntasTemaIsOkTest()
        {
            ChromeDriver navegador = new ChromeDriver();

            navegador.Url = Ruta;
            navegador.FindElementByName("Username");
            navegador.FindElementByName("Password");
            navegador.FindElementById("BotonLogin").Click();
            navegador.FindElementById("temaLink").Click();
            //
            navegador.FindElementById("preguntas+1").Click();
            navegador.FindElementById("crearPreg").Click();


            navegador.FindElementByName("Descripcion").SendKeys("Pregunta");
            navegador.FindElementById("btnAddAlternativa").Click();
            navegador.FindElementById("0descripcion").SendKeys("Pregunta");
            navegador.FindElementById("0check").Click();

            navegador.FindElementById("guardar").Click();
            var page = navegador.FindElementById("preguntas");

            Assert.IsNotNull(page);
            navegador.Close();
        }
 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);
     }
 }
Пример #8
0
        /// <summary>
        /// Auto Login to HTO
        /// </summary>
        /// <param name="userEmail">User account</param>
        /// <param name="password">Account Password</param>
        /// <param name="loginURL">HTO Login page</param>
        public static void Login(string userEmail, string password, string loginURL)
        {
            // used for sending clicks and and characters
            Actions actions = new Actions(driver);


            // set driver timeout and launch browser
            Console.WriteLine("Goto " + loginURL);
            driver.Manage().Timeouts().ImplicitWait = new TimeSpan(0, 0, 12);
            driver.Navigate().GoToUrl(loginURL);

            IWebElement body = driver.FindElement(By.TagName("body"));

            body.SendKeys(OpenQA.Selenium.Keys.Control + 'T');

            // Get the elements of the login elements from HTML

            OpenQA.Selenium.IWebElement LoginBox      = driver.FindElementByName("loginemailaddress");
            OpenQA.Selenium.IWebElement LoginPassword = driver.FindElementByName("loginpassword");
            OpenQA.Selenium.IWebElement LoginButton   = driver.FindElementByName(HTOMenuButtons.Login);


            //Execute auto login
            {
                Console.WriteLine("logging onto HTO as " + userEmail);
                actions.SendKeys(LoginBox, userEmail);
                actions.SendKeys(LoginPassword, password);
                actions.Click(LoginButton);
                actions.Perform();
            }
        }
Пример #9
0
 private static ChromeDriver FillOutForm(ChromeDriver driver)
 {
     WaitForPageLoad(driver);
     driver.FindElementByName("fullName").SendKeys("Test - Tom Dane");
     driver.FindElementByName("email").SendKeys("*****@*****.**");
     driver.FindElementByName("interest").SendKeys("Testing");
     driver.FindElementByClassName("Button").Click();
     return(driver);
 }
Пример #10
0
        public YourPokerRoomsPage_VotingProcess EnterTheName(string name)
        {
            driver.FindElementByName("inputName").SendKeys(name);
            IWebElement element = driver.FindElementByXPath("//button[text()='Enter']");

            element.Click();

            return(new YourPokerRoomsPage_VotingProcess(driver));
        }
        public void TestGoogleSearch_MSFT_ValidNASDAQCode()
        {
            driver.Navigate().GoToUrl("https://www.google.com/");

            driver.FindElementByName("q").SendKeys("MSFT");
            driver.FindElementByName("btnK").Submit();

            Assert.IsTrue(driver.FindElementById("knowledge-finance-wholepage__entity-summary").Text.Contains("NASDAQ: MSFT"));
        }
Пример #12
0
 public void Login()
 {
     browser.Navigate().GoToUrl(URL + "accounts/login/");
     delay(1);
     browser.FindElementByName("username").SendKeys(UserName);
     browser.FindElementByName("password").SendKeys(Password);
     browser.FindElementByTagName("button").Click();
     delay(2);
 }
Пример #13
0
        /// <summary>
        /// Browser test recaptcha normal
        /// </summary>
        private static void browser_test_normal()
        {
            Console.WriteLine("[=] BROWSER TEST STARTED (NORMAL CAPTCHA) [=]");
            var s = ChromeDriverService.CreateDefaultService();

            s.HideCommandPromptWindow = true;
            ChromeDriver d = new ChromeDriver(s);

            try
            {
                d.Navigate().GoToUrl(TEST_PAGE_NORMAL);               // 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");
                Console.WriteLine(string.Format("[+] Site key: {0}", site_key));

                // 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);
                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
                d.FindElementByTagName("form").Submit();
                Console.WriteLine("[+] Form submitted");
            }
            finally
            {
                Thread.Sleep(5000);
                d.Quit();       // quit browser
                Console.WriteLine("[=] BROWSER TEST FINISHED [=]");
            }
        }
        public CreateStoriesAndVotingProcess VotingProcess(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.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("2");
            IWebElement clickOnFinish = driver.FindElementByXPath("//*[@ng-bs-click='finish']");

            clickOnFinish.Click();

            return(new CreateStoriesAndVotingProcess(driver));
        }
Пример #15
0
        public void GivenEnterTheOrder(string name, string meal, int price)
        {
            _name = name;
            _driver.FindElementByName("name").SendKeys(name);

            _meal = meal;
            _driver.FindElementByName("meal").SendKeys(meal);

            _price = price;
            _driver.FindElementByName("price").SendKeys(price.ToString());
        }
Пример #16
0
        private void Login(string user, string pass)
        {
            Wait(".form");

            Driver.FindElementByName("username").SendKeys(user);
            Driver.FindElementByName("password").SendKeys(pass);

            Driver.FindElementByTagName("button").Click();

            Wait("section");
        }
Пример #17
0
        public static void Login(ParimatchCredentials creds)
        {
            OpenRefresh("https://www.parimatch.com/?login=1");
            var n = driver.FindElementByName("username");

            n.SendKeys(creds.User);
            var p = driver.FindElementByName("passwd");

            p.SendKeys(creds.Pasw);
            driver.FindElementByCssSelector("button.ok").Click();
        }
Пример #18
0
        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());
                }
            }
        }
Пример #19
0
        public void HomeIndexTest()
        {
            ChromeDriver navegador = new ChromeDriver();

            navegador.Url = Ruta;
            navegador.FindElementByName("Username");
            navegador.FindElementByName("Password");
            navegador.FindElementById("BotonLogin").Click();
            var page = navegador.FindElementByName("homeIndex");

            Assert.IsNotNull(page);
            navegador.Close();
        }
Пример #20
0
        public void ViewLibrosIsOk()
        {
            ChromeDriver navegador = new ChromeDriver();

            navegador.Url = Ruta;
            navegador.FindElementByName("Username").SendKeys("admin");
            navegador.FindElementByName("Password").SendKeys("admin");
            navegador.FindElementById("BotonLogin").Click();
            navegador.FindElementById("2").Click();
            var page = navegador.FindElementById("DetalleLibro");

            Assert.IsNotNull(page);
            navegador.Close();
        }
Пример #21
0
        public void GivenFillUpTheFormUsingTheDataWith(string name, string lastname, string email, string password, string confirmPassword)
        {
            var nameField            = chromeDriver.FindElementByCssSelector("#Input_FirstName");
            var lastnameField        = chromeDriver.FindElementByCssSelector("#Input_LastName");
            var emailFiled           = chromeDriver.FindElementByXPath("//*[@id=\"Input_Email\"]");
            var passwordField        = chromeDriver.FindElementByName("Input.Password");
            var confirmPasswordFiled = chromeDriver.FindElementByName("Input.ConfirmPassword");

            nameField.SendKeys(name);
            lastnameField.SendKeys(lastname);
            emailFiled.SendKeys(email);
            passwordField.SendKeys(password);
            confirmPasswordFiled.SendKeys(confirmPassword);
        }
Пример #22
0
        public void ButtonTomarExamenTest()
        {
            ChromeDriver navegador = new ChromeDriver();

            navegador.Url = Ruta;
            navegador.FindElementByName("Username");
            navegador.FindElementByName("Password");
            navegador.FindElementById("BotonLogin").Click();
            navegador.FindElementById("BotonTomarExamen").Click();
            var page = navegador.FindElementById("Confirmar");

            Assert.IsNotNull(page);
            navegador.Close();
        }
        /// <summary>
        /// This method assumes user is in the add student page
        /// Subsequently, it will both enter and submit the student information as provided
        /// </summary>
        private void SubmitStudentData(String firstName, String lastName, String enrollmentDate)
        {
            // First Name input
            _driver.FindElementByName("ctl00$MainContent$StudentsDetailsView$ctl01").SendKeys(firstName);

            // Last Name input
            _driver.FindElementByName("ctl00$MainContent$StudentsDetailsView$ctl02").SendKeys(lastName);

            // Enrollment Date input
            _driver.FindElementByName("ctl00$MainContent$StudentsDetailsView$ctl03").SendKeys(enrollmentDate);

            // Click "insert" link
            _driver.FindElementByLinkText("Insert").Click();
        }
Пример #24
0
        public void AgregarABibliotecaIsOk()
        {
            ChromeDriver navegador = new ChromeDriver();

            navegador.Url = Ruta;
            navegador.FindElementByName("Username").SendKeys("admin");
            navegador.FindElementByName("Password").SendKeys("admin");
            navegador.FindElementById("BotonLogin").Click();
            navegador.FindElementByName("2").Click();
            var page = navegador.FindElementById("HomeIndex");

            Assert.IsNotNull(page);
            navegador.Close();
        }
Пример #25
0
        static void Main(string[] args)
        {
            // Initialize the Chrome Driver
            using (var driver = new ChromeDriver())
            {
                // Go to the home page
                driver.Navigate().GoToUrl("http://testapp.galenframework.com/");

                // Get User Name field, Password field and Login Button
                var loginButton = driver.FindElementByXPath("//button[text()='Login']");
                // and click the login button to enter username and password
                loginButton.Click();

                var userNameField     = driver.FindElementByName("login.username");
                var userPasswordField = driver.FindElementByName("login.password");


                // Type user name and password
                userNameField.SendKeys("*****@*****.**");
                userPasswordField.SendKeys("test123");

                // Login to system to create NOTE
                var loginToSytem = driver.FindElementByXPath("//button[text()='Login']");
                loginToSytem.Click();

                // Click Login button to open Add Note page
                var loginToAddNote = driver.FindElementByXPath("//button[text()='Add note']");
                loginToAddNote.Click();


                // Type Title and Description
                var titleField       = driver.FindElementByName("note.title");
                var descriptionField = driver.FindElementByName("note.description");

                titleField.SendKeys("Title Note to Test");
                descriptionField.SendKeys("Title Description");

                // Add Note
                var addNote = driver.FindElementByXPath("//button[text()='Add Note']");
                addNote.Click();


                // Extract resulting message 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", ImageFormat.Png);
            }
        }
Пример #26
0
        public void signup(string URI, string firstName, string lastName, string email)
        {
            // Initialize the Chrome Driver
            using (var driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)))
            //using (var driver = new ChromeDriver(""))
            {
                // Go to the specific signup page
                driver.Navigate().GoToUrl(URI);

                // Get the page elements
                var userNameField     = driver.FindElementByName("name");
                var userPasswordField = driver.FindElementByName("email");
                var loginButton       = driver.FindElementByXPath("//button[@type='submit'][text()='Make Reservation']");

                // Type user name and password
                userNameField.SendKeys(firstName + " " + lastName);
                userPasswordField.SendKeys(email);

                //check the time and wait until 07:00:00:01
                //Helper h = new Helper();
                //h.GetTime();

                // Click the login button
                loginButton.Click();
                //System.Threading.Thread.Sleep(250);

                // Grab all the text within the body tag and re-try the login
                int x = 1;
                while (driver.FindElementByTagName("body").Text.Contains("Reservations may not be made until 24 hours prior to the start time of the class.") & (x <= 15000))
                {
                    //It's too early to signup, so go back to form and try again
                    driver.Navigate().Back();
                    //System.Threading.Thread.Sleep(250);
                    x++;
                    //form will be populated w the previous name and email values...re-submit
                    driver.FindElementByXPath("//button[@type='submit'][text()='Make Reservation']").Click();
                }


                // 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(firstName + ".png", OpenQA.Selenium.ScreenshotImageFormat.Png);
                //driver.GetScreenshot().SaveAsFile(@"D:\repo\dotnetCoreHockeySignUp\HockeySignUpCore\bin\Debug\netcoreapp2.1\SPF.png", OpenQA.Selenium.ScreenshotImageFormat.Png);
                driver.Close();
            }
        }
Пример #27
0
        public void ButtonCrearTemaTest()
        {
            ChromeDriver navegador = new ChromeDriver();

            navegador.Url = Ruta;
            navegador.FindElementByName("Username");
            navegador.FindElementByName("Password");
            navegador.FindElementById("BotonLogin").Click();
            navegador.FindElementById("temaLink").Click();
            navegador.FindElementById("creartemaLink").Click();
            var page = navegador.FindElementById("crearTema");

            Assert.IsNotNull(page);
            navegador.Close();
        }
Пример #28
0
        public void Shoud_Search_Using_Chrome()
        {
            // Initialize the Chrome Driver
            using (var driver = new ChromeDriver())
            {
                // 1. Maximize the browser
                driver.Manage().Window.Maximize();

                // 2. Go to the "Google" homepage
                driver.Navigate().GoToUrl("http: //www.google.com");

                // 3. Find the search textbox (by ID) on the homepage

                var searchBox = driver.FindElementById("lst - ib");
                // 4. Enter the text (to search for) in the textbox
                searchBox.SendKeys("Automation using selenium 3.0 in C#");

                // 5. Find the search button (by Name) on the homepage
                var searchButton = driver.FindElementByName("btnK");

                // 6. Click "Submit" to start the search
                searchButton.Submit();

                // 7. Find the "Id" of the "Div" containing results stats
                var searchResults = driver.FindElementById("resultStats");
            }
        }
        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"));
        }
Пример #30
0
        public void Criticar_Prazo_Financiamento_Maior_Que_30_Anos()
        {
            var txtPrazoEmAnos = driver.FindElementByName("years");

            txtPrazoEmAnos.SendKeys("31");

            var btn = driver.FindElementById("simular-financiamento");

            btn.Click();

            Thread.Sleep(2_000);

            var textoCritica = driver.FindElements(By.XPath("//*[@id=\"email-form\"]/div[2]/div[2]/div[1]/div[3]"));
            var nomeTest     = $@"C:\temp\teste-selenium\{DateTime.Now.ToString("mm")}{nameof(Criticar_Prazo_Financiamento_Maior_Que_30_Anos)}.png";


            if (textoCritica == null)
            {
                SalvarEvidencia(nomeTest);
                Assert.Fail();
            }


            if (textoCritica.Any(x => x.Text == "O prazo máximo de financiamento é 30 anos."))
            {
                SalvarEvidencia(nomeTest);
                Assert.Pass();
            }
            else
            {
                SalvarEvidencia(nomeTest);
                Assert.Fail();
            }
        }