Esempio n. 1
0
        public void VerifyPageTitle()
        {
            // Replace with your own test logic
            _driver.Url = "https://www.bing.com";

            Assert.AreEqual("Bing", _driver.Title);

            var input = _driver.FindElementById("sb_form_q");

            input.SendKeys("helloworld");
            System.Threading.Thread.Sleep(2000);
            var button = _driver.FindElementById("sb_form_go");

            button.Click();

            System.Threading.Thread.Sleep(10000);
        }
        static void Main(string[] args)
        {
            NavigationData data = new NavigationData();

            MenuFilterSection menu = MenuFilterSection.GetConfig();
            List<string> ids = menu.GetItemsToBeRemove();

            string filter = string.Join(",", ids.ToArray());
            MenuOrderSection menuOrder = MenuOrderSection.GetConfig();
            List<SAMenuItemDTO> menuItems = data.GetAllUsedDiagrams(filter);

            List<string> errorUrls = new List<string>();

            foreach (var item in menuItems)
            {
                foreach (var item2 in item.ChildItems)
                {
                    InternetExplorerDriver driver = new InternetExplorerDriver();

                    string url = string.Format("http://wpsa1/tobe_ea/Default.aspx?id={0}", item2.Key);
                    driver.Url = url;

                    var sc = driver.GetScreenshot();

                    sc.SaveAsFile(item2.Key.ToString() + ".jpg", ImageFormat.Jpeg);
                    //Thread.Sleep(100000);

                    var x = driver.FindElementById("reportId");
                    if (x == null)
                    {
                        errorUrls.Add(url);
                    }
                    driver.Quit();
                }
            }

            File.WriteAllLines(@"BrokenPages.txt", errorUrls.ToArray());

            Console.ReadLine();
        }
        public void Test_for_donation_error_text()
        {
            RemoteWebDriver Driver = new InternetExplorerDriver();
            Driver.Navigate().GoToUrl(@"http://en.wikipedia.org/");

            // On Main Page
            var lnkSupportUs = Driver.FindElementByCssSelector(@"a[title='Support us']");
            lnkSupportUs.Click();

            // On Make your donation page

            var radio50UAH = Driver.FindElementByCssSelector(@"#input_amount_0[value='50']");
            radio50UAH.Click();


            // And clich on "Donate" button
            var btnDonate = Driver.FindElementByCssSelector(@"input[value='Donate by credit/debit card']");
            btnDonate.Click();


            // On Billing information

            var txtFirstName = Driver.FindElementByName("fname");
            var txtLastName = Driver.FindElementByName("lname");
            var txtStreet = Driver.FindElementByName("street");
            var txtPostalCode = Driver.FindElementByName("zip");
            var txtCity = Driver.FindElementByName("city");
            var txtEmailAddress = Driver.FindElementByName("emailAdd");

            var radioCardType = Driver.FindElementByCssSelector(@"input[name='cardtype'][value='visa']");


            txtFirstName.Clear();
            txtFirstName.SendKeys("Vasya");

            txtLastName.Clear();
            txtLastName.SendKeys("Poopkin");

            txtCity.Clear();
            txtCity.SendKeys("Kyiv");

            txtEmailAddress.Clear();
            txtEmailAddress.SendKeys("*****@*****.**");

            txtPostalCode.Clear();
            txtPostalCode.SendKeys("80999");

            txtStreet.Clear();
            txtStreet.SendKeys("It is very boring");

            radioCardType.Click();


            // Donation form second part

            var wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(30));

            string frameSelector = @"div#payment > iframe";

            wait.Until(ExpectedConditions.ElementExists(By.CssSelector(frameSelector)));

            var frameFormSecondPart = Driver.FindElementByCssSelector(frameSelector);

            Driver.SwitchTo().Frame(frameFormSecondPart);

            string cardNumSelector = @"CREDITCARDNUMBER";
            wait.Until(ExpectedConditions.ElementIsVisible(By.Name(cardNumSelector)));

            var txtCreditCardNum = Driver.FindElementByName(cardNumSelector);
            var selectExpMonth = new SelectElement(Driver.FindElementByName(@"EXPIRYDATE_MM"));
            var selectExpYear = new SelectElement(Driver.FindElementByName(@"EXPIRYDATE_YY"));
            var txtCVV = Driver.FindElementByName(@"CVV");
            var btnSubmit = Driver.FindElementById(@"btnSubmit");

            txtCreditCardNum.Clear();
            txtCreditCardNum.SendKeys("4716699955349929");

            selectExpMonth.SelectByText("02");
            selectExpYear.SelectByText("15");

            txtCVV.Clear();
            txtCVV.SendKeys("555");

            // Looks like we cannot click on this button. 
            // Well... 
            btnSubmit.SendKeys(Keys.Enter);

            Driver.SwitchTo().DefaultContent();

            // On Donate result page

            wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(@"div#mw-content-text * big > span")));
            var lblTransactionErrorMessage = Driver.FindElement(By.CssSelector(@"div#mw-content-text * big > span"));

            Assert.AreEqual("Your transaction could not be accepted.", lblTransactionErrorMessage.Text);

            Driver.Dispose();

        }
        public void Donate_error_test()
        {
            RemoteWebDriver driver = new InternetExplorerDriver();
            // Navigate to the base url.
            driver.Navigate().GoToUrl(@"http://en.wikipedia.org");

            // Main Page
            var lnkDonate = driver.FindElementByCssSelector(@"a[title='Support us']");
            lnkDonate.Click();

            // Donate Page
            var rbtnDonate50 = driver.FindElementByCssSelector(@"input[name='amount'][value='50']");
            rbtnDonate50.Click();

            var btnMakeDonation = driver.FindElementByCssSelector(@"input[value='Donate by credit/debit card']");
            btnMakeDonation.Click();

            // Donation Payments
            var txtFirstName = driver.FindElementByName("fname");
            var txtLastName = driver.FindElementByName("lname");
            var txtStreet = driver.FindElementByName("street");
            var txtPostalCode = driver.FindElementByName("zip");
            var txtCity = driver.FindElementByName("city");
            var txtEmailAddress = driver.FindElementByName("emailAdd");
            var rbtnCardVisa = driver.FindElementByCssSelector(@"input[name='cardtype'][value='visa']");


            txtFirstName.Clear();
            txtFirstName.SendKeys("Vasya");

            txtLastName.Clear();
            txtLastName.SendKeys("Pupkin");

            txtStreet.Clear();
            txtStreet.SendKeys("Blah blah blah street");

            txtPostalCode.Clear();
            txtPostalCode.SendKeys("8577");

            txtCity.Clear();
            txtCity.SendKeys("My Str");

            txtEmailAddress.Clear();
            txtEmailAddress.SendKeys("*****@*****.**");

            rbtnCardVisa.Click();

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

            
            var frameCardNumber=wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(@"iframe[src^='https://na.gcsip.com/orb/']")));

            driver.SwitchTo().Frame(frameCardNumber);

            var txtName = wait.Until(ExpectedConditions.ElementIsVisible(By.Name("CREDITCARDNUMBER")));

            txtName.Clear();
            txtName.SendKeys("4556767453966453");

            var ddlMonthSelect = new SelectElement(driver.FindElementByName(@"EXPIRYDATE_MM"));
            var ddlYearSelect = new SelectElement(driver.FindElementByName(@"EXPIRYDATE_YY"));
            var txtSecurityCode = driver.FindElementByName(@"CVV");
            var btnContinue = driver.FindElementById("btnSubmit");

            ddlMonthSelect.SelectByText("05");
            ddlYearSelect.SelectByText("15");
            txtSecurityCode.SendKeys("555");

            Assert.IsTrue(btnContinue.Displayed, "There is a Continue button");
            
            btnContinue.SendKeys(Keys.Enter);

            driver.SwitchTo().DefaultContent();

            wait.Until(ExpectedConditions.TitleContains(@"Donate-error - Payments"));

            var lblFirstHeader = driver.FindElementById(@"firstHeading");

            Assert.AreEqual("Donate-error", lblFirstHeader.Text);

        }
        public void TestMethod1()
        {
            //RemoteWebDriver Driver = new InternetExplorerDriver();
            RemoteWebDriver Driver = new InternetExplorerDriver();
            //Driver.Url = "www.football.ua";
            Driver.Navigate().GoToUrl(@"http://en.wikipedia.org/");
            //Driver.Manage().Window.Maximize();

            var lnkSupportUs = Driver.FindElementByCssSelector(@"a[title = 'Support us']");
            lnkSupportUs.Click();

            // Cannot find with this locator!
            var radio50UAH = Driver.FindElementByXPath("/html/body/div[3]/div[2]/div[3]/table/tbody/tr/td[2]/form/div/div[3]/table/tbody/tr[1]/td[1]/label");//Driver.FindElementById("input_amount_0");// Driver.FindElementByCssSelector(@"#input_amount_0[value='50']");
            radio50UAH.Click();

            var btnDonate = Driver.FindElement(By.ClassName("payment-method-button"));
            btnDonate.Click();

            var txtFirstName = Driver.FindElementById("fname");
            var txtlastName = Driver.FindElementById("lname");
            var txtEmail = Driver.FindElementById("emailAdd");
            var radioCardType = Driver.FindElementById("cc-visa");

            txtFirstName.Clear();
            txtFirstName.SendKeys("Vasya");

            txtlastName.Clear();
            txtlastName.SendKeys("Poopkin");

            txtEmail.Clear();
            txtEmail.SendKeys("*****@*****.**");

            radioCardType.Click();

            var wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(6));

            var txtCreditCardNum = Driver.FindElementByName("CREDITCARDNU");
            var selectExpMonth = new SelectElement(Driver.FindElementById("F1010_MM"));
            var selectExpYear = new SelectElement(Driver.FindElementById("F1010_YY"));
            var txtCVV = Driver.FindElementById(@"F1136");
            var btnSubmit = Driver.FindElementById(@"btnSubmit");

            txtCreditCardNum.Clear();
            txtCreditCardNum.SendKeys("8975397698238467");

            selectExpMonth.SelectByText("02");
            selectExpYear.SelectByText("15");

            txtCVV.Clear();
            txtCVV.SendKeys("836");

            btnSubmit.SendKeys(Keys.Enter);

            Driver.SwitchTo().DefaultContent();

            // On Donate results page

            string headerSelector = @"h1.firstHeading";
            var headingElement = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(headerSelector)));

            Assert.AreEqual("Donate-error", headingElement.Text);

            Driver.Quit();
            Driver.Dispose();
        }