コード例 #1
0
        // Initialize the Chrome Driver
        public static List <MonsterClass> RunSearch(string jobName, string jobLocation)
        {
            // Check operating system
            string driverLocation = "";
            string osName         = System.Runtime.InteropServices.RuntimeInformation.OSDescription.ToLower();

            Console.WriteLine(osName);

            if (osName.Contains("windows"))
            {
                driverLocation = "..\\JobSearch\\wwwroot\\drivers-win";
            }
            else
            {
                driverLocation = "../JobSearch/wwwroot/drivers";
            }
            // Initialize the Chrome Driver

            ChromeDriver driver = new ChromeDriver(driverLocation);

            // Go to the home page
            driver.Navigate().GoToUrl("https://www.monster.com/");

            Thread.Sleep(2000);
            // Get the page elements
            var searchForm   = driver.FindElementById("q2");
            var locationForm = driver.FindElementById("where2");

            Thread.Sleep(250);
            // Type user name and password
            searchForm.SendKeys(jobName);
            locationForm.SendKeys("");
            for (int i = 0; i < 20; i++)
            {
                locationForm.SendKeys(Keys.Backspace);
            }
            Thread.Sleep(250);
            locationForm.SendKeys(jobLocation);

            Thread.Sleep(250);
            // and click the login button
            searchForm.Submit();

            List <MonsterClass> monsterJobs = new List <MonsterClass> {
            };
            IList <IWebElement> cards       = driver.FindElements(By.ClassName("card-content"));
            string tempTitle    = "";
            string tempLink     = "";
            string tempCompany  = "";
            string tempLocation = "No Location Specified";
            string tempDate     = "";

            Thread.Sleep(750);

            bool existsElement(int i)
            {
                try
                {
                    driver.FindElement(By.XPath("//*[@id='SearchResults']/section[" + i + "]/div/div[2]/div[1]/a"));
                }
                catch
                {
                    return(false);
                }
                return(true);
            }

            try
            {
                for (int i = 1; i < cards.Count - 1; i++)
                {
                    if (existsElement(i))
                    {
                        cards = driver.FindElements(By.ClassName("card-content"));
                        IWebElement single = driver.FindElement(By.XPath("//*[@id='SearchResults']/section[" + i + "]/div/div[2]/header/h2/a"));
                        tempTitle = single.Text;
                        tempLink  = single.GetAttribute("href");

                        IWebElement company = driver.FindElement(By.XPath("//*[@id='SearchResults']/section[" + i + "]/div/div[2]/div[1]/a"));
                        tempCompany = company.Text;

                        List <IWebElement> location = new List <IWebElement>();
                        location.AddRange(driver.FindElements(By.XPath("//*[@id='SearchResults']/section[" + i + "]/div/div[2]/div[2]/a")));


                        if (location.Count >= 1)
                        {
                            if (!string.IsNullOrEmpty(location[0].Text))
                            {
                                tempLocation = location[0].Text;
                            }
                            else if (string.IsNullOrEmpty(location[0].Text))
                            {
                                tempLocation = "Location not listed";
                            }
                        }
                        IWebElement date = driver.FindElement(By.XPath("//*[@id='SearchResults']/section[" + i + "]/div/div[3]/time"));
                        tempDate = date.Text;
                        MonsterClass tempjob = new MonsterClass(tempTitle, tempLink, tempCompany, tempLocation, tempDate);
                        monsterJobs.Add(tempjob);
                    }
                }
            }
            catch
            {
                for (int i = 1; i < cards.Count - 1; i++)
                {
                    if (existsElement(i))
                    {
                        cards = driver.FindElements(By.ClassName("card-content"));
                        IWebElement single = driver.FindElement(By.XPath("//*[@id='SearchResults']/section[" + i + "]/div/div[2]/header/h2/a"));
                        tempTitle = single.Text;
                        tempLink  = single.GetAttribute("href");

                        IWebElement company = driver.FindElement(By.XPath("//*[@id='SearchResults']/section[" + i + "]/div/div[2]/div[1]/a"));
                        tempCompany = company.Text;

                        List <IWebElement> location = new List <IWebElement>();
                        location.AddRange(driver.FindElements(By.XPath("//*[@id='SearchResults']/section[" + i + "]/div/div[2]/div[2]/a")));


                        if (location.Count >= 1)
                        {
                            if (!string.IsNullOrEmpty(location[0].Text))
                            {
                                tempLocation = location[0].Text;
                            }
                            else if (string.IsNullOrEmpty(location[0].Text))
                            {
                                tempLocation = "Location not listed";
                            }
                        }
                        IWebElement date = driver.FindElement(By.XPath("//*/section[" + i + "]/div/div[3]/time"));
                        tempDate = date.Text;
                        MonsterClass tempjob = new MonsterClass(tempTitle, tempLink, tempCompany, tempLocation, tempDate);
                        monsterJobs.Add(tempjob);
                    }
                }
            }
            driver.Close();
            return(monsterJobs);
        }
コード例 #2
0
        public void Testcase08()
        {
            Infor("1.Go to http://live.guru99.com/");
            Driver = new ChromeDriver(Directory.GetCurrentDirectory())
            {
                Url = TestCommonKeyWords["Guru.URL"]
            };
            Driver.Manage().Window.Maximize();
            Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2);
            Infor("2.Click on my account link");
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Acount"])).Click();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.MyAcount"])).Click();
            Thread.Sleep(3000);

            Infor("3.Login in application using previously created credential");
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.LoginEmail"])).SendKeys(TestCommonKeyWords["Guru.Xpath.LoginEmailData"]);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.LoginPass"])).SendKeys(TestCommonKeyWords["Guru.Xpath.LoginPassData"]);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.LoginSubmit"])).Click();
            Thread.Sleep(3000);

            Infor("4.Click on 'My Orders'");
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Acount"])).Click();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.MyAcount"])).Click();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.MyOrder"])).Click();
            Thread.Sleep(2000);

            Infor("5. Click on 'REORDER' link , change QTY & click Update");
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.Reorder"])).Click();
            Thread.Sleep(2000);
            string OldPrice = Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.OldPrice"])).Text;

            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.Quanlity"])).Clear();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.Quanlity"])).SendKeys(TestKeyWords["Guru.Xpath.QuanlityData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.Update"])).Click();
            string NewPrice = Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.OldPrice"])).Text;

            Infor("6. Verify Grand Total is changed");
            AssertNot(NewPrice.Trim(), OldPrice.Trim());

            Infor("7. Complete Billing & Shipping Information");
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.BtnCheckOut"])).Click();
            SelectElement BtnAdress = new SelectElement(Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.NewAddress"])));

            BtnAdress.SelectByIndex(0);
            if (BtnAdress.Options.Count == 1)
            {
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Company"])).Clear();
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Company"])).SendKeys(TestCommonKeyWords["Guru.Xpath.CompanyData"]);
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Address"])).Clear();
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Address"])).SendKeys(TestCommonKeyWords["Guru.Xpath.AddressData"]);
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.AddressStreet"])).Clear();
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.AddressStreet"])).SendKeys(TestCommonKeyWords["Guru.Xpath.AddressStreetData"]);
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.City"])).Clear();
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.City"])).SendKeys(TestCommonKeyWords["Guru.Xpath.CityData"]);
                Thread.Sleep(2000);
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.RegionBilling"])).Clear();
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.RegionBilling"])).SendKeys(TestKeyWords["Guru.Xpath.RegionBillingData"]);
                //new SelectElement(Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.RegionBilling"]))).SelectByText(TestKeyWords["Guru.Xpath.RegionBillingData"]);
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.PostCodeBilling"])).Clear();
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.PostCodeBilling"])).SendKeys(TestCommonKeyWords["Guru.Xpath.PostCodeBillingData"]);
                new SelectElement(Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.CountryBilling"]))).SelectByText(TestCommonKeyWords["Guru.Xpath.CountryBillingData"]);
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Telephone"])).Clear();
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Telephone"])).SendKeys(TestCommonKeyWords["Guru.Xpath.TelephoneData"]);
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Fax"])).Clear();
                Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Fax"])).SendKeys(TestCommonKeyWords["Guru.Xpath.FaxData"]);
            }
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.Checkbox2"])).Click();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.ContinueButton"])).Click();
            Thread.Sleep(3000);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.ShipButtonMethod"])).Click();
            Thread.Sleep(3000);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.ShipMethodCheckMo"])).Click();
            Thread.Sleep(3000);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.ShipButtonMethodPayment"])).Click();
            Thread.Sleep(3000);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.ShipPlaceOrder"])).Click();
            Thread.Sleep(3000);

            Infor("8. Verify order is generated and note the order number.");
            PassTest("Reorder rồi nhá");
            AddScreenCaptureFromPath();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            IWebDriver driver = new ChromeDriver();

            // NAVIGATING TO CRM-PRO WEBSITE
            driver.Navigate().GoToUrl("https://www.crmpro.com/");
            driver.Manage().Window.Maximize();
            driver.FindElement(By.XPath("//*[@name='username']")).SendKeys("hanee5432");
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
            driver.FindElement(By.XPath("//*[@type='password']")).SendKeys("hanee@12345");
            driver.FindElement(By.XPath("//*[@type='submit']")).Click();
            driver.SwitchTo().Frame("mainpanel");
            string Logoutaction = driver.FindElement(By.XPath("//*[@class='topnavlink' and contains(@href,'logout')]")).Text.Trim();

            Logoutaction.ShouldBe("Logout");
            Console.WriteLine("display the function:" + Logoutaction.Trim());
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
            driver.FindElement(By.XPath("(//div[@id='homebox_CALDAY']//table//td)[2]")).Click();

            // EDIT EVENT
            driver.FindElement(By.XPath("//*[@value='Edit']")).Click();
            driver.FindElement(By.XPath("//*[@name='title']")).SendKeys("R Haneesha");

            //DATE PICKER
            driver.FindElement(By.XPath("//*[@id='f_trigger_c_start']")).Click();

            IList <IWebElement> ele1 = driver.FindElements(By.XPath("//*[@class='headrow']/td"));

            for (int i = 0; i < ele1.Count; i++)
            {
                String aa = ele1[i].Text;

                if (aa.Equals("›"))
                {
                    for (int j = 0; j <= 3; j++)
                    {
                        ele1[i].Click();
                    }
                }
            }

            IList <IWebElement> ele = driver.FindElements(By.XPath("//*[@class='daysrow']/td"));

            for (int i = 0; i < ele.Count; i++)
            {
                String aa = ele[i].Text;

                if (aa.Equals("24"))
                {
                    ele[i].Click();
                    break;
                }
            }
            driver.FindElement(By.XPath("//*[@name='all_day_event']")).Click();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);

            //USING DROPDOWNS
            SelectElement       selectcategory = new SelectElement(driver.FindElement(By.Name("category")));
            IList <IWebElement> listcount      = selectcategory.Options;
            int categories = listcount.Count();

            Console.WriteLine("Display the count of categories:" + categories);
            listcount.ElementAt(2).Click();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
            driver.FindElement(By.XPath("//*[@value ='<=REMOVE=']")).Click();
            driver.FindElement(By.XPath("//*[text()='Rongala Haneesha']")).Click();
            driver.FindElement(By.XPath("//*[@value='==ADD==>']")).Click();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);

            //USING RADIO BUTTONS
            driver.FindElement(By.XPath("(//*[@type='radio'])[1]")).Click();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);

            //USING CHECKBOXES
            driver.FindElement(By.XPath("//*[@name='email_alert']")).Click();
            System.Threading.Thread.Sleep(5000);
            driver.FindElement(By.XPath("//*[@name='email_alert_contact']")).Click();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);

            //Dropdown
            SelectElement       remainder = new SelectElement(driver.FindElement(By.XPath("//*[@name='reminder_minutes']")));
            IList <IWebElement> Listcount = remainder.Options;
            int remainders = Listcount.Count();

            Console.WriteLine("Display the list of remainders:" + remainder);
            Listcount.ElementAt(1).Click();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
            driver.FindElement(By.XPath("//*[@name='reminder_note']")).SendKeys("Gentle remainder for meeting");
            driver.FindElement(By.XPath("//*[@name='internal_reminder']")).Click();

            // WINDOW HANDLING(Switching to MainWindow)
            driver.FindElement(By.XPath("//*[@name='contact_lookup']")).SendKeys("9010459436");
            driver.FindElement(By.XPath("(//*[@value='Lookup'])[1]")).Click();
            IList <string> Mainwindow = new List <string>(driver.WindowHandles);

            driver.SwitchTo().Window(Mainwindow[1]);
            driver.Close();
            driver.SwitchTo().Window(Mainwindow[0]);
            driver.SwitchTo().Frame("mainpanel");
            System.Threading.Thread.Sleep(2000);

            driver.FindElement(By.XPath("//*[@name='client_lookup']")).SendKeys("TCS");
            driver.FindElement(By.XPath("(//*[@value='Lookup'])[2]")).Click();
            IList <string> Mainwindow1 = new List <string>(driver.WindowHandles);

            driver.SwitchTo().Window(Mainwindow1[1]);
            driver.Close();
            driver.SwitchTo().Window(Mainwindow1[0]);
            driver.SwitchTo().Frame("mainpanel");
            System.Threading.Thread.Sleep(2000);

            driver.FindElement(By.XPath("//*[@name='prospect_lookup']")).SendKeys("To understand and sell the customers products");
            driver.FindElement(By.XPath("(//*[@value='Lookup'])[3]")).Click();
            IList <string> Mainwindow2 = new List <string>(driver.WindowHandles);

            driver.SwitchTo().Window(Mainwindow2[1]);
            driver.Close();
            driver.SwitchTo().Window(Mainwindow2[0]);
            driver.SwitchTo().Frame("mainpanel");
            System.Threading.Thread.Sleep(2000);

            driver.FindElement(By.XPath("//*[@name='task_lookup']")).SendKeys("Selling products and making customer satisfy");
            driver.FindElement(By.XPath("(//*[@value='Lookup'])[4]")).Click();
            IList <string> Mainwindow3 = new List <string>(driver.WindowHandles);

            driver.SwitchTo().Window(Mainwindow3[1]);
            driver.Close();
            driver.SwitchTo().Window(Mainwindow3[0]);
            driver.SwitchTo().Frame("mainpanel");
            System.Threading.Thread.Sleep(2000);

            driver.FindElement(By.XPath("//*[@name='case_lookup']")).SendKeys("Important");
            System.Threading.Thread.Sleep(2000);
            driver.FindElement(By.XPath("(//*[@value='Lookup'])[5]")).Click();
            IList <string> Mainwindow4 = new List <string>(driver.WindowHandles);

            driver.SwitchTo().Window(Mainwindow4[1]);
            driver.Close();
            driver.SwitchTo().Window(Mainwindow4[0]);
            driver.SwitchTo().Frame("mainpanel");
            driver.FindElement(By.XPath("//*[@name='tags']")).SendKeys("Important");
            driver.FindElement(By.XPath("//*[@name='location']")).SendKeys("Lancohills , Manikonda /n Hyderabad ");
            driver.FindElement(By.XPath("//*[@name='notes']")).SendKeys("This meeting will ensures the customer relationship management and customer satisfaction");
            driver.FindElement(By.XPath("//*[@name='meeting_notes']")).SendKeys("NO MINUTES");

            //// SAVE BUTTON
            IList <IWebElement> savebutton = driver.FindElements(By.XPath("//*[@value='Save']"));

            savebutton[1].Click();
            Console.WriteLine("count is" + savebutton.Count);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);

            // LOG OUT BUTTON
            driver.FindElement(By.XPath("(//*[@class='topnavlink'])[3]")).Click();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
            driver.Close();
        }
コード例 #4
0
        static void Main(string[] args)
        {
            //Define Chrome WebDriver
            IWebDriver driver = new ChromeDriver();


            //Launch Url
            driver.Navigate().GoToUrl("https://demo.econz.co.nz:1000/AdminPortal/Account/Login/exptest");

            //Maximize Browser


            //Username Definition and Input
            IWebElement Username = driver.FindElement(By.Id("UserName"));

            Username.SendKeys("jiya");

            //Password Definition and Input
            IWebElement Password = driver.FindElement(By.Id("Password"));

            Password.SendKeys("Jiya@345");

            //Login Button Definition and Click
            IWebElement LoginButton = driver.FindElement(By.XPath("/ html / body / div[3] / form / div / div / div / div[2] / div[3] / input"));

            LoginButton.Click();

            //Verification
            String Welcome = driver.FindElement(By.XPath("//*[@id='container']/div/div/h2")).Text;

            if (Welcome == "Welcome")
            {
                Console.WriteLine("Login Test Passed");
            }
            else
            {
                Console.WriteLine("Login Test Failed");
            }

            //Userinterface dropdown definiton and click
            IWebElement UserInterface = driver.FindElement(By.LinkText("User Interface"));

            UserInterface.Click();
            //Button Definiton and click
            IWebElement Button = driver.FindElement(By.LinkText("Buttons"));

            Button.Click();

            //Add New Record button definition and Click
            IWebElement AddNewRecordButton = driver.FindElement(By.XPath("//*[@id='grid']/div[1]/a"));

            AddNewRecordButton.Click();

            //Verification of Create Window
            String Create = driver.FindElement(By.XPath("/html/body/div[6]/div[1]/span")).Text;

            if (Create == "Create")
            {
                Console.WriteLine("Create window Test Passed");
            }
            else
            {
                Console.WriteLine("Create window Test Failed");
            }
            //Button name definiton
            IWebElement ButtonName = driver.FindElement(By.XPath("/html/body/div[6]/div[2]/div/div[2]/input"));

            ButtonName.SendKeys("Archana");

            //Button Display Title
            IWebElement ButtonDisplayTitle = driver.FindElement(By.XPath("/html/body/div[6]/div[2]/div/div[4]/input"));

            ButtonDisplayTitle.SendKeys("Archu");

            //Button Logo Definition

            IWebElement ButtonLogo = driver.FindElement(By.XPath("/html/body/div[6]/div[2]/div/div[6]/span/span/span[1]"));

            ButtonLogo.Click();
            Thread.Sleep(2000);

            IWebElement BLSelection = driver.FindElement(By.XPath("/html/body/div[7]/div/ul/li[4]/table/tbody/tr/td[1]/div"));

            BLSelection.Click();
            Thread.Sleep(2000);
            //Pre-Condition Definition
            IWebElement PreCondition = driver.FindElement(By.XPath("/html/body/div[6]/div[2]/div/div[8]/input"));

            PreCondition.SendKeys("xyz");

            //Next Screen
            IWebElement NextScreen = driver.FindElement(By.XPath("/html/body/div[6]/div[2]/div/div[10]/span/span/span[1]"));

            NextScreen.Click();

            Thread.Sleep(8000);
            IWebElement NSSelection = driver.FindElement(By.XPath("//*[@id='NEXT_SCREEN_DBID_listbox']/li[3]"));

            NSSelection.Click();
            Thread.Sleep(8000);


            //Value Update Definition
            IWebElement ValueUpdate = driver.FindElement(By.XPath("/html/body/div[6]/div[2]/div/div[12]/input"));

            ValueUpdate.SendKeys("update");
            Thread.Sleep(2000);

            //Next State Definiton
            IWebElement NextState = driver.FindElement(By.XPath("/html/body/div[6]/div[2]/div/div[14]/span/span/span[1]"));

            NextState.Click();
            Thread.Sleep(5000);
            IWebElement NTSelection = driver.FindElement(By.XPath("//*[@id='NEXT_STATE_DBID_listbox']/li[8]"));

            NTSelection.Click();
            Thread.Sleep(5000);

            //Pending State Definition
            IWebElement PendingState = driver.FindElement(By.XPath("/html/body/div[6]/div[2]/div/div[16]/span/span/span[1]"));

            PendingState.Click();
            Thread.Sleep(5000);
            IWebElement PSSelection = driver.FindElement(By.XPath("//*[@id='PENDING_STATE_DBID_listbox']/li[5]"));

            PSSelection.Click();
            Thread.Sleep(2000);

            //Entity Type Definiton
            IWebElement EntityType = driver.FindElement(By.XPath("/html/body/div[6]/div[2]/div/div[18]/span/span/span[1]"));

            EntityType.Click();
            Thread.Sleep(5000);
            IWebElement ETSelection = driver.FindElement(By.XPath("//*[@id='ETT_DBID_listbox']/li[3]"));

            ETSelection.Click();
            Thread.Sleep(2000);
            //Override Theme ? Definition
            IWebElement OverrideTheme = driver.FindElement(By.XPath("/html/body/div[6]/div[2]/div/div[20]/span[1]/span/span[1]"));

            OverrideTheme.Click();
            Thread.Sleep(2000);
            IWebElement ORSelection = driver.FindElement(By.XPath("/html/body/div[12]/div/ul/li[1]"));

            ORSelection.Click();
            Thread.Sleep(2000);

            //BG Colour Definiton
            //Colour efiniton
            //Border Colour efiniton

            IWebElement CreateButton = driver.FindElement(By.XPath("/html/body/div[6]/div[2]/div/div[27]/a[1]"));

            CreateButton.Click();
        }
コード例 #5
0
        public void Testcase06()
        {
            Infor("1.Go to http://live.guru99.com/");
            Driver = new ChromeDriver(Directory.GetCurrentDirectory())
            {
                Url = TestCommonKeyWords["Guru.URL"]
            };
            Driver.Manage().Window.Maximize();
            Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2);

            Infor("2.Click on my account link");
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Acount"])).Click();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.MyAcount"])).Click();

            Infor("3.Login in application using previously created credential");
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.LoginEmail"])).SendKeys(TestCommonKeyWords["Guru.Xpath.LoginEmailData"]);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.LoginPass"])).SendKeys(TestCommonKeyWords["Guru.Xpath.LoginPassData"]);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.LoginSubmit"])).Click();
            Thread.Sleep(3000);
            //Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.Acount"])).Click();

            Infor("4.Click on MY WISHLIST link");
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Acount"])).Click();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.MyWhistlist"])).Click();

            Infor("5.In next page, Click ADD TO CART link");
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.AddToCartWhistlist"])).Click();

            Infor("6.Enter general shipping country, state / province and zip for the shipping cost estimate");
            new SelectElement(Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.Country"]))).SelectByText(TestKeyWords["Guru.Xpath.CountryData"]);
            Thread.Sleep(2000);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.Region"])).SendKeys(TestKeyWords["Guru.Xpath.RegionData"]);
            Thread.Sleep(2000);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.PostCode"])).SendKeys(TestKeyWords["Guru.Xpath.PostCodeData"]);

            Infor("7.Click Estimate");
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.Estimate"])).Click();

            /*
             * Infor("8.Verify Shipping cost generated");
             * string flatRate = Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.FlatRate"])).Text;
             * Assert(flatRate.Trim(), TestKeyWords["Guru.Xpath.FlatRateData"].Trim());
             * string fpriceFix = Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.FlatRate"])).Text;
             * Assert(fpriceFix.Trim(), TestKeyWords["Guru.Xpath.FixPriceData"].Trim());
             */
            Infor("9.Select Shipping Cost, Update Total");
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.CheckboxPrice"])).Click();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.UpdateTotal"])).Click();

            Infor("10.Verify shipping cost is added to total");
            string vflatRatePrice = Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.vFlatRatePrice"])).Text;

            //Assert(vflatRatePrice.Trim(), TestKeyWords["Guru.Xpath.vFlatRatePriceData"].Trim());

            Infor("11.Click 'Proceed to Checkout'");
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.Checkout"])).Click();

            Infor("12a.Enter Billing Information, and click Continue");
            SelectElement BtnAdress = new SelectElement(Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.NewAddress"])));

            BtnAdress.SelectByIndex(2);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Company"])).Clear();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Company"])).SendKeys(TestCommonKeyWords["Guru.Xpath.CompanyData"]);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Address"])).Clear();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Address"])).SendKeys(TestCommonKeyWords["Guru.Xpath.AddressData"]);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.AddressStreet"])).Clear();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.AddressStreet"])).SendKeys(TestCommonKeyWords["Guru.Xpath.AddressStreetData"]);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.City"])).Clear();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.City"])).SendKeys(TestCommonKeyWords["Guru.Xpath.CityData"]);
            Thread.Sleep(2000);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.RegionBilling"])).Clear();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.RegionBilling"])).SendKeys(TestKeyWords["Guru.Xpath.RegionBillingData"]);
            //new SelectElement(Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.RegionBilling"]))).SelectByText(TestKeyWords["Guru.Xpath.RegionBillingData"]);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.PostCodeBilling"])).Clear();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.PostCodeBilling"])).SendKeys(TestCommonKeyWords["Guru.Xpath.PostCodeBillingData"]);
            new SelectElement(Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.CountryBilling"]))).SelectByText(TestCommonKeyWords["Guru.Xpath.CountryBillingData"]);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Telephone"])).Clear();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Telephone"])).SendKeys(TestCommonKeyWords["Guru.Xpath.TelephoneData"]);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Fax"])).Clear();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Fax"])).SendKeys(TestCommonKeyWords["Guru.Xpath.FaxData"]);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Checkbox1"])).Click();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.ContinueButton"])).Click();
            Thread.Sleep(3000);

            Infor("12b.Enter Shipping Information, and click Continue");
            SelectElement BtnAdressship = new SelectElement(Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipAddress"])));

            BtnAdressship.SelectByIndex(2);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipFirstName"])).Clear();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipFirstName"])).SendKeys(TestKeyWords["Guru.Xpath.ShipFirstNameData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipMiddleName"])).Clear();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipMiddleName"])).SendKeys(TestKeyWords["Guru.Xpath.ShipMiddleNameData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipLastName"])).Clear();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipLastName"])).SendKeys(TestKeyWords["Guru.Xpath.ShipLastNameData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipCompany"])).Clear();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipCompany"])).SendKeys(TestKeyWords["Guru.Xpath.ShipCompanyData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipAdress1"])).Clear();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipAdress1"])).SendKeys(TestKeyWords["Guru.Xpath.ShipAdress1Data"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipAdress2"])).Clear();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipAdress2"])).SendKeys(TestKeyWords["Guru.Xpath.ShipAdress2Data"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipCity"])).Clear();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipCity"])).SendKeys(TestKeyWords["Guru.Xpath.ShipCityData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipDistrict"])).Clear();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipDistrict"])).SendKeys(TestKeyWords["Guru.Xpath.ShipDistrictData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipPostcode"])).Clear();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipPostcode"])).SendKeys(TestKeyWords["Guru.Xpath.ShipPostcodeData"]);
            new SelectElement(Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipCountry"]))).SelectByText(TestKeyWords["Guru.Xpath.ShipCountryData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipTelephone"])).Clear();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipTelephone"])).SendKeys(TestKeyWords["Guru.Xpath.ShipTelephoneData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipCheckbox"])).Click();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShipButton"])).Click();
            Thread.Sleep(3000);
            Infor("13.In Shipping Method, Click Continue");
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.ShipButtonMethod"])).Click();
            Thread.Sleep(3000);

            Infor("14.In Payment Information select 'Check/Money Order' radio button.Click Continue");
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.ShipMethodCheckMo"])).Click();
            Thread.Sleep(3000);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.ShipButtonMethodPayment"])).Click();
            Thread.Sleep(3000);

            Infor("15.Click 'PLACE ORDER' button");
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.ShipPlaceOrder"])).Click();
            Thread.Sleep(3000);

            Infor("16.Verify Oder is generated.Note the order number");
            PassTest("Ra order rồi nhé");
            AddScreenCaptureFromPath();

            //NOTE: PROCEED TO CHECKOUT (step 6 ) was taken out, so as to allow the Estimate button step to get processed.
            //Rest of the steps renumbered accordingly.
        }
コード例 #6
0
        public List <Stock> Scrape()
        {
            var options = new ChromeOptions();

            options.AddArguments("--headless");
            options.AddArguments("--disable-gpu");
            options.AddArguments("--window-size=1980,1080");

            IWebDriver chromeDriver = new ChromeDriver("C:\\Users\\klync\\Source\\Repos\\FinanceScraper");

            // fixing timing issues //
            //WebDriverWait wait = new WebDriverWait(chromeDriver, TimeSpan.FromSeconds(5));

            chromeDriver.Navigate().GoToUrl("https://login.yahoo.com");
            chromeDriver.Manage().Window.Maximize();

            chromeDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);

            chromeDriver.FindElement(By.Id("login-username")).SendKeys("" + Keys.Enter);
            chromeDriver.FindElement(By.Id("login-passwd")).SendKeys("" + Keys.Enter);

            chromeDriver.Url = "https://finance.yahoo.com/portfolio/p_0/view/v1";

            IWebElement list = chromeDriver.FindElement(By.TagName("tbody"));

            System.Collections.ObjectModel.ReadOnlyCollection <IWebElement> stocks = list.FindElements(By.TagName("tr"));
            int count;

            count = stocks.Count();

            List <Stock> stockList = new List <Stock>();

            for (int i = 1; i <= count; i++)
            {
                var symbol    = chromeDriver.FindElement(By.XPath("//*[@id=\"main\"]/section/section[2]/div[2]/table/tbody/tr[" + i + "]/td[1]/span/a")).GetAttribute("innerText");
                var lastPrice = chromeDriver.FindElement(By.XPath("//*[@id=\"main\"]/section/section[2]/div[2]/table/tbody/tr[" + i + "]/td[2]/span")).GetAttribute("innerText");
                var change    = chromeDriver.FindElement(By.XPath("//*[@id=\"main\"]/section/section[2]/div[2]/table/tbody/tr[" + i + "]/td[3]/span")).GetAttribute("innerText");
                var pChange   = chromeDriver.FindElement(By.XPath("//*[@id=\"main\"]/section/section[2]/div[2]/table/tbody/tr[" + i + "]/td[4]/span")).GetAttribute("innerText");
                var currency  = chromeDriver.FindElement(By.XPath("//*[@id=\"main\"]/section/section[2]/div[2]/table/tbody/tr[" + i + "]/td[5]")).GetAttribute("innerText");
                var volume    = chromeDriver.FindElement(By.XPath("//*[@id=\"main\"]/section/section[2]/div[2]/table/tbody/tr[" + i + "]/td[7]/span")).GetAttribute("innerText");
                var aVolume   = chromeDriver.FindElement(By.XPath("//*[@id=\"main\"]/section/section[2]/div[2]/table/tbody/tr[" + i + "]/td[9]")).GetAttribute("innerText");
                var marketCap = chromeDriver.FindElement(By.XPath("//*[@id=\"main\"]/section/section[2]/div[2]/table/tbody/tr[" + i + "]/td[13]/span")).GetAttribute("innerText");


                Stock stock = new Stock();
                Console.WriteLine(symbol);
                stock.Symbol = symbol;
                Console.WriteLine(lastPrice);
                stock.LastPrice = lastPrice;
                Console.WriteLine(change);
                stock.Change = change;
                Console.WriteLine(pChange);
                stock.PChange = pChange;
                Console.WriteLine(currency);
                stock.Currency = currency;
                Console.WriteLine(volume);
                stock.Volume = volume;
                Console.WriteLine(aVolume);
                stock.AVolume = aVolume;
                Console.WriteLine(marketCap);
                stock.MarketCap = marketCap;

                Console.WriteLine(stock);
                stockList.Add(stock);
            }
            return(stockList);
        }
コード例 #7
0
        static void Main(string[] args)
        {
            IWebDriver chromeDriver = new ChromeDriver();

            //string pathToFile = @"C:\Users\jnprogrammer9\Documents\Projects\c#\webScrapper-Selenium\webScrapper-Selenium\webScrapper-Selenium\test.txt";
            string coinName, coinSymbol, coinPrice, coinMarketCap, coinSupply, coinVolume24hr;

            chromeDriver.Navigate().GoToUrl("https://coinmarketcap.com/all/views/all/");
            var table = chromeDriver.FindElement(By.XPath("//table[@id='currencies-all']"));

            try
            {
                // "//table[@id='currencies-all']//tr[@id='id-bitcoin']//td[@class='no-wrap currency-name']//a[@class='currency-name-container']"

                // coinName = chromeDriver.FindElement(By.XPath("//table[@id='currencies-all']//tr/td//a[@class='currency-name-container']")).Text; //$x("//table[@id='currencies-all']//tr[@id='id-bitcoin']")[0]



                // foreach (var row in table.FindElements(By.TagName("tbody")))

                coinName   = chromeDriver.FindElement(By.XPath("//table[@id='currencies-all']//tr/td//a[@class='currency-name-container']")).Text;
                coinSymbol = chromeDriver.FindElement(By.XPath("//table[@id='currencies-all']//tr/td[@class='text-left col-symbol']")).Text;
                coinPrice  = chromeDriver.FindElement(By.XPath("//table[@id='currencies-all']//tr/td//a[@class='price']")).Text;

                // < td class="text-left col-symbol">BTC</td>
                Console.WriteLine(coinName);
                Console.WriteLine(coinSymbol);
                Console.WriteLine(coinPrice);



                using (var db = new CryptoContext())
                {
                    var aCryptoTable = new CryptoTable {
                        CoinName = coinName, CoinSymbol = coinSymbol
                    };
                    db.CryptoTables.Add(aCryptoTable);
                    db.SaveChanges();

                    var query = from b in db.CryptoTables
                                orderby b.CoinName
                                select b;

                    foreach (var item in query)
                    {
                        Console.WriteLine(item.CoinSymbol);
                    }
                }

                /* coinSymbol = chromeDriver.FindElement(By.XPath("")).Text;
                 *                                                                                                                     coinPrice = chromeDriver.FindElement(By.XPath("")).Text;
                 *                                                                                                                                coinMarketCap = chromeDriver.FindElement(By.XPath("")).Text;
                 *                                                                                                                                coinSupply = chromeDriver.FindElement(By.XPath("")).Text;
                 *                                                                                                                                coinVolume24hr = chromeDriver.FindElement(By.XPath("")).Text;*/

                //Console.WriteLine("{0} {1} Price:{2} MarketCap:{3} Supply:{4} 24Hr Volume: {5}\n",coinName,coinSymbol,coinPrice,coinMarketCap,coinSupply,coinVolume24hr);  ////table[@id='currencies-all']//tr[@id='id-bitcoin']
            }
            catch (Exception e)
            {
                Console.WriteLine("Error:" + e);
            }
            chromeDriver.Close();
            Console.WriteLine("No errors thrown");
        }
コード例 #8
0
    private void Run()
    {
        // Create a new webdriver
        IWebDriver webDriver = new ChromeDriver();

        // Navigate to the url we want to test
        webDriver.Url = "https:/demo.applitools.com";

        // ⭐️ Note to see visual bugs, run the test using the above URL for the 1st run.
        //but then change the above URL to https://demo.applitools.com/index_v2.html (for the 2nd run)

        // Create a runner with concurrency of 10
        VisualGridRunner runner = new VisualGridRunner(10);

        // Create Eyes object with the runner, meaning it'll be a Visual Grid eyes.
        Eyes eyes = new Eyes(runner);

        //Set the Applitools API KEY here or as an environment variable "APPLITOOLS_API_KEY"
        eyes.ApiKey = "F14XisZHkSsBUkObF9puHR104mxuXUsVL2zAVd7x49bps110";


        // Create configuration object
        Configuration conf = new Configuration();


        // Set test name
        conf.TestName = "C# VisualGrid demo";

        // Set app name
        conf.AppName = "Demo app";

        // Add browsers with different viewports
        conf.AddBrowser(800, 600, Configuration.BrowserType.CHROME);
        conf.AddBrowser(700, 500, Configuration.BrowserType.CHROME);
        conf.AddBrowser(1200, 800, Configuration.BrowserType.FIREFOX);
        conf.AddBrowser(1600, 1200, Configuration.BrowserType.FIREFOX);

        // Add iPhone 4 device emulation in Portraig mode
        EmulationInfo iphone4 = new EmulationInfo(EmulationInfo.DeviceNameEnum.iPhone_4, Applitools.VisualGrid.ScreenOrientation.Portrait);

        conf.AddDeviceEmulation(iphone4);



        // Set the configuration object to eyes
        eyes.Configuration = conf;

        // Call Open on eyes to initialize a test session
        eyes.Open(webDriver);

        // check the login page
        eyes.Check(Target.Window().Fully().WithName("Login page"));
        webDriver.FindElement(By.Id("log-in")).Click();

        // Check the app page
        eyes.Check(Target.Window().Fully().WithName("App page"));

        // Close the browser
        webDriver.Quit();

        //Wait and collect all test results
        TestResultSummary allTestResults = runner.GetAllTestResults();

        System.Console.WriteLine(allTestResults);
    }
コード例 #9
0
ファイル: UserExists.cs プロジェクト: sbstemen/PracticeCode
        /// <summary>
        /// Logs on a student, validates and returns a bool.
        /// </summary>
        /// <param name="utility">The utility.</param>
        /// <param name="logPath">The log path.</param>
        /// <param name="usrData">An Object representing user details and data</param>
        /// <returns>bool</returns>
        public bool LogIn(Utilities utility, string logPath, UserData usrData)
        {
            bool   passed      = false;
            var    newLine     = Environment.NewLine;
            Size   browserSize = new Size(1526, 896);
            string chromePath  = Directory.GetCurrentDirectory() + "\\assets\\";
            string logOffXpath = this.LogOffXpath(usrData.LogInAlias);
            string startPage   = @"https://www.google.com/"; // Just for browser Timing.
            string pageText    = string.Empty;
            string searchText  = string.Empty;

            if (!Directory.Exists(logPath))
            {
                Directory.CreateDirectory(logPath);
                utility.MakeLogEntry("Log on student > " + DateTime.UtcNow.Ticks.ToString() + newLine);
            }
            else
            {
                utility.MakeLogEntry("Log on student > " + DateTime.UtcNow.Ticks.ToString() + newLine);
            }

            // MUST do a log off, or else cookie will remain for last user ID
            try
            {
                Assert.IsTrue(logOffXpath != "nopath");
                {
                    utility.MakeLogEntry("Logout XPath is set for = " + usrData.LogInAlias);
                }
            }
            catch (Exception expText)
            {
                utility.MakeLogEntry("FAILED" + newLine + expText);
                utility.MakeLogEntry("Abandoned the whole test, no logoff path, bad login");
            }

            using (IWebDriver webDriver = new ChromeDriver(chromePath))
            {
                webDriver.Navigate().GoToUrl(startPage);

                utility.RandomPause(1);

                webDriver.Manage().Window.Size = browserSize;

                webDriver.Navigate().GoToUrl(usrData.ClientUrl);

                utility.RandomPause(2);

                webDriver.FindElement(By.Id("Username")).SendKeys(usrData.LogInAlias);
                webDriver.FindElement(By.Id("Password")).SendKeys(usrData.Password);
                utility.RandomPause(1.5);
                webDriver.FindElement(By.ClassName("cc-btn-sign-in")).Click();
                utility.RandomPause(3);
                pageText   = webDriver.PageSource.ToString();
                searchText = "My Dashboard";

                try
                {
                    Assert.IsTrue(pageText.Contains(searchText));
                    {
                        utility.MakeLogEntry("Log On succeeded for ==> " + usrData.LogInAlias);
                        utility.RandomPause(2);
                        searchText = string.Empty;
                    }
                }
                catch (Exception expText)
                {
                    utility.MakeLogEntry("Log On Failed for client " + newLine + usrData.LogInAlias);
                    utility.MakeLogEntry("Exception Code" + newLine + expText);
                    Assert.Fail();
                }

                /* For Log OFF code required, It scrolls down and then clan click click */
                try
                {
                    IJavaScriptExecutor jsexe = (IJavaScriptExecutor)webDriver;

                    jsexe.ExecuteScript("window.scrollTo(0, Math.max(document.documentElement.scrollHeight, document.body.scrollHeight, document.documentElement.clientHeight));");

                    utility.RandomPause(2);

                    webDriver.FindElement(By.XPath(logOffXpath)).Click();
                }
                catch (Exception expText)
                {
                    utility.MakeLogEntry(expText.ToString());
                }

                /* Validation the log out was completed successfully, check is the ph num is gone */
                try
                {
                    utility.RandomPause(2);
                    pageText   = webDriver.PageSource;
                    searchText = "tel:+1-855-755-2267";

                    Assert.IsTrue(!pageText.Contains(searchText));
                    {
                        utility.MakeLogEntry("PASSED" + newLine +
                                             "Log In, Authentication, Log Off all passed");
                        passed = true;
                    }
                }
                catch (Exception expText)
                {
                    utility.MakeLogEntry("LOG OFF Failed error Was " + newLine + expText);
                    Assert.Fail();
                }

                webDriver.Close();
            }

            return(passed);
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: Zvonetg/Selenium
        static void Main(string[] args)

        {
            ChromeOptions options = new ChromeOptions(); //definiranje profila

            options.AddArgument("disable-infobars");
            options.AddArgument("--disable-web-security");
            options.AddArgument("--ignore-certificate-errors");
            options.AddArgument("-ignore-certificate-errors");
            options.AddUserProfilePreference("profile.default_content_setting_values.notifications", 1);
            IWebDriver driver = new ChromeDriver(options);

            driver.Navigate().GoToUrl("https://www.getihub.com/login"); //navigacija
            IWebElement element = driver.FindElement(By.CssSelector("[type = button]"));

            Thread.Sleep(1000);
            driver.Manage().Window.Maximize();
            string text  = "zvonimir.knezevic";
            string text1 = "@serengetitech.com";

            element.Click();
            Thread.Sleep(1000);
            driver.FindElement(By.Name("loginfmt")).SendKeys(text);
            Thread.Sleep(1000);
            driver.FindElement(By.Name("loginfmt")).SendKeys(text1);
            driver.FindElement(By.Id("idSIButton9")).Click();
            Thread.Sleep(1000);
            driver.FindElement(By.Id("i0118")).SendKeys("Zvone9922" + Keys.Enter);

            Thread.Sleep(1000);
            driver.FindElement(By.Id("idSIButton9")).Click();
            Thread.Sleep(2000);

            driver.Navigate().GoToUrl("https://www.getihub.com/timesheet/landing");
            Thread.Sleep(2000);
            driver.FindElement(By.CssSelector("[class = event-header-button]")).Click();
            Thread.Sleep(1000);
            Thread.Sleep(1000);
            driver.FindElement(By.CssSelector("[type = button]")).Click();
            Thread.Sleep(1000);
            Thread.Sleep(1000);
            driver.FindElement(By.LinkText("5")).Click();
            Thread.Sleep(1000);

            driver.FindElement(By.XPath("//*[@aria-label= '7:30-15:30']")).Click();
            Thread.Sleep(1000);

            IWebElement element1 = driver.FindElement(By.XPath("//*[@for = 'projectId']"));

            element1.Click();
            driver.FindElement(By.XPath("//*[@role = 'listbox']")).Click();
            Thread.Sleep(2000);
            IWebElement element2 = driver.FindElement(By.XPath("//*[@for = 'taskId']"));

            element2.Click();
            Thread.Sleep(2000);
            driver.FindElement(By.XPath("//*[@role = 'listbox']")).Click();
            Thread.Sleep(2000);
            driver.FindElement(By.XPath("//*[@type = 'submit']")).Submit();
            Thread.Sleep(2000);
            driver.Navigate().Refresh();
            Thread.Sleep(3000);



            driver.Quit();
        }
コード例 #11
0
        public void CreateAccount()
        {
            IWebDriver driver = new ChromeDriver();

            WebDriverWait myWaitVar = new WebDriverWait(driver, TimeSpan.FromSeconds(20));

            // Open the website
            driver.Navigate().GoToUrl("https://techblog.polteq.com/testshop/index.php");

            driver.Manage().Window.Maximize();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            driver.FindElement(By.ClassName("login")).Click();

            Assert.AreEqual("Authentication - TestShop", driver.Title);

            IWebElement createEmail = wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("email_create")));

            createEmail.Click();

            Random random = new Random();

            int emailAddition = random.Next(1, 10000);

            string emailBase     = "bootcampmania";
            string emailProvider = "@test.com";

            createEmail.SendKeys(emailBase + emailAddition + emailProvider);

            IWebElement createAccount = driver.FindElement(By.Id("SubmitCreate"));

            createAccount.Click();

            IWebElement firstGender = wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("uniform-id_gender2")));

            firstGender.Click();

            IWebElement fName = driver.FindElement(By.Id("customer_firstname"));

            fName.SendKeys("T");

            IWebElement lName = driver.FindElement(By.Id("customer_lastname"));

            lName.SendKeys("Test");

            IWebElement password = driver.FindElement(By.Id("passwd"));

            password.SendKeys("1qazxsw2");

            var daySelection = driver.FindElement(By.Id("days"));
            var selectDay    = new SelectElement(element: daySelection);

            selectDay.SelectByValue("1");

            var monthSelection = driver.FindElement(By.Id("months"));
            var selectMonth    = new SelectElement(element: monthSelection);

            selectMonth.SelectByValue("1");

            var yearSelection = driver.FindElement(By.Id("years"));
            var selectYear    = new SelectElement(element: yearSelection);

            selectYear.SelectByValue("1982");

            IWebElement submitButton = driver.FindElement(By.Id("submitAccount"));

            Console.WriteLine(submitButton.Text);
            submitButton.Click();

            // Verify if the MY ACCOUNT text is show
            String validationString = driver.FindElement(By.CssSelector("h1.page-heading")).Text;

            Assert.AreEqual("MY ACCOUNT", validationString, "My account element was not found");

            driver.Quit();
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: 0x24D/QubaGroup1
        static void Main()
        {
            IWebDriver driver = new ChromeDriver();
            //-------------------------change-url-here------------------------------------
            string baseURL = "http://shugroupproject1.quba.co.uk/";

            //----------------------------------------------------------------------------
            //---------------------------Enter-Code-Here----------------------------------
            //---------Use-Console-to-test-for-errors-and-error-capturing-----------------
            driver.Navigate().GoToUrl(baseURL);
            Console.WriteLine("Testing TextBox1");//for test log
            try
            {
                driver.FindElement(By.Id("TextBox1")).Clear();
                driver.FindElement(By.Id("TextBox12")).SendKeys("*****@*****.**");
            }
            catch
            {
                Console.Error.WriteLine("Error: Testing TextBox1");/*Error to logs*/
                Environment.Exit(1);
            }
            Console.WriteLine("Testing TextBox2");
            try
            {
                driver.FindElement(By.Id("TextBox2")).Clear();
                driver.FindElement(By.Id("TextBox2")).SendKeys("password");
            }
            catch
            {
                Console.Error.WriteLine("Error: Testing TextBox1");
                Environment.Exit(1);
            }
            Console.WriteLine("Testing CheckBox1");
            try
            {
                driver.FindElement(By.Id("CheckBox1")).Click();
            }
            catch
            {
                Console.Error.WriteLine("Error: Testing CheckBox1");
                Environment.Exit(1);
            }
            Console.WriteLine("Testing TextBox3");
            try
            {
                driver.FindElement(By.Id("TextBox3")).Clear();
                driver.FindElement(By.Id("TextBox3")).SendKeys("homenumber\naddress\npostcode");
            }
            catch
            {
                Console.Error.WriteLine("Error: Testing TextBox3");
                Environment.Exit(1);
            }
            Console.WriteLine("Testing RadioButtonList1_1");
            try
            {
                driver.FindElement(By.Id("RadioButtonList1_1")).Click();
            }
            catch
            {
                Console.Error.WriteLine("Error: Testing RadioButtonList1_1");
                Environment.Exit(1);
            }
            Console.WriteLine("Testing DropDownList1");
            try
            {
                new SelectElement(driver.FindElement(By.Id("DropDownList1"))).SelectByText("GERMANY");
            }
            catch
            {
                Console.Error.WriteLine("Error: Testing DropDownList1");
                Environment.Exit(1);
            }
            Console.WriteLine("Testing btnSubmit");
            try
            {
                driver.FindElement(By.Id("btnSubmit")).Click();
            }
            catch
            {
                Console.Error.WriteLine("Error: Testing btnSubmit");
                Environment.Exit(1);
            }
            //---------------------------------------------------------------------------
            Console.ReadLine();
            driver.Quit();
        }
コード例 #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="streetno"></param>
        /// <param name="streetname"></param>
        /// <param name="direction"></param>
        /// <param name="streetype"></param>
        /// <param name="unitno"></param>
        /// <param name="ownername"></param>
        /// <param name="parcelNumber"></param>
        /// <param name="searchType"></param>
        /// <param name="orderNumber"></param>
        /// <param name="directParcel"></param>
        /// <returns></returns>
        public string FTP_Spokane(string streetno, string streetname, string direction, string streetype, string unitno, string ownername, string parcelNumber, string searchType, string orderNumber, string directParcel)
        {
            GlobalClass.global_orderNo             = orderNumber;
            HttpContext.Current.Session["orderNo"] = orderNumber;
            GlobalClass.global_parcelNo            = parcelNumber;
            List <string> multiparcel = new List <string>();
            string        StartTime = "", AssessmentTime = "", TaxTime = "", CitytaxTime = "", LastEndTime = "", TaxAuthority = "";

            var driverService = PhantomJSDriverService.CreateDefaultService();

            driverService.HideCommandPromptWindow = true;
            using (driver = new PhantomJSDriver())
            {
                StartTime = DateTime.Now.ToString("HH:mm:ss");
                driver.Navigate().GoToUrl("https://cp.spokanecounty.org/scout/propertyinformation/");

                try
                {
                    if (searchType == "titleflex")
                    {
                        string address = streetno + " " + direction + " " + streetname + " " + streetype + " " + unitno;
                        gc.TitleFlexSearch(orderNumber, parcelNumber, ownername, address, "WA", "Spokane");
                        if ((HttpContext.Current.Session["TitleFlex_Search"] != null && HttpContext.Current.Session["TitleFlex_Search"].ToString() == "Yes"))
                        {
                            driver.Quit();
                            return("MultiParcel");
                        }
                        else if (HttpContext.Current.Session["titleparcel"].ToString() == "")
                        {
                            HttpContext.Current.Session["Nodata_SpokaneWA"] = "Yes";
                            driver.Quit();
                            return("No Data Found");
                        }
                        parcelNumber = HttpContext.Current.Session["titleparcel"].ToString();
                        searchType   = "parcel";
                    }
                    if (searchType == "address")
                    {
                        try
                        {
                            driver.Navigate().GoToUrl("https://cp.spokanecounty.org/scout/propertyinformation/SearchADV.aspx");
                        }
                        catch { }

                        driver.FindElement(By.Id("MainContent_txtFromStreet")).SendKeys(streetno);
                        IWebElement   ISelect = driver.FindElement(By.Id("MainContent_ddlStreetDir"));
                        SelectElement sSelect = new SelectElement(ISelect);
                        sSelect.SelectByValue(direction);
                        IWebElement   ISelect1 = driver.FindElement(By.Id("MainContent_ddlStreetType"));
                        SelectElement sSelect1 = new SelectElement(ISelect1);
                        sSelect1.SelectByValue(streetype);
                        driver.FindElement(By.Id("MainContent_txtStreetName")).SendKeys(streetname);
                        gc.CreatePdf_WOP(orderNumber, "SearchAddressBefore", driver, "WA", "Spokane");
                        driver.FindElement(By.Id("MainContent_btnSearch")).SendKeys(Keys.Enter);
                        Thread.Sleep(2000);
                        gc.CreatePdf_WOP(orderNumber, "SearchAddressAfter", driver, "WA", "Spokane");
                        //Multi Parcel
                        try
                        {
                            IWebElement         Multiaddresstable = driver.FindElement(By.XPath("//*[@id='MainContent_GridView1']/tbody"));
                            IList <IWebElement> multiaddressrow   = Multiaddresstable.FindElements(By.TagName("tr"));
                            IList <IWebElement> Mutiaddressid;
                            foreach (IWebElement Multiaddress in multiaddressrow)
                            {
                                Mutiaddressid = Multiaddress.FindElements(By.TagName("td"));
                                if (multiaddressrow.Count != 0 && multiaddressrow.Count < 26)
                                {
                                    string Parcelnumber       = Mutiaddressid[1].Text;
                                    string multiaddressresult = Mutiaddressid[3].Text + "~" + Mutiaddressid[6].Text;
                                    gc.insert_date(orderNumber, Parcelnumber, 943, multiaddressresult, 1, DateTime.Now);
                                }
                            }
                            if (multiaddressrow.Count > 1 && multiaddressrow.Count < 26)
                            {
                                HttpContext.Current.Session["multiparcel_Spokane"] = "Yes";
                                driver.Quit();
                                return("MultiParcel");
                            }
                            if (multiaddressrow.Count > 1 && multiaddressrow.Count > 25)
                            {
                                HttpContext.Current.Session["multiparcel_Spokane_Maximum"] = "Maximum";
                                driver.Quit();
                                return("Maximum");
                            }
                        }
                        catch { }
                        try
                        {
                            //No Data Found
                            string nodata = driver.FindElement(By.Id("MainContent_lblMsg")).Text;
                            if (nodata.Contains("There were no records found."))
                            {
                                HttpContext.Current.Session["Nodata_SpokaneWA"] = "Yes";
                                driver.Quit();
                                return("No Data Found");
                            }
                        }
                        catch { }
                    }
                    if (searchType == "parcel")
                    {
                        driver.FindElement(By.Id("txtSearch")).SendKeys(parcelNumber);
                        driver.FindElement(By.Id("MainContent_btnSearch")).SendKeys(Keys.Enter);
                        Thread.Sleep(2000);
                        gc.CreatePdf_WOP(orderNumber, "SearchAddressBefore", driver, "WA", "Spokane");
                        try
                        {
                            //No Data Found
                            string nodata = driver.FindElement(By.Id("MainContent_lblMsg")).Text;
                            if (nodata.Contains("There were no records found.") || nodata.Contains("No record found by that search criteria."))
                            {
                                HttpContext.Current.Session["Nodata_SpokaneWA"] = "Yes";
                                driver.Quit();
                                return("No Data Found");
                            }
                        }
                        catch { }
                    }
                    //Property Details
                    string PropertyDetails = "", ParcelNumber = "", ParcelNumber1 = "", OwnerName = "", OwnerAddress1 = "", OwnerAddress = "", TaxpayerName = "", TaxPayerAddress = "", ParcelType = "", SiteAddress = "", City = "", Description = "", TaxCodeArea = "", Status = "", ParcelClass = "", NeighborhoodCode = "", NeighborhoodName = "", NeighborhoodDesc = "", YearBuilt = "", Acreage = "";

                    ParcelNumber1   = driver.FindElement(By.Id("lblParcel")).Text.Trim();
                    ParcelNumber    = GlobalClass.After(ParcelNumber1, "Parcel Number:").Trim();
                    OwnerName       = driver.FindElement(By.Id("MainContent_OwnerName_dlOwner_txtNameLabel_0")).Text.Trim();
                    OwnerAddress1   = driver.FindElement(By.Id("MainContent_OwnerName_dlOwner_addressLabel_0")).Text.Trim();
                    TaxpayerName    = driver.FindElement(By.Id("MainContent_Taxpayer_dlTaxpayer_txtNameLabel_0")).Text.Trim();
                    TaxPayerAddress = driver.FindElement(By.Id("MainContent_Taxpayer_dlTaxpayer_addressLabel_0")).Text.Trim();

                    try
                    {
                        IWebElement         proinfo2   = driver.FindElement(By.XPath("//*[@id='MainContent_SiteAddress_GridView1']/tbody"));
                        IList <IWebElement> TRproinfo2 = proinfo2.FindElements(By.TagName("tr"));
                        IList <IWebElement> TDproinfo2;
                        foreach (IWebElement row in TRproinfo2)
                        {
                            TDproinfo2 = row.FindElements(By.TagName("td"));
                            if (TDproinfo2.Count != 0 && TDproinfo2.Count == 9)
                            {
                                ParcelType  = TDproinfo2[0].Text;
                                SiteAddress = TDproinfo2[1].Text;
                                City        = TDproinfo2[2].Text;
                                Description = TDproinfo2[5].Text;
                                TaxCodeArea = TDproinfo2[7].Text;
                                Status      = TDproinfo2[8].Text;
                            }
                        }
                    }
                    catch { }
                    try
                    {
                        IWebElement         proinfo3   = driver.FindElement(By.XPath("//*[@id='MainContent_Appraisal_GridView3']/tbody"));
                        IList <IWebElement> TRproinfo2 = proinfo3.FindElements(By.TagName("tr"));
                        IList <IWebElement> TDproinfo2;
                        foreach (IWebElement row in TRproinfo2)
                        {
                            TDproinfo2 = row.FindElements(By.TagName("td"));
                            if (TDproinfo2.Count != 0 && TDproinfo2.Count == 7)
                            {
                                ParcelClass      = TDproinfo2[0].Text;
                                NeighborhoodCode = TDproinfo2[2].Text;
                                NeighborhoodName = TDproinfo2[3].Text;
                                NeighborhoodDesc = TDproinfo2[4].Text;
                            }
                        }
                    }
                    catch { }
                    try
                    {
                        IWebElement proinfo4 = driver.FindElement(By.XPath("//*[@id='MainContent_Dwelling_GridView6']/tbody"));
                        driver.ExecuteJavaScript("arguments[0].removeAttribute('style')", proinfo4);
                        proinfo4 = driver.FindElement(By.XPath("//*[@id='MainContent_Dwelling_GridView6']/tbody"));
                        IList <IWebElement> TRproinfo2 = proinfo4.FindElements(By.TagName("tr"));
                        IList <IWebElement> TDproinfo2;
                        foreach (IWebElement row in TRproinfo2)
                        {
                            TDproinfo2 = row.FindElements(By.TagName("td"));
                            if (TDproinfo2.Count != 0 && TDproinfo2.Count == 12)
                            {
                                IWebElement proinfo54 = TDproinfo2[1];
                                driver.ExecuteJavaScript("arguments[0].removeAttribute('style')", proinfo54);
                                YearBuilt = TDproinfo2[1].Text;
                            }
                        }
                    }
                    catch { }

                    try
                    {
                        IWebElement         proinfo5   = driver.FindElement(By.XPath("//*[@id='MainContent_Land_GridView12']/tbody"));
                        IList <IWebElement> TRproinfo2 = proinfo5.FindElements(By.TagName("tr"));
                        IList <IWebElement> TDproinfo2;
                        foreach (IWebElement row in TRproinfo2)
                        {
                            TDproinfo2 = row.FindElements(By.TagName("td"));
                            if (TDproinfo2.Count != 0 && TDproinfo2.Count == 7)
                            {
                                Acreage = TDproinfo2[2].Text;
                            }
                        }
                    }
                    catch { }
                    //Assessed Value Details
                    string AssessdDetails = "", assesstaxyear = "", Taxable = "", Totalvalue = "", Land = "", DwellingandStructure = "", CurrentuseLand = "", Personalprop = "";
                    try
                    {
                        IWebElement         assesinfo1    = driver.FindElement(By.XPath("//*[@id='MainContent_AssessedValue_GridView4']/tbody"));
                        IList <IWebElement> TRassessinfo2 = assesinfo1.FindElements(By.TagName("tr"));
                        IList <IWebElement> TDassessinfo2;
                        foreach (IWebElement row in TRassessinfo2)
                        {
                            TDassessinfo2 = row.FindElements(By.TagName("td"));
                            if (TDassessinfo2.Count != 0 && TDassessinfo2.Count == 7)
                            {
                                assesstaxyear        = TDassessinfo2[0].Text;
                                Taxable              = TDassessinfo2[1].Text;
                                Totalvalue           = TDassessinfo2[2].Text;
                                Land                 = TDassessinfo2[3].Text;
                                DwellingandStructure = TDassessinfo2[4].Text;
                                CurrentuseLand       = TDassessinfo2[5].Text;
                                Personalprop         = TDassessinfo2[6].Text;
                            }
                            AssessdDetails = assesstaxyear.Trim() + "~" + Taxable.Trim() + "~" + Totalvalue.Trim() + "~" + Land.Trim() + "~" + DwellingandStructure.Trim() + "~" + CurrentuseLand.Trim() + "~" + Personalprop.Trim();
                            gc.insert_date(orderNumber, ParcelNumber, 929, AssessdDetails, 1, DateTime.Now);
                        }
                        AssessmentTime = DateTime.Now.ToString("HH:mm:ss");
                    }
                    catch { }
                    //Levy Details
                    string LevyDetails = "", Levyname = "", Levyrate2017 = "", Levyrate2018 = "", Levytype = "", TaxID = "";
                    try
                    {
                        IWebElement         levyinfo1   = driver.FindElement(By.XPath("//*[@id='MainContent_Levy_GridView1']/tbody"));
                        IList <IWebElement> TRlevyinfo2 = levyinfo1.FindElements(By.TagName("tr"));
                        IList <IWebElement> TDlevyinfo2;
                        foreach (IWebElement row in TRlevyinfo2)
                        {
                            TDlevyinfo2 = row.FindElements(By.TagName("td"));
                            if (TDlevyinfo2.Count != 0 && TDlevyinfo2.Count == 5)
                            {
                                Levyname     = TDlevyinfo2[0].Text;
                                Levyrate2017 = TDlevyinfo2[1].Text;
                                Levyrate2018 = TDlevyinfo2[2].Text;
                                Levytype     = TDlevyinfo2[3].Text;
                                TaxID        = TDlevyinfo2[4].Text;
                            }

                            LevyDetails = Levyname.Trim() + "~" + Levyrate2017.Trim() + "~" + Levyrate2018.Trim() + "~" + Levytype.Trim() + "~" + TaxID.Trim();
                            gc.insert_date(orderNumber, ParcelNumber, 932, LevyDetails, 1, DateTime.Now);
                        }
                    }
                    catch { }
                    //Tax Information Details
                    //1.Default Tax Delinquent Scenario
                    try
                    {//MainContent_TaxInfo_lblMsg....There are special circumstances regarding this parcel. Please call (509) 477-4713 for tax information.
                        string defaulttax = driver.FindElement(By.Id("MainContent_TaxInfo_lblMsg")).Text.Trim();
                        if (defaulttax.Contains("There are special circumstances regarding this parcel. Please call (509) 477-4713 for tax information."))
                        {
                            string InformationComments = "For prior tax amount due, you must call (509) 477-4713 the Collector's Office.";
                            string alertmessage        = InformationComments;
                            gc.insert_date(orderNumber, ParcelNumber, 1187, alertmessage, 1, DateTime.Now);
                        }
                    }
                    catch { }
                    string TaxDueDates = "", TaxinformationDetails = "", Propertytaxyear = "", ChargeType = "", AnnualCharges = "", RemainingChargesOwning = "";
                    try
                    {
                        TaxDueDates = driver.FindElement(By.Id("MainContent_TaxInfo_lblTaxDue")).Text.Trim();
                    }
                    catch { }
                    try
                    {
                        IWebElement         taxinfo1    = driver.FindElement(By.XPath("//*[@id='MainContent_TaxInfo_GridView16']/tbody"));
                        IList <IWebElement> TRlevyinfo2 = taxinfo1.FindElements(By.TagName("tr"));
                        IList <IWebElement> TDlevyinfo2;
                        foreach (IWebElement row in TRlevyinfo2)
                        {
                            TDlevyinfo2 = row.FindElements(By.TagName("td"));
                            if (TDlevyinfo2.Count != 0 && TDlevyinfo2.Count == 4)
                            {
                                Propertytaxyear        = TDlevyinfo2[0].Text;
                                ChargeType             = TDlevyinfo2[1].Text;
                                AnnualCharges          = TDlevyinfo2[2].Text;
                                RemainingChargesOwning = TDlevyinfo2[3].Text;
                            }
                            TaxinformationDetails = Propertytaxyear.Trim() + "~" + ChargeType.Trim() + "~" + AnnualCharges.Trim() + "~" + RemainingChargesOwning.Trim();
                            gc.insert_date(orderNumber, ParcelNumber, 933, TaxinformationDetails, 1, DateTime.Now);
                        }
                        if (TaxDueDates != "")
                        {
                            gc.insert_date(orderNumber, ParcelNumber, 933, "" + "~" + TaxDueDates.Trim() + "~" + "" + "~" + "", 1, DateTime.Now);
                        }
                    }
                    catch
                    {
                    }


                    //Tax Payment History Details
                    string TaxpaymentHistoryDetails = "", paymenttaxyear = "", receiptnumber = "", receiptdate = "", receiptamount = "";
                    try
                    {
                        IWebElement         taxpayment1     = driver.FindElement(By.XPath("//*[@id='MainContent_TaxInfo_GridView17']/tbody"));
                        IList <IWebElement> TRpayment1info2 = taxpayment1.FindElements(By.TagName("tr"));
                        IList <IWebElement> TDpayment1info2;
                        foreach (IWebElement row in TRpayment1info2)
                        {
                            TDpayment1info2 = row.FindElements(By.TagName("td"));
                            if (TDpayment1info2.Count != 0 && TDpayment1info2.Count == 5)
                            {
                                paymenttaxyear = TDpayment1info2[0].Text;
                                receiptnumber  = TDpayment1info2[1].Text;
                                receiptdate    = TDpayment1info2[2].Text;
                                receiptamount  = TDpayment1info2[3].Text;
                            }
                            TaxpaymentHistoryDetails = paymenttaxyear.Trim() + "~" + receiptnumber.Trim() + "~" + receiptdate.Trim() + "~" + receiptamount.Trim();
                            gc.insert_date(orderNumber, ParcelNumber, 940, TaxpaymentHistoryDetails, 1, DateTime.Now);
                        }
                    }
                    catch
                    {
                    }
                    //Last Three Revaluation Notice details

                    try
                    {
                        string taxurl = driver.FindElement(By.XPath("//*[@id='bs-example-navbar-collapse-1']/ul/li[3]/a")).GetAttribute("href");
                        driver.Navigate().GoToUrl(taxurl);
                        gc.CreatePdf(orderNumber, ParcelNumber, " Last Three Year Revaluation Notice details", driver, "WA", "Spokane");
                    }
                    catch
                    {
                    }

                    string fileName1 = "", fileName2 = "";
                    try
                    {
                        // int pcount = 1,Ocount=3;
                        var chromeOptions     = new ChromeOptions();
                        var downloadDirectory = ConfigurationManager.AppSettings["AutoPdf"];
                        chromeOptions.AddUserProfilePreference("download.default_directory", downloadDirectory);
                        chromeOptions.AddUserProfilePreference("download.prompt_for_download", false);
                        chromeOptions.AddUserProfilePreference("disable-popup-blocking", "true");
                        chromeOptions.AddUserProfilePreference("plugins.always_open_pdf_externally", true);
                        var driver1 = new ChromeDriver(chromeOptions);
                        driver1.Navigate().GoToUrl(driver.Url);

                        // driver1.Navigate().GoToUrl("https://cp.spokanecounty.org/scout/propertyinformation/");
                        driver1.FindElement(By.Id("txtSearch")).SendKeys(ParcelNumber);
                        driver1.FindElement(By.Id("MainContent_btnSearch")).SendKeys(Keys.Enter);
                        driver1.FindElement(By.LinkText("Notices")).SendKeys(Keys.Enter);
                        string current = driver1.CurrentWindowHandle;

                        //IWebElement Receipttable = driver1.FindElement(By.XPath("//*[@id='MainContent_GridView1']/tbody/tr[1]/td/a"));
                        //string BillTax2 = Receipttable.GetAttribute("href");

                        //Receipttable.Click();



                        fileName1 = "ImageOutput";
                        int                 pcount = 0, Ocount = 0;
                        IWebElement         IParcelAssess     = driver1.FindElement(By.Id("MainContent_GridView1"));
                        IList <IWebElement> IParcelAssessList = IParcelAssess.FindElements(By.TagName("a"));
                        foreach (IWebElement parcel in IParcelAssessList)
                        {
                            if (parcel.Text.Contains("Parcel Assessment Notice") && pcount < 3)
                            {
                                parcel.Click();
                                Thread.Sleep(10000);
                                gc.AutoDownloadFileSpokane(orderNumber, ParcelNumber, "Spokane", "WA", fileName1 + ".pdf");
                                driver1.SwitchTo().Window(driver1.WindowHandles.Last());
                                gc.CreatePdf(orderNumber, ParcelNumber, "Parcel Assessment Notice" + pcount, driver1, "WA", "Spokane");
                                pcount++;
                                driver1.SwitchTo().Window(current);
                            }
                        }
                        driver1.SwitchTo().Window(current);
                        //fileName2 = "ImageOutput.pdf";
                        IWebElement         IOriginalTax     = driver1.FindElement(By.Id("MainContent_GridView2"));
                        IList <IWebElement> IOriginalTaxList = IOriginalTax.FindElements(By.TagName("a"));
                        foreach (IWebElement Original in IOriginalTaxList)
                        {
                            if (Original.Text.Contains("Original Tax Statement") && Ocount < 3)
                            {
                                Original.Click();
                                Thread.Sleep(10000);
                                gc.AutoDownloadFileSpokane(orderNumber, ParcelNumber, "Spokane", "WA", fileName1 + ".pdf");
                                driver1.SwitchTo().Window(driver1.WindowHandles.Last());
                                gc.CreatePdf(orderNumber, ParcelNumber, "Original Tax Statement" + Ocount, driver1, "WA", "Spokane");
                                Ocount++;
                                driver1.SwitchTo().Window(current);
                            }
                        }
                        driver1.Quit();
                    }
                    catch { }

                    //Tax Authority
                    string Taxauthority1 = "", Taxauthority2 = "";
                    try
                    {
                        driver.Navigate().GoToUrl("https://www.spokanecounty.org/Directory.aspx?did=62");
                        gc.CreatePdf(orderNumber, ParcelNumber, "TaxAuthority Pdf", driver, "WA", "Spokane");
                        Taxauthority1 = driver.FindElement(By.XPath("//*[@id='CityDirectoryLeftMargin']/span[1]/p[1]")).Text;
                        Taxauthority2 = driver.FindElement(By.XPath("//*[@id='CityDirectoryLeftMargin']/span[1]/p[3]")).Text;
                        TaxAuthority  = Taxauthority1 + " Phone:   " + Taxauthority2;
                    }
                    catch { }

                    if (OwnerName != "" && ParcelNumber != "")
                    {
                        PropertyDetails = OwnerName.Trim() + "~" + OwnerAddress1 + "~" + TaxpayerName.Trim() + "~" + TaxPayerAddress.Trim() + "~" + ParcelType.Trim() + "~" + SiteAddress.Trim() + "~" + City.Trim() + "~" + Description.Trim() + "~" + TaxCodeArea.Trim() + "~" + Status.Trim() + "~" + ParcelClass.Trim() + "~" + NeighborhoodCode.Trim() + "~" + NeighborhoodName.Trim() + "~" + NeighborhoodDesc.Trim() + "~" + YearBuilt.Trim() + "~" + Acreage.Trim() + "~" + TaxAuthority;
                        gc.insert_date(orderNumber, ParcelNumber, 927, PropertyDetails, 1, DateTime.Now);
                    }

                    TaxTime = DateTime.Now.ToString("HH:mm:ss");
                    driver.Quit();
                    gc.mergpdf(orderNumber, "WA", "Spokane");
                    LastEndTime = DateTime.Now.ToString("HH:mm:ss");
                    gc.insert_TakenTime(orderNumber, "WA", "Spokane", StartTime, AssessmentTime, TaxTime, CitytaxTime, LastEndTime);
                    return("Data Inserted Successfully");
                }
                catch (Exception ex)
                {
                    driver.Quit();
                    GlobalClass.LogError(ex, orderNumber);
                    throw ex;
                }
            }
        }
コード例 #14
0
        public void ParrotNameSite_FormFillWithEmail_CorrectEmail()
        {
            driver.Navigate().GoToUrl(url);

            driver.FindElement(emailInputLocator).SendKeys(expectedEmail);
            driver.FindElement(buttonLocator).Click();

            Assert.AreEqual(expectedEmail, driver.FindElement(emailResultLocator).Text, "Сделали заявку не на тот e-mail");
        }
コード例 #15
0
        public void CadastraSinistro()
        {
            #region Abrir o Chrome
            //inicializando o chrome
            IWebDriver driver = new ChromeDriver();
            driver.Navigate().GoToUrl("http://main.safety8.local/#/login?cnpj=72.408.271%2F0001-91");
            driver.Manage().Window.Maximize();
            System.Threading.Thread.Sleep(3000);
            #endregion

            #region Login
            var cnpj = driver.FindElement(By.Id("cnpj"));
            cnpj.SendKeys("72408271000191");
            {
                var     elemento = driver.FindElement(By.CssSelector(".logo-login-q"));
                Actions builder  = new Actions(driver);
                builder.MoveToElement(elemento).ClickAndHold().Perform();
            }
            {
                var     elemento = driver.FindElement(By.CssSelector(".efeitoOverlay"));
                Actions builder  = new Actions(driver);
                builder.MoveToElement(elemento).Release().Perform();
            }
            driver.FindElement(By.CssSelector(".container-fluid")).Click();
            driver.FindElement(By.CssSelector(".ng-scope > .animated")).Click();
            {
                var dropdown = driver.FindElement(By.CssSelector(".ng-scope > .animated"));
                dropdown.FindElement(By.XPath("/html/body/div[5]/div[2]/div[2]/div/div/div/div/div/div[2]/div[2]/select/option[3]")).Click();
                //driver.Quit();
            }
            Login login = new Login();

            driver.FindElement(By.CssSelector(".ng-scope > .animated")).Click();
            driver.FindElement(By.Id("usuario")).Click();
            driver.FindElement(By.Id("usuario")).SendKeys(login.RetornaUsuario());
            driver.FindElement(By.Id("senha")).SendKeys(login.RetornaSenha());
            driver.FindElement(By.CssSelector(".button-login-q")).Click();
            #endregion

            #region Cadastrar Sinistro
            //Seleciona o campo de busca
            System.Threading.Thread.Sleep(3000);
            driver.FindElement(By.XPath("/html/body/div[5]/div[2]/div[3]/div[4]/div[1]/vs-portal-consultas-directive/div/div/div/div[3]/div")).Click();
            driver.FindElement(By.XPath("/html/body/div[5]/div[2]/div[3]/div[4]/div[1]/vs-portal-consultas-directive/div/div/div/div[3]/div/input")).SendKeys("fausto silva");

            //Clicar no busca
            driver.FindElement(By.CssSelector("div:nth-child(5) > div.container-fluid > div:nth-child(3) > div.index-conteudo.ng-scope.animated.fadeIn.conteudo-geral > div:nth-child(1) > vs-portal-consultas-directive > div > div > div > div:nth-child(3) > div > span > button")).Click();

            //Seleciona o cliente na lista
            System.Threading.Thread.Sleep(5000);//Aguardando a pagina carregar
            driver.FindElement(By.CssSelector("div:nth-child(5) > div.container-fluid > div:nth-child(3) > div.index-conteudo.ng-scope.animated.fadeIn.conteudo-geral > div > div > div.col-sm-12.col-lg-9 > div > div > div:nth-child(2) > div.col-lg-12.col-md-12.col-sm-12 > div > div.card-body.card-padding.ng-scope > div > div:nth-child(1) > div > h3 > a")).Click();

            //Clicar em seguros
            System.Threading.Thread.Sleep(3000);//Aguardando a pagina carregar
            driver.FindElement(By.XPath("/html/body/div[5]/div[1]/nav/div[3]/div/vs-menu-responsivo/div/div[2]/div/div/ul/li[2]/a")).Click();

            //Acessar um documento
            System.Threading.Thread.Sleep(3000);
            driver.FindElement(By.CssSelector("tbody > tr.odd > td:nth-child(1) > button")).Click();

            //Clicar em sinistros
            System.Threading.Thread.Sleep(3000);
            driver.FindElement(By.CssSelector("div.col-xs-10.col-sm-10.col-lg-10.tab-menu-topo > div > vs-menu-responsivo > div > div.scrtabs-tabs-fixed-container > div > div > ul > li:nth-child(2) > a")).Click();

            //Clicar em incluir
            System.Threading.Thread.Sleep(3000);
            driver.FindElement(By.CssSelector(".btn-raised")).Click();
            driver.ExecuteJavaScript("window.scroll(0,100)");

            //Clicar em data do sinistro
            System.Threading.Thread.Sleep(3000);
            driver.FindElement(By.Name("frmAutoFormdocumentosSinistrosundefined_edt_sin_data_sinistro")).Click();
            driver.FindElement(By.CssSelector(".today")).Click();

            //Gravar
            driver.FindElement(By.CssSelector("div:nth-child(2) > .botoes-bottom-verde")).Click();
            #endregion
            MetodosNavega.SairPlus(driver);

            driver.Quit();
        }
コード例 #16
0
        static void Main(string[] args)
        {
            //Create reference of browser
            IWebDriver driver = new ChromeDriver();

            //Create reference for interactions with browser
            Actions action = new Actions(driver);

            //Maximize browser window
            driver.Manage().Window.Maximize();

            //To Delay execution for 02 sec. as to view the resize browser
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromMinutes(1));

            try
            {
                #region REGISTER
                //------------------Navigate to the Nopcommerce Registration Page-------------------------------
                driver.Navigate().GoToUrl("http://nop1.ysoftsolution.com/register");
                Thread.Sleep(2000);

                //gender: By.Class = 'gender';
                driver.FindElement(By.XPath("//input[@type='radio'][@name='Gender']")).Click();
                Thread.Sleep(2000);

                //FirstName element
                IWebElement elementfirstName = driver.FindElement(By.Id("FirstName"));
                elementfirstName.SendKeys("Test First Name");
                Thread.Sleep(2000);

                //LastName element
                IWebElement elementlastName = driver.FindElement(By.Id("LastName"));
                elementlastName.SendKeys("Test Last Name");
                Thread.Sleep(2000);

                //Date of birth element
                var txtBirDay = driver.FindElement(By.Name("DateOfBirthDay"));
                action.ClickAndHold(txtBirDay).SendKeys("03").Perform();
                Thread.Sleep(2000);

                var txtBirMonth = driver.FindElement(By.Name("DateOfBirthMonth"));
                action.ClickAndHold(txtBirMonth).SendKeys("March").Perform();
                Thread.Sleep(2000);

                var txtBirYear = driver.FindElement(By.Name("DateOfBirthYear"));
                action.ClickAndHold(txtBirYear).SendKeys("2020").Perform();
                Thread.Sleep(2000);

                //email element
                IWebElement elementEmail = driver.FindElement(By.Id("Email"));
                elementEmail.SendKeys("*****@*****.**");
                Thread.Sleep(2000);

                //Comapny element
                IWebElement elementCompany = driver.FindElement(By.Id("Company"));
                elementCompany.SendKeys("TESTING COMPANY");
                Thread.Sleep(2000);

                //NewsLetter element- uncheck as by Default : Checked
                driver.FindElement(By.Id("Newsletter")).Click();
                Thread.Sleep(2000);


                //Password element
                IWebElement elementPassword = driver.FindElement(By.Id("Password"));
                elementPassword.SendKeys("test@123");
                Thread.Sleep(2000);

                //ConfirmPassword element
                IWebElement elementConfirmPassword = driver.FindElement(By.Id("ConfirmPassword"));
                elementConfirmPassword.SendKeys("test@123");
                Thread.Sleep(2000);


                //Click on Submit button : id 'register-button'
                driver.FindElement(By.Id("register-button")).Click();
                //To Delay execution for 02 sec. as to view the resize browser
                wait = new WebDriverWait(driver, TimeSpan.FromMinutes(2));
                Thread.Sleep(2000);


                //After successfully registered click on Continue button.
                driver.FindElement(By.Id("register-continue")).Click();
                Thread.Sleep(2000);

                //Logout
                driver.FindElement(By.XPath("//a[text()='Log out']")).Click();
                Thread.Sleep(2000);
                #endregion


                //-------------------------Navigate to the Nopcommerce LOGIN Page-----------------------------

                #region LOGIN

                //wait = new WebDriverWait(driver, TimeSpan.FromMinutes(2));
                driver.Navigate().GoToUrl("http://nop1.ysoftsolution.com/login");
                Thread.Sleep(2000);

                //LOGIN EMAIL
                driver.FindElement(By.XPath("//input[@type='email'][@name='Email']")).SendKeys("*****@*****.**");
                Thread.Sleep(2000);

                //LOGIN Password
                driver.FindElement(By.XPath("//input[@type='password'][@name='Password']")).SendKeys("test@123");
                Thread.Sleep(2000);


                //RememberMe
                driver.FindElement(By.XPath("//label[text()='Remember me?']")).Click();
                Thread.Sleep(2000);


                //Login
                driver.FindElement(By.XPath("//input[@type='submit'][@value='Log in']")).Click();
                Thread.Sleep(2000);

                #endregion


                //------------Forgot Password------------------

                #region RECOVERY / Forgot Pasword
                //Navigate to Recovery Page
                driver.Navigate().GoToUrl("http://nop1.ysoftsolution.com/passwordrecovery");
                Thread.Sleep(2000);

                //Email
                driver.FindElement(By.Id("Email")).SendKeys("*****@*****.**");
                Thread.Sleep(2000);

                //Recover button
                driver.FindElement(By.XPath("//input[@type='submit'][@name='send-email']")).Click();
                Thread.Sleep(2000);
                #endregion


                //----------Search-------------

                #region SEARCH PRODUCT
                //Navigate to home Page
                driver.Navigate().GoToUrl("http://nop1.ysoftsolution.com/");
                Thread.Sleep(2000);

                //Search element with keyword searching -'Apple MacBook Pro 13-inch'
                driver.FindElement(By.XPath("//input[@type='text'][@name='q']")).SendKeys("Apple MacBook Pro 13-inch");
                wait = new WebDriverWait(driver, TimeSpan.FromMinutes(2));
                Thread.Sleep(2000);

                //Click on Search Button
                driver.FindElement(By.XPath("//text()[.='Search']/ancestor::a[1]")).Click();
                Thread.Sleep(2000);

                //Click on searched Product
                driver.FindElement(By.XPath("//a[text()='Apple MacBook Pro 13-inch']")).Click();
                //driver.Navigate().GoToUrl("http://nop1.ysoftsolution.com/apple-macbook-pro-13-inch");
                Thread.Sleep(2000);

                //Product Images
                driver.FindElement(By.XPath("/html[1]/body[1]/div[6]/div[3]/div[2]/div[1]/div[1]/div[1]/form[1]/div[1]/div[1]/div[1]/div[2]/div[3]/img[1]")).Click();
                Thread.Sleep(2000);

                driver.FindElement(By.XPath("/html[1]/body[1]/div[6]/div[3]/div[2]/div[1]/div[1]/div[1]/form[1]/div[1]/div[1]/div[1]/div[2]/div[2]/img[1]")).Click();
                Thread.Sleep(2000);
                #endregion
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                driver.Dispose();
                //Close the browser
                driver.Quit();
            }
        }
コード例 #17
0
        static void Main(string[] args)
        {
            //ChromeOptions options = new ChromeOptions();
            //options.AddArgument("--user-data-dir=C:/Users/Administrator/AppData/Local/Google/Chrome/User Data/Default");



            IWebDriver selenium = new ChromeDriver();

            selenium.Manage().Window.Maximize();
            selenium.Navigate().GoToUrl("https://www.baidu.com");
            System.Threading.Thread.Sleep(1000);

            selenium.FindElement(By.Name("wd")).SendKeys("金属徽章工艺厂家直销");
            System.Threading.Thread.Sleep(1000);
            selenium.FindElement(By.Id("su")).Click();

            int page = 0;

            ck_keyword : System.Threading.Thread.Sleep(2000);
            page++;
            bool isshowpage            = false;
            IJavaScriptExecutor js     = (IJavaScriptExecutor)selenium;
            Actions             action = new Actions(selenium);

            IList <IWebElement> listOption = selenium.FindElements(By.TagName("h3"));

            string find_title = "金属徽章工艺厂家直销 苍南金属徽章工艺厂家直销价格可定制批发";

            foreach (var item in listOption)
            {
                System.Drawing.Point pt = item.Location;

                if (pt.Y > 600)
                {
                    js.ExecuteScript("window.scrollTo(0, " + (pt.Y - 176) + ");");
                    System.Threading.Thread.Sleep(1000);
                }

                if (find_title.Contains(item.Text.Replace("...", "").Trim()))
                {
                    item.Click();
                    isshowpage = true;
                    break;
                }

                //item.Click();

                //action.MoveByOffset(130,80).Build().Perform();

                //System.Threading.Thread.Sleep(1000);
                //action.Click();
            }

            if (!isshowpage && page < 3)
            {
                selenium.FindElement(By.Id("page")).FindElements(By.ClassName("n"))[0].Click();
                goto ck_keyword;
            }

            //selenium.Close();
            //selenium.Quit();

            Console.ReadLine();
        }
コード例 #18
0
ファイル: Class1.cs プロジェクト: randaeltaher/QAtask
        public void TestMethod()
        {
            //using Chrome as browser
            IWebDriver driver = new ChromeDriver();

            //go to Orange HRM
            driver.Url = "https://opensource-demo.orangehrmlive.com";


            //Login
            IWebElement elementUsername = driver.FindElement(By.Id("txtUsername"));

            elementUsername.SendKeys("admin");
            IWebElement elementPassword = driver.FindElement(By.Id("txtPassword"));

            elementPassword.SendKeys("admin123");
            IWebElement elementLogin = driver.FindElement(By.Name("Submit"));

            elementLogin.Click();

            //User Management via Admin tab
            IWebElement elementAdmin = driver.FindElement(By.Id("menu_admin_viewAdminModule"));

            elementAdmin.Click();

            //Filling the search data
            //Username
            IWebElement elementUsernameSystem = driver.FindElement(By.Id("searchSystemUser_userName"));

            elementUsernameSystem.SendKeys("admin");

            //User Role
            IWebElement selectDropDownListUserRole = driver.FindElement(By.Id("searchSystemUser_userType"));

            new SelectElement(selectDropDownListUserRole).SelectByValue("1");

            //Search
            IWebElement elementSearch = driver.FindElement(By.Id("searchBtn"));

            elementSearch.Click();

            //Reset
            IWebElement elementReset = driver.FindElement(By.Id("resetBtn"));

            elementReset.Click();

            //Add User
            IWebElement elementAdd = driver.FindElement(By.Name("btnAdd"));

            elementAdd.Click();

            //Add user
            //Role
            Thread.Sleep(1000);
            IWebElement selectDropDownListAddRole = driver.FindElement(By.Id("systemUser_userType"));

            new SelectElement(selectDropDownListAddRole).SelectByValue("2");

            //Name
            Thread.Sleep(1000);
            IWebElement elementAddName = driver.FindElement(By.Id("systemUser_employeeName_empName"));

            elementAddName.SendKeys("lahanta");
            Thread.Sleep(1000);
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromMinutes(1));

            wait.Until(ExpectedConditions.ElementExists(By.ClassName("ac_results")));

            IWebElement elementlist = driver.FindElement(By.ClassName("ac_results"));

            elementlist.Click();

            //Username
            IWebElement elementAddSystemUserName = driver.FindElement(By.Id("systemUser_userName"));

            elementAddSystemUserName.SendKeys("lahanta.smith");

            //Password
            IWebElement elementAddSystemPassword = driver.FindElement(By.Id("systemUser_password"));

            elementAddSystemPassword.SendKeys("P@ssw0rd1===");

            //Confirm Password
            IWebElement elementAddSystemConfirmPassword = driver.FindElement(By.Id("systemUser_confirmPassword"));

            elementAddSystemConfirmPassword.SendKeys("P@ssw0rd1===");

            //Try to cancel
            //Thread.Sleep(1000);
            //IWebElement elementCancel = driver.FindElement(By.Id("btnCancel"));
            //elementCancel.Click();


            //Save button
            Thread.Sleep(1000);
            IWebElement elementSave = driver.FindElement(By.Id("btnSave"));

            elementSave.Click();

            Thread.Sleep(2000);

            //Close the browser
            driver.Close();
        }
コード例 #19
0
        public void CadastroCredencial()
        {
            #region Abrir o Chrome
            //inicializando o chrome
            IWebDriver driver = new ChromeDriver();
            driver.Navigate().GoToUrl("http://main.safety8.local/#/login?cnpj=72.408.271%2F0001-91");
            driver.Manage().Window.Maximize();
            System.Threading.Thread.Sleep(3000);
            #endregion

            #region Login
            var cnpj = driver.FindElement(By.Id("cnpj"));
            cnpj.SendKeys("72408271000191");
            {
                var     elemento = driver.FindElement(By.CssSelector(".logo-login-q"));
                Actions builder  = new Actions(driver);
                builder.MoveToElement(elemento).ClickAndHold().Perform();
            }
            {
                var     elemento = driver.FindElement(By.CssSelector(".efeitoOverlay"));
                Actions builder  = new Actions(driver);
                builder.MoveToElement(elemento).Release().Perform();
            }
            driver.FindElement(By.CssSelector(".container-fluid")).Click();
            driver.FindElement(By.CssSelector(".ng-scope > .animated")).Click();
            {
                var dropdown = driver.FindElement(By.CssSelector(".ng-scope > .animated"));
                dropdown.FindElement(By.XPath("/html/body/div[5]/div[2]/div[2]/div/div/div/div/div/div[2]/div[2]/select/option[3]")).Click();
                //driver.Quit();
            }

            driver.FindElement(By.CssSelector(".ng-scope > .animated")).Click();
            driver.FindElement(By.Id("usuario")).Click();
            driver.FindElement(By.Id("usuario")).SendKeys("francisco");
            driver.FindElement(By.Id("senha")).SendKeys("F123456");
            driver.FindElement(By.CssSelector(".button-login-q")).Click();
            #endregion

            #region Menu
            // Clica Menu Lateral
            System.Threading.Thread.Sleep(2000);//Para aguardar a tela carregar
            driver.FindElement(By.Id("botaoMenu")).Click();
            // Usando o menu pesquisa
            System.Threading.Thread.Sleep(2000);
            driver.FindElement(By.Id("pesquisaMenu")).SendKeys("Senhas");
            driver.FindElement(By.CssSelector("div:nth-child(3) > ul > li > a")).Click();
            // Espera para carregar
            System.Threading.Thread.Sleep(2000);

            driver.FindElement(By.CssSelector("div:nth-child(3) > ul > li > div > ul > li > a")).Click();
            System.Threading.Thread.Sleep(2000);
            //Armazena o ID da janela
            string originalWindow = driver.CurrentWindowHandle;
            // Verifica se tem mais janelas abertas
            Assert.AreEqual(driver.WindowHandles.Count, 1);
            // Clica em "Acessar Central de Senhas" |
            System.Threading.Thread.Sleep(2000);
            driver.FindElement(By.CssSelector("div:nth-child(3) > ul > li > div > ul > li > div > ul > li > a")).Click();
            #endregion

            #region Abrir a Central de Senhas
            System.Threading.Thread.Sleep(2000);
            //Loop até achar a nova guia
            foreach (string window in driver.WindowHandles)
            {
                if (originalWindow != window)
                {
                    driver.SwitchTo().Window(window);
                    break;
                }
            }
            // Seleciona Bradesco
            System.Threading.Thread.Sleep(12000);
            driver.FindElement(By.XPath("/html/body/div[2]/div[2]/div[1]/div[1]/div[2]/div/div[10]/div")).Click();
            // Clica em incluir
            System.Threading.Thread.Sleep(2000);
            driver.FindElement(By.CssSelector(".icone-redondo")).Click();
            //
            driver.FindElement(By.CssSelector(".col-lg-12 > .ng-pristine .form-control")).Click();
            // Clica em descrição
            driver.FindElement(By.CssSelector("div:nth-child(2) > div:nth-child(2) > div.col-lg-8.ng-scope > div:nth-child(1) > div > div > div > div.card-body.card-padding.row > div:nth-child(1) > vs-editavel3 > div > input")).SendKeys("ROBO TESTE");
            // Clica em usuario |
            driver.FindElement(By.CssSelector(".col-lg-6 .ng-valid-maxlength")).Click();
            // Informa o usuario | 06564836953
            driver.FindElement(By.CssSelector(".col-lg-6 .ng-valid-maxlength")).SendKeys("06564836953");
            // Clica em senha |
            driver.FindElement(By.CssSelector(".ng-scope > .form-control-wrapper > .form-control")).Click();
            // Informa Senha | B115087F
            driver.FindElement(By.CssSelector(".ng-scope > .form-control-wrapper > .form-control")).SendKeys("B115087F");
            // Clica em situação |id=comboundefined |
            driver.FindElement(By.Id("comboundefined")).Click();
            // Seleciona Ativo |linkText=Ativo |
            driver.FindElement(By.LinkText("Ativo")).Click();
            // Clica em Produtor |
            driver.FindElement(By.CssSelector(".ng-scope > .ng-pristine #comboundefined")).Click();
            // Seleciona Produtor
            driver.FindElement(By.LinkText("Produtor")).Click();
            //
            driver.FindElement(By.CssSelector(".ng-scope:nth-child(2) > .card-virtual .icone-redondo")).Click();
            //
            driver.FindElement(By.CssSelector(".col-lg-5 .form-control")).Click();
            //
            driver.FindElement(By.CssSelector(".col-lg-5 .form-control")).SendKeys("425792-643");
            // Clica Inspetoria |
            driver.FindElement(By.CssSelector("div:nth-child(2) > div:nth-child(2) > div.col-lg-8.ng-scope > div:nth-child(2) > div > div.card-body.card-padding.row > div > vs-editavel3:nth-child(2) > div > input")).Click();
            // Informa Inspetoria
            driver.FindElement(By.CssSelector("div:nth-child(2) > div:nth-child(2) > div.col-lg-8.ng-scope > div:nth-child(2) > div > div.card-body.card-padding.row > div > vs-editavel3:nth-child(2) > div > input")).SendKeys("018");
            // Salva
            driver.FindElement(By.CssSelector(".btn:nth-child(1) > .visible-lg")).Click();
            #endregion
        }
コード例 #20
0
ファイル: Test12.cs プロジェクト: siar0/test-NunitProject
        public void TestMethod()
        {
            LoginAdminUser();
            driver.Url = "http://localhost/litecart/admin/?app=catalog&doc=catalog";
            driver.FindElement(By.XPath("//*[@id=\"content\"]/div[1]/a[2]")).Click();
            var productName = FillGeneralTab();

            driver.FindElement(By.XPath("//*[@id=\"content\"]/form/div/ul/li[2]/a")).Click();
            FillInformationTab();
            driver.FindElement(By.XPath("//*[@id=\"content\"]/form/div/ul/li[4]/a")).Click();
            FillPricesTab();
            Assert.IsTrue(IsProductAdded(productName));
        }
コード例 #21
0
        public void GetAppointment()
        {
            //var mDriver = new ChromeDriver("D:\\src\\ChromeWebDriver\\MacOS");
            var mDriver = new ChromeDriver("/Volumes/Storage/src/ChromeWebDriver/MacOs");

            mDriver.Url = "https://burghquayregistrationoffice.inis.gov.ie/Website/AMSREG/AMSRegWeb.nsf/AppSelect?OpenForm";
            mDriver.Manage().Window.Maximize();

            mDriver.FindElement(By.XPath("//select[@id='Category']/option[contains(.,'All')]")).Click();
            mDriver.FindElement(By.XPath("//select[@id='SubCategory']/option[contains(.,'All')]")).Click();
            mDriver.FindElement(By.XPath("//select[@id='ConfirmGNIB']/option[contains(.,'Yes')]")).Click();

            var gnibNo = mDriver.FindElement(By.Id("GNIBNo"));

            gnibNo.Clear();
            gnibNo.SendKeys("847198");

            var gnibExDt = mDriver.FindElement(By.Id("GNIBExDT"));

            ((IJavaScriptExecutor)mDriver).ExecuteScript("arguments[0].value='07/01/2020'", gnibExDt);

            mDriver.FindElement(By.XPath("//input[@id='UsrDeclaration']")).Click();

            mDriver.FindElement(By.XPath("//input[@id='GivenName']")).SendKeys("Erdem");
            mDriver.FindElement(By.XPath("//input[@id='SurName']")).SendKeys("Kemer");

            var dob = mDriver.FindElement(By.Id("DOB"));

            ((IJavaScriptExecutor)mDriver).ExecuteScript("arguments[0].value='09/05/1983'", dob);

            mDriver.FindElement(By.XPath("//select[@id='Nationality']/option[contains(.,'Turkey, Republic of')]")).Click();

            mDriver.FindElement(By.XPath("//input[@id='Email']")).SendKeys("*****@*****.**");
            mDriver.FindElement(By.XPath("//input[@id='EmailConfirm']")).SendKeys("*****@*****.**");

            mDriver.FindElement(By.XPath("//select[@id='FamAppYN']/option[contains(.,'Yes')]")).Click();

            mDriver.FindElement(By.XPath("//select[@id='FamAppNo']/option[contains(.,'2')]")).Click();

            mDriver.FindElement(By.XPath("//select[@id='PPNoYN']/option[contains(.,'Yes')]")).Click();

            mDriver.FindElement(By.XPath("//input[@id='PPNo']")).SendKeys("U06114646");

            mDriver.FindElement(By.XPath("//button[@id='btLook4App']")).Click();

            mDriver.FindElement(By.XPath("//select[@id='AppSelectChoice']/option[contains(.,'closest to today')]")).Click();

            mDriver.FindElement(By.XPath("//button[@id='btSrch4Apps']")).Click();

            var table = mDriver.FindElement(By.XPath("//div[@id='dvAppOptions']"));
            ICollection <IWebElement> appointments = table.FindElements(By.XPath("//div[@class='appOption']"));

            foreach (var appointment in appointments)
            {
                var button = appointment.FindElement(By.XPath("//button"));
                var date   = appointment.FindElement(By.XPath("//td[2]"));

                var         appDate         = date.GetAttribute("innerText").ToLower();
                var         exactDate       = appDate.Substring(0, appDate.IndexOf('-')).Trim();
                CultureInfo provider        = CultureInfo.InvariantCulture;
                var         exactDateInDate = DateTime.ParseExact(exactDate, "d MMMM yyyy", provider);

                Console.WriteLine($"Found the reservation on {exactDateInDate.ToShortDateString()}");
                if ((exactDateInDate - DateTime.Today).TotalDays < 35)
                {
                    Console.WriteLine($"Booking the reservation on {exactDateInDate.ToShortDateString()}");
                    ((IJavaScriptExecutor)mDriver).ExecuteScript("window.focus();");
                    break;
                }
            }

            Console.Read();
            mDriver.Quit();
        }
コード例 #22
0
ファイル: Program.cs プロジェクト: wnmwi/SeleniumDemo
        static void Main(string[] args)
        {
            var options = new ChromeOptions();

            options.AddArgument("--user-data-dir=C:/Users/Yang/AppData/Local/Google/Chrome/User Data"); //置顶用户文件夹路径
            options.AddArgument("--profile-directory=Default");                                         //指定用户
            //m_Options.AddArgument("--disable-extensions"); //禁用插件
            using (var driver = new ChromeDriver(@"D:\WebDriver\bin", options))                         //声明chrome驱动器
            {
                driver.Navigate().GoToUrl("https://member.bilibili.com/platform/upload/video/frame");   //跳转网址

                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
                wait.Until(wb => wb.FindElements(By.TagName("iframe")).Count() > 0);
                driver.SwitchTo().Frame(1);
                IWebElement firstResult = wait.Until(wb => wb.FindElement(By.Id("bili-upload-btn"))); //查找上传按钮
                Thread.Sleep(100);                                                                    //bili需要等待资源加载
                firstResult.Click();                                                                  //点击上传按钮

                Thread.Sleep(1000);

                IntPtr hWnd = FindWindow(null, "打开");
                //var result = GetAllChildrenWindowHandles(hWnd, 100);
                if (hWnd != null && hWnd != new IntPtr(0))
                {
                    uint   WM_SETTEXT = 0xC;
                    IntPtr textHwnd   = FindWindowEx(hWnd, IntPtr.Zero, null, "文件名(&N):"); //获取文件名lable句柄
                    IntPtr editor     = FindWindowEx(hWnd, textHwnd, null, null);          //获取文本框句柄(位于文件名lable后)
                    SendMessage(editor, WM_SETTEXT, IntPtr.Zero, @"E:\地球频道\2.videos\20210402毅力号自拍\导出.mp4");
                    Thread.Sleep(100);

                    IntPtr childHwnd = FindWindowEx(hWnd, IntPtr.Zero, null, "打开(&O)"); //获取按钮的句柄
                    if (childHwnd != IntPtr.Zero)
                    {
                        SendMessage(childHwnd, 0xF5, 0, 0);  //鼠标点击的消息,对于各种消息的数值,大家还是得去API手册
                    }

                    IWebElement imgElement = wait.Until(wb => wb.FindElement(By.CssSelector("#app > div.upload-v2-container > div.upload-v2-step2-container > div.file-content-v2-container > div.normal-v2-container > div.cover-v2-container > div.cover-v2-detail-wrp > div.cover-v2-preview > input[type=file]")));
                    imgElement.SendKeys(@"E:\地球频道\2.videos\20200809\vlcsnap-2020-08-09-23h21m21s931.png");

                    wait.Until(wb => wb.FindElement(By.CssSelector("#app > div.common-modal-container > div > div.common-modal-foot > div > div > div:nth-child(1)"))).Click();

                    IWebElement titleElement = driver.FindElement(By.CssSelector("#app > div.upload-v2-container > div.upload-v2-step2-container > div.file-content-v2-container > div.normal-v2-container > div.content-title-v2-container > div.content-title-v2-input-wrp > div > div > input"));
                    titleElement.Clear();
                    titleElement.SendKeys("我是标题");

                    //分类
                    //wait.Until(wb => wb.FindElement(By.CssSelector("#type-list-v2-container > div.type-list-v2-selector-wrp > div > div"))).Click();

                    //标签
                    IWebElement tagElement = driver.FindElement(By.CssSelector("#content-tag-v2-container > div.content-tag-v2-input-wrp > div > div.input-box-v2-1-instance > input"));
                    tagElement.SendKeys($"天文{Keys.Enter}");
                    Thread.Sleep(200);
                    tagElement.SendKeys($"宇宙{Keys.Enter}");
                    Thread.Sleep(200);
                    tagElement.SendKeys($"地球{Keys.Enter}");

                    //简介
                    driver.FindElement(By.CssSelector("#app > div.upload-v2-container > div.upload-v2-step2-container > div.file-content-v2-container > div.normal-v2-container > div.content-desc-v2-container > div.content-desc-v2-text-wrp > div > textarea")).SendKeys("哈哈简介!");
                }

                Console.ReadLine();
            }


            //System.Console.WriteLine("driver.Url: " + driver.Url);
            //driver.Navigate().Back(); //后退
            //driver.Navigate().Forward(); //前进
            //driver.Navigate().Refresh(); //刷新
            //System.Console.WriteLine("driver.Title: " + driver.Title);
            //System.Console.WriteLine("river.CurrentWindowHandle: " + driver.CurrentWindowHandle); //获取窗口句柄


            //WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            //driver.FindElement(By.Name("q")).SendKeys("cheese" + Keys.Enter);
            //wait.Until(webDriver => webDriver.FindElement(By.CssSelector("h3>div")).Displayed);
            //IWebElement firstResult = driver.FindElement(By.CssSelector("h3>div"));
            //Console.WriteLine(firstResult.GetAttribute("textContent"));
        }
コード例 #23
0
        public void Testcase05()
        {
            Infor("1.Go to http://live.guru99.com/");
            Driver = new ChromeDriver(Directory.GetCurrentDirectory())
            {
                Url = TestCommonKeyWords["Guru.URL"]
            };
            Driver.Manage().Window.Maximize();
            Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2);

            Infor("2.Click on my account link");
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Acount"])).Click();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.MyAcount"])).Click();

            Infor("3.Click Create an Account link and fill New User information except Email ID");
            string lastWindows = Driver.WindowHandles.Last();

            Driver.SwitchTo().Window(lastWindows);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.CreateAcount"])).Click();
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.FirstName"])).SendKeys(TestKeyWords["Guru.Xpath.FirstNameData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.MiddleName"])).SendKeys(TestKeyWords["Guru.Xpath.MiddleNameData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.LastName"])).SendKeys(TestKeyWords["Guru.Xpath.LastNameData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.Email"])).SendKeys(TestKeyWords["Guru.Xpath.EmailData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.Pass"])).SendKeys(TestKeyWords["Guru.Xpath.PassData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.PassConfirm"])).SendKeys(TestKeyWords["Guru.Xpath.PassConfirmData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.Checkbox"])).Click();

            Infor("4.Click Register");
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ResgiterButton"])).Click();
            string FirstWindows = Driver.WindowHandles.First();

            Driver.SwitchTo().Window(FirstWindows);

            Infor("5.Verify Registration is done.Expected account registration done.");
            string welcomeNoti = Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.WelcomeNotification"])).Text;

            Assert(welcomeNoti.Trim(), TestKeyWords["Guru.Xpath.WelcomeNotificationData"].Trim());

            Infor("6.Go to TV menu");
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.MenuTV"])).Click();


            Infor("7.Add product in your wish list - use product - LG LCD");
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.WishList"])).Click();

            Infor("8.Click SHARE WISHLIST");
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShareWishList"])).Click();

            Infor("9.In next page enter Email and a message and click SHARE WISHLIST");
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.EmailAddress"])).SendKeys(TestKeyWords["Guru.Xpath.EmailAddressData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.Message"])).SendKeys(TestKeyWords["Guru.Xpath.MessageData"]);
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShareWishListSubmit"])).Click();

            Infor("10.Check wishlist is shared.Expected wishlist shared successfully.");
            string WishlistShare = Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ShareWishListSuccess"])).Text;

            Assert(WishlistShare.Trim(), TestKeyWords["Guru.Xpath.ShareWishListSuccessData"].Trim());
        }
コード例 #24
0
        public void bucleProductos(IList <IWebElement> productos, ChromeDriver driver, INavigation nav)
        {
            int cont = productos.Count;


            if (cont > 0)
            {
                correct = true;
            }

            if (correct)
            {
                String[] allText = new string[cont];

                int i = 0;
                foreach (IWebElement producto in productos)
                {
                    allText[i] = producto.Text;
                    Console.WriteLine(allText[i]);

                    i++;
                }
                //   Console.WriteLine(i);

                IWebElement linkProducto;

                foreach (string nombre in allText)
                {
                    try
                    {
                        Thread.Sleep(4000);
                        linkProducto = driver.FindElement(By.XPath(xpathToFind: "//a[span='" + nombre + "']"));
                        Thread.Sleep(1000);
                        linkProducto.Click();
                        Console.WriteLine(nombre);

                        try
                        {
                            for (int a = 0; a < 2; a++)
                            {
                                try
                                {
                                    IWebElement masReseñas = driver.FindElement(By.XPath("//span[span='Cargar más reseñas internacionales']"));;
                                    masReseñas.Click();
                                }
                                catch (Exception e)
                                {
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("no hay más botones de reseñas" + e);
                        }

                        string SnumReseñas;
                        int    numReseñas = 0;
                        string Sprecio    = null;
                        string cadenaPro;

                        Thread.Sleep(2000);
                        try
                        {
                            Sprecio     = driver.FindElement(By.Id("priceblock_ourprice")).Text;
                            SnumReseñas = driver.FindElement(By.Id("acrCustomerReviewText")).Text;
                            numReseñas  = (int)numReseñasEntero(SnumReseñas);
                        }
                        catch (NoSuchElementException e)
                        {
                            Sprecio     = driver.FindElement(By.Id("priceblock_saleprice")).Text;
                            SnumReseñas = driver.FindElement(By.Id("acrCustomerReviewText")).Text;
                            numReseñas  = (int)numReseñasEntero(SnumReseñas);
                        }

                        //Excepción causada al no poder insertar producto
                        try
                        {
                            cadenaPro = "insert into productos (nombre, precio,  numReseñas) values ('" + nombre + "','" + Sprecio + "'," + numReseñas + ")";
                            transac.InsertarProducto(cadenaPro);

                            //  Console.WriteLine(cadenaPro);

                            //--------------------------------------------------------------USUARIOS Y RESEÑAS--------------------------------------------------------------

                            //Excepción causada por no encontrar perfil de clientes
                            try
                            {
                                Thread.Sleep(3000);

                                IList <IWebElement> perfiles = driver.FindElements(By.XPath("//span[@class='a-profile-name']"));
                                int      contaPerfiles       = perfiles.Count;
                                String[] nombres             = new string[contaPerfiles];
                                nombres = limpiarArray(perfiles, nombres);

                                IList <IWebElement> Ireseñas = driver.FindElements(By.XPath("//div[@class='a-expander-content reviewText review-text-content a-expander-partial-collapse-content']"));
                                int      contaReseñas        = Ireseñas.Count;
                                String[] reseñas             = new string[contaReseñas];
                                reseñas = limpiarArray(Ireseñas, reseñas);

                                string cadenaUsu;
                                string rparam;

                                for (int y = 0; y < nombres.Length; y++)
                                {
                                    //Excepción causada por no encontrar perfil de clientes
                                    try
                                    {
                                        Console.WriteLine(nombres[y]);

                                        if (nombre[y].Equals(""))
                                        {
                                            Console.WriteLine("nombre Vacio");
                                        }
                                        else
                                        {
                                            try
                                            {
                                                cadenaUsu = "insert into usuarios (nombre) values ('" + nombres[y] + "')";
                                                transac.InsertarUsuario(nombres[y]);
                                                Console.WriteLine(cadenaUsu);
                                                Console.WriteLine("-----------------USUARIO INTRODUCIDO-----------------");

                                                Thread.Sleep(500);

                                                string cadenaReseñas  = "select idProducto from productos where nombre='" + nombre + "'";
                                                int    idProducto     = transac.Seleccionar(cadenaReseñas);
                                                string cadenaUsuarios = "select idUsuario from usuarios where nombre='" + nombres[y] + "'";
                                                int    idUsuario      = transac.Seleccionar(cadenaUsuarios);
                                                Console.WriteLine(reseñas[y]);

                                                rparam = reseñas[y];

                                                transac.InsertarReseña(idProducto, idUsuario, rparam);
                                                Console.WriteLine("-----------------RESEÑA INTRODUCIDA-----------------");
                                            }
                                            catch (Exception e)
                                            {
                                                Console.WriteLine(e);
                                            }

                                            Thread.Sleep(1000);
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        Console.WriteLine("----------------------------- Error: " + e);
                                    }
                                }
                            }
                            catch (System.Data.SqlClient.SqlException e)
                            {
                                Console.WriteLine("SQL EXCEPTION--------------------------------" + e + "--------------------------------");
                            }
                        }
                        catch (NoSuchElementException)
                        {
                        }

                        nav.Back();
                        Thread.Sleep(1000);
                    }

                    //Excepción causada por no encontrar enlace a producto
                    catch (NoSuchElementException e)
                    {
                        Console.WriteLine("PRODUCT EXCEPTION" + e);
                    }
                }
                correct = false;
            }
            else
            {
                correct = true;
            }
        }
コード例 #25
0
        public void Testcase07a()
        {
            Infor("1.Go to http://live.guru99.com/");
            Driver = new ChromeDriver(Directory.GetCurrentDirectory())
            {
                Url = TestCommonKeyWords["Guru.URL"]
            };
            Driver.Manage().Window.Maximize();
            Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2);
            Infor("2.Click on my account link");
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Acount"])).Click();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.MyAcount"])).Click();
            Thread.Sleep(3000);

            Infor("3.Login in application using previously created credential");
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.LoginEmail"])).SendKeys(TestCommonKeyWords["Guru.Xpath.LoginEmailData"]);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.LoginPass"])).SendKeys(TestCommonKeyWords["Guru.Xpath.LoginPassData"]);
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.LoginSubmit"])).Click();
            Thread.Sleep(3000);

            Infor("4.Click on 'My Orders'");
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.Acount"])).Click();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.MyAcount"])).Click();
            Driver.FindElement(By.XPath(TestCommonKeyWords["Guru.Xpath.MyOrder"])).Click();
            string StatusRecentOrder = Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.StatusP.RecentOrder"])).Text;

            Infor("5.Click on 'View Order'");
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.ViewOrder"])).Click();

            //* **note: After steps 4 and 5, step 6 'RECENT ORDERS' was not displayed.
            Infor("6.Verify the previously created order is displayed in 'RECENT ORDERS' table and status is Pending");
            string StatusViewOrder = Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.StatusP.ViewOrder"])).Text;

            Assert(StatusRecentOrder, StatusViewOrder);

            Infor("7.Click on 'Print Order' link");
            Driver.FindElement(By.XPath(TestKeyWords["Guru.Xpath.PrintOrder"])).Click();
        }
コード例 #26
0
        static void Main(string[] args)
        {
            IWebDriver driver = new ChromeDriver();

            driver.Navigate().GoToUrl("http://opensource.demo.orangehrmlive.com/index.php/auth/login");
            driver.Manage().Window.Maximize();
            IWebElement inputUser = driver.FindElement(By.Id("txtUsername"));

            inputUser.SendKeys("Admin");
            IWebElement inputPass = driver.FindElement(By.Id("txtPassword"));

            inputPass.SendKeys("admin");
            driver.FindElement(By.Id("btnLogin")).Click();
            driver.FindElement(By.XPath("//a[@id='menu_pim_viewPimModule']/b")).Click();
            driver.FindElement(By.Id("menu_pim_addEmployee")).Click();
            IWebElement inputFirstName = driver.FindElement(By.Id("firstName"));

            inputFirstName.SendKeys("Purple");
            IWebElement inputMiddleName = driver.FindElement(By.Id("middleName"));

            inputMiddleName.SendKeys("Hrm");
            IWebElement inputLastName = driver.FindElement(By.Id("lastName"));

            inputLastName.SendKeys("Automation");
            driver.FindElement(By.Id("btnSave")).Click();
            driver.FindElement(By.Id("menu_pim_viewEmployeeList")).Click();
            IWebElement searchEmployee = driver.FindElement(By.Id("empsearch_employee_name_empName"));

            searchEmployee.SendKeys("Purple Hrm Automation");

            var  table = driver.FindElement(By.XPath("//table[@id='resultTable']/tbody"));
            var  rows  = table.FindElements(By.TagName("tr"));
            bool isPresentInTable;

            foreach (var row in rows)
            {
                if (row.Text.Contains("Purple Hrm"))
                {
                    isPresentInTable = true;
                    Console.WriteLine($"Row found {isPresentInTable}");
                    break;
                }
            }
            Console.ReadLine();
            driver.Close();
        }
コード例 #27
0
ファイル: main.cs プロジェクト: goynese/Csharp-auto-laptop
        static int CheckOut(ChromeDriver driver, Laptop laptop)
        {
            using (driver)
            {
                WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 0, 40));

BeginCheckout:

                //Navigate to Cart
                driver.Navigate().GoToUrl("http://shop.lenovo.com/SEUILibrary/controller/e/outlet_us/LenovoPortal/en_US/cart.workflow:ShowCart");

                if (driver.PageSource.Contains("currently"))
                {
                    return(0);
                }

                wait.Until(ExpectedConditions.ElementIsVisible(By.Id("cart-item-[:00000128:]"))).Clear();
                wait.Until(ExpectedConditions.ElementIsVisible(By.Id("cart-item-[:00000128:]"))).SendKeys("6");
                wait.Until(ExpectedConditions.ElementIsVisible(By.Id("cart-item-pricing-and-quantity-form-button"))).Click();

                Thread.Sleep(3000);

                //Proceed to checkout
                //driver.FindElement(By.LinkText("Proceed to Checkout")).Click();

                try
                {
                    driver.FindElement(By.ClassName("cart-checkoutButtons-checkout")).Click();
                }
                catch
                {
                    goto BeginCheckout;
                }
                //wait.Until(ExpectedConditions.ElementIsVisible(By.LinkText("cart-checkoutButtons-checkout"))).Click();


                //Sign in if not signed in.
                wait.Until(ElementIsClickable(By.Id("LoginName")));
                driver.FindElement(By.Id("LoginName")).Clear();
                driver.FindElement(By.Id("LoginName")).SendKeys("*****@*****.**");
                driver.FindElement(By.Id("Password")).Clear();
                driver.FindElement(By.Id("Password")).SendKeys("password");

                ////wait.Until(ElementIsClickable(By.CssSelector("#SignInButtonLink > span"))).Click();
                try
                {
                    Thread.Sleep(1000);
                    wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#SignInButtonLink > span"))).Click();
                }
                catch
                {
                    Thread.Sleep(5000);
                    wait.Until(ExpectedConditions.ElementIsVisible(By.Id("SignInButtonLink"))).Click();
                }

                //driver.FindElement(By.CssSelector("#SignInButtonLink > span")).Click();

                if (driver.PageSource.Contains("Opinion!"))
                {
                    wait.Until(ElementIsClickable(By.Id("oo_never_show"))).Click();
                }


                //Enter Address
                try
                {
                    Thread.Sleep(3000);
                    wait.Until(ElementIsClickable(By.CssSelector("#continueButton > span"))).Click();
                }
                catch
                {
                    driver.Navigate().GoToUrl("http://shop.lenovo.com/SEUILibrary/controller/e/outlet_us/LenovoPortal/en_US/cart.workflow:ShowCart");
                    driver.FindElement(By.ClassName("cart-checkoutButtons-checkout")).Click();
                    Thread.Sleep(3000);
                    wait.Until(ElementIsClickable(By.CssSelector("#continueButton > span"))).Click();
                }

                //Enter Credit Card Information
                //wait.Until(ExpectedConditions.ElementExists(By.XPath("//*[@id=\"table\"]/div[1]/div[2]")));
                try
                {
                    wait.Until(ExpectedConditions.ElementExists(By.ClassName("paymentTokenizationFrame")));
                }
                catch
                {
                    SendEmailMessage("Error payment page broken", "FF");
                    goto BeginCheckout;
                }
                driver.SwitchTo().Frame(driver.FindElementByClassName("paymentTokenizationFrame"));



                Thread.Sleep(3000);
                new SelectElement(driver.FindElement(By.Id("Paymetric_CreditCardType"))).SelectByText("Visa");

                IWebElement editable = driver.SwitchTo().ActiveElement();
                editable.SendKeys("Your text here");

                driver.FindElement(By.Id("Paymetric_CreditCardNumber")).SendKeys("ChaseFreedomCard#");
                driver.FindElement(By.Id("Paymetric_Exp_Month")).SendKeys("12");
                driver.FindElement(By.Id("Paymetric_Exp_Year")).SendKeys("12");
                driver.FindElement(By.Id("Paymetric_CVV")).SendKeys("123");

                driver.SwitchTo().DefaultContent();

                driver.FindElement(By.Id("CARD_HOLDER_NAME")).SendKeys("John Doe");

                try
                {
                    Thread.Sleep(2000);
                    wait.Until(ElementIsClickable(By.Id("checkout-continue-billing-link"))).Click();
                }
                catch
                {
                    driver.Navigate().GoToUrl("http://shop.lenovo.com/SEUILibrary/controller/e/outlet_us/LenovoPortal/en_US/cart.workflow:ShowCart");
                    driver.FindElement(By.ClassName("cart-checkoutButtons-checkout")).Click();
                    Thread.Sleep(1000);
                    wait.Until(ElementIsClickable(By.CssSelector("#continueButton > span"))).Click();

                    //CREDIT CARDS
                    new SelectElement(driver.FindElement(By.Id("Paymetric_CreditCardType"))).SelectByText("Visa");

                    editable = driver.SwitchTo().ActiveElement();
                    editable.SendKeys("Your text here");

                    driver.FindElement(By.Id("Paymetric_CreditCardNumber")).SendKeys("CardNumber");
                    driver.FindElement(By.Id("Paymetric_Exp_Month")).SendKeys("12");
                    driver.FindElement(By.Id("Paymetric_Exp_Year")).SendKeys("12");
                    driver.FindElement(By.Id("Paymetric_CVV")).SendKeys("123");

                    driver.SwitchTo().DefaultContent();

                    driver.FindElement(By.Id("CARD_HOLDER_NAME")).SendKeys("Edward Goynes");

                    //
                    Thread.Sleep(2000);
                    wait.Until(ElementIsClickable(By.Id("checkout-continue-billing-link"))).Click();
                }

                //Place Order
                wait.Until(ElementIsClickable(By.Id("TERMS_AND_CONDITIONS_AGREEMENT"))).Click();
                driver.FindElement(By.Id("checkout-continue-review-btn-link")).Click();

                //Email Successful purchase
                SendEmailMessage(laptop.name + laptop.processor + "Total Price:" + laptop.price, "Checkout Successful Price: ");

                //Laptop added to cart
                return(1);
            }
        }
コード例 #28
0
        public List <Match> FetchMatches_SB()
        {
            ChromeDriver browser = new ChromeDriver();

            List <Match> lsFootball = new List <Match>();

            browser.Navigate().GoToUrl($"https://agentii.stanleybet.ro/sportsbetting/Fotbal/68");

            Thread.Sleep(3000);

            IWebElement cookiewindow = browser.FindElement(By.CssSelector("[aria-labelledby='ui-dialog-title-cookieMessage']"));

            cookiewindow.FindElement(By.CssSelector("[class='ui-icon ui-icon-closethick']")).Click();

            IWebElement window = browser.FindElement(By.CssSelector("[aria-labelledby='ui-dialog-title-age18Message']"));

            window.FindElement(By.CssSelector("[class='successButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only']")).Click();

            IWebElement games = browser.FindElement(By.CssSelector("[class='oddsTable drop-shadow lifted']"));

            ICollection <IWebElement> odds  = games.FindElements(By.ClassName("trOdd"));
            ICollection <IWebElement> evens = games.FindElements(By.ClassName("trEven"));

            foreach (var item in odds)
            {
                lsFootball.Add(new Match());

                string teams = item.FindElement(By.CssSelector("[class='alignLeft fullWidth']")).GetAttribute("textContent");
                ICollection <IWebElement> tds = item.FindElements(By.TagName("td"));

                int iterator = 0;

                string home = teams.Substring(0, teams.Length - teams.IndexOf("-") - 3);
                string away = teams.Substring(teams.IndexOf("-") + 2);

                lsFootball.Last().HomeTeam = home;
                lsFootball.Last().AwayTeam = away;

                lsFootball.Last().Bets = new Dictionary <string, double>();

                foreach (var td in tds)
                {
                    if (iterator == 1)  //hour
                    {
                        lsFootball.Last().PlayingDate = DateTime.ParseExact(td.GetAttribute("textContent"), "HH:mm", null);
                    }

                    if (iterator == 2) //date
                    {
                        if (lsFootball.Last().PlayingDate.Hour != DateTime.Now.Hour)
                        {
                            lsFootball.Last().PlayingDate.AddDays(1);
                        }
                    }

                    if (iterator == 5) //1
                    {
                        string cota = td.GetAttribute("textContent");

                        if (cota == "-")
                        {
                            break;
                        }

                        if (cota.Contains(","))
                        {
                            cota.Replace(",", ".");
                        }

                        lsFootball.Last().Bets.Add("1", Double.Parse(cota));
                    }

                    if (iterator == 6) //X
                    {
                        string cota = td.GetAttribute("textContent");

                        if (cota == "-")
                        {
                            break;
                        }

                        if (cota.Contains(","))
                        {
                            cota.Replace(",", ".");
                        }

                        lsFootball.Last().Bets.Add("X", Double.Parse(cota));
                    }

                    if (iterator == 7) //2
                    {
                        string cota = td.GetAttribute("textContent");

                        if (cota == "-")
                        {
                            break;
                        }

                        if (cota.Contains(","))
                        {
                            cota.Replace(",", ".");
                        }

                        lsFootball.Last().Bets.Add("2", Double.Parse(cota));
                    }

                    iterator++;
                }
            }

            foreach (var item in evens)
            {
                lsFootball.Add(new Match());

                string teams = item.FindElement(By.CssSelector("[class='alignLeft fullWidth']")).GetAttribute("textContent");
                ICollection <IWebElement> tds = item.FindElements(By.TagName("td"));

                int iterator = 0;

                string home = teams.Substring(0, teams.Length - teams.IndexOf("-") - 3);
                string away = teams.Substring(teams.IndexOf("-") + 2);

                lsFootball.Last().HomeTeam = home;
                lsFootball.Last().AwayTeam = away;

                lsFootball.Last().Bets = new Dictionary <string, double>();

                foreach (var td in tds)
                {
                    if (iterator == 1) //hour
                    {
                        lsFootball.Last().PlayingDate = DateTime.ParseExact(td.GetAttribute("textContent"), "HH:mm", null);
                    }

                    if (iterator == 2) //date
                    {
                        if (lsFootball.Last().PlayingDate.Hour != DateTime.Now.Hour)
                        {
                            lsFootball.Last().PlayingDate.AddDays(1);
                        }
                    }

                    if (iterator == 5) //1
                    {
                        string cota = td.GetAttribute("textContent");

                        if (cota == "-")
                        {
                            break;
                        }

                        if (cota.Contains(","))
                        {
                            cota.Replace(",", ".");
                        }

                        lsFootball.Last().Bets.Add("1", Double.Parse(cota));
                    }

                    if (iterator == 6) //X
                    {
                        string cota = td.GetAttribute("textContent");

                        if (cota == "-")
                        {
                            break;
                        }

                        if (cota.Contains(","))
                        {
                            cota.Replace(",", ".");
                        }

                        lsFootball.Last().Bets.Add("X", Double.Parse(cota));
                    }

                    if (iterator == 7) //2
                    {
                        string cota = td.GetAttribute("textContent");

                        if (cota == "-")
                        {
                            break;
                        }

                        if (cota.Contains(","))
                        {
                            cota.Replace(",", ".");
                        }

                        lsFootball.Last().Bets.Add("2", Double.Parse(cota));
                    }

                    iterator++;
                }
            }

            browser.Dispose();

            return(lsFootball);
        }
コード例 #29
0
        public void Run()
        {
            bool result     = false;
            int  retryCount = -1;

            using (ChromeDriver driver = new ChromeDriver())
            {
                try
                {
                    var navigate = driver.Navigate();
                    navigate.GoToUrl(@"https://online.jsil.com/login.xhtml");
                    driver.Manage().Window.Maximize();

                    IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
                    js.ExecuteScript("document.getElementById('onlineSecurityTipDialog').remove(); document.getElementById('onlineSecurityTipDialog_modal').remove();");

                    while (retryCount++ < 10)
                    {
                        try
                        {
                            IWebElement userName = driver.FindElement(By.Id("loginForm:username"));
                            userName.Clear();
                            userName.SendKeys(Configuration["JSIL:username"]);

                            userName.SendKeys(Keys.Tab);

                            Thread.Sleep(2000);

                            IWebElement password = driver.FindElement(By.Id("loginForm:password"));
                            password.Clear();
                            password.SendKeys(Configuration["JSIL:password"]);

                            Thread.Sleep(2000);

                            IWebElement loginButton = driver.FindElement(By.Id("loginForm:btn1"));
                            loginButton.Click();
                        }
                        catch (NoSuchElementException)
                        {
                            result = true;
                            break;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                            Thread.Sleep(5000);
                            continue;
                        }
                    }

                    if (result)
                    {
                        IWebElement mainTable = driver.FindElement(By.CssSelector("table[class='classback portfolioImage col-md-12 col-md-offset-1'"));

                        var splitted = mainTable.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
                        File.AppendAllText(Path.Combine(Directory.GetCurrentDirectory(), "StatusFile.txt"), Environment.NewLine + splitted[0] + " " + splitted[1] + Environment.NewLine);

                        SendEmail(splitted[0] + " " + splitted[1]);

                        IWebElement logout = driver.FindElement(By.Id("menuLinkForm:logout_link"));
                        logout.Click();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    File.AppendAllText(Path.Combine(Directory.GetCurrentDirectory(), "ErrorFile.txt"), ex.Message);
                }
                finally
                {
                    driver.Quit();
                }
            }
        }
コード例 #30
0
ファイル: TabBuilder.cs プロジェクト: ronanmoriarty/CQSplit
        private void Submit()
        {
            var createTabButton = _chromeDriver.FindElement(By.XPath("//input[@type=\"submit\"]"));

            createTabButton.Click();
        }