public void Can_Add_Comment()
        {
            DatabaseHelper.ExecuteCommand("DELETE FROM Messages");
            DatabaseHelper.ExecuteCommand("INSERT INTO Messages (Message) VALUES('foo'),('Bar')");
            using (var driver = new EventFiringWebDriver(new ChromeDriver()))
            {
                driver.Navigate().GoToUrl("http://localhost/TDDDemoApp/");

                var loadingWait = new WebDriverWait(driver, new TimeSpan(0, 0, 30));
                loadingWait.Until(x => !x.FindElement(By.Id("message-loading")).Displayed);

                const string inputMessage = "this is my message";
                var          inputElement = driver.FindElement(By.Id("message-text-input"));
                inputElement.SendKeys(inputMessage);

                var buttonElement = driver.FindElement(By.Id("add-message-button"));
                buttonElement.Click();

                var wait = new WebDriverWait(driver, new TimeSpan(0, 0, 5));
                wait.Until(x => string.IsNullOrEmpty(x.FindElement(By.Id("message-text-input")).Text));

                Thread.Sleep(1000);

                var messages = driver.FindElements(By.TagName("blockquote"));
                Assert.That(messages.Any(x => x.Text.Contains(inputMessage)));
            }
        }
示例#2
0
        public void Task17Test()
        {
            driver.Url = "http://localhost/litecart/admin/";
            IWebElement element = wait.Until(d => d.FindElement(By.Name("username")));

            driver.FindElement(By.Name("username")).SendKeys("admin");
            IWebElement element2 = wait.Until(d => d.FindElement(By.Name("password")));

            driver.FindElement(By.Name("password")).SendKeys("password123");
            driver.FindElement(By.Name("login")).Click();
            wait.Until(d => d.Title == "My Store");

            driver.Url = catalogUrl;
            wait.Until(d => d.Title == "Catalog | My Store");

            var count = driver.FindElements(By.CssSelector("tr.row [href*=edit]:not([title=Edit])")).Count;

            for (int i = 0; i < count; i++)
            {
                driver.FindElements(By.CssSelector("tr.row [href*=edit]:not([title=Edit])"))[i].Click();
                wait.Until(d => d.Title.Contains("Edit Product"));
                foreach (var entry in driver.Manage().Logs.GetLog(LogType.Browser))
                {
                    Console.WriteLine("{0}:{1} - {2}", entry.Timestamp, entry.Level, entry.Message);
                }
                driver.Url = catalogUrl;
                wait.Until(d => d.Title == "Catalog | My Store");
            }
        }
示例#3
0
        public void FirstTestEvent()
        {
            driver.Navigate().GoToUrl("http://www.google.ru/");

            driver.FindElement(By.Id("lst-ib")).SendKeys("software-testing.ru");
            driver.FindElement(By.Id("lst-ib")).SendKeys(Keys.Enter);
        }
示例#4
0
 public void LoginAdmin()
 {
     driver.Url = "http://localhost:8080/litecart/admin/login.php";
     driver.FindElement(By.Name("username")).SendKeys("admin");
     driver.FindElement(By.Name("password")).SendKeys("admin");
     driver.FindElement(By.Name("login")).Click();
     wait.Until(ExpectedConditions.TitleIs("My Store"));
 }
        public void FirstTest()
        {
            driver.Url = "http://www.google.com/";
            driver.FindElement(By.Name("q")).SendKeys("webdriver");
            driver.FindElement(By.Name("q")).SendKeys(Keys.Tab);
            IWebElement searchButton = wait.Until(d => d.FindElement(By.Name("btnK")));

            //IList<IWebElement> links =  driver.FindElements(By.XPath("//h3/a"));
            //links[0].Click();
        }
示例#6
0
 public static void Clicks(By by)
 {
     if (WaitElement(by) != false)
     {
         driver.FindElement(by).Click();
     }
 }
示例#7
0
 public bool IsElementPresent(By locator)
 {
     try
     {
         driver.FindElement(locator);
         return true;
     }
     catch (NoSuchElementException)
     {
         return false;
     }
 }
示例#8
0
 // 경고창과 클릭 예외 처리가 된 클릭 이벤트
 public void Click(EventFiringWebDriver pDriver, By by)
 {
     while (true)
     {
         try
         {
             pDriver.FindElement(by).Click();
             break;
         }
         catch (UnhandledAlertException e)
         {
             Console.WriteLine($": '{e}'");
             try
             {
                 IAlert alert = pDriver.SwitchTo().Alert();
                 Console.WriteLine(alert.Text);
                 alert.Dismiss();
             }
             catch (Exception)
             {
                 //Console.WriteLine($": '{e}'");
             }
         }
         catch (ElementClickInterceptedException e)
         {
             Console.WriteLine($": '{e}'");
         }
         catch (Exception e)
         {
             Console.WriteLine($": '{e}'");
         }
         Thread.Sleep(1000);
     }
 }
示例#9
0
        public void TestPractice()
        {
            driver.Url = "https://www.google.com/";
            IWebElement element = wait.Until(d => d.FindElement(By.Name("q")));

            element.SendKeys("webdriver" + Keys.Escape);
            driver.FindElement(By.Name("btnK")).Click();
            wait.Until(ExpectedConditions.TitleIs("webdriver - Пошук Google"));
        }
示例#10
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DriverControl        dc          = new DriverControl();
            EventFiringWebDriver eventDriver = dc.GetDriver(); // 드라이버 객체 생성 및 클릭 이벤트 세팅

            eventDriver.Navigate().GoToUrl("https://spib.wooribank.com/pib/Dream?withyou=CMLGN0001");
            Thread.Sleep(1000);

            Thread.Sleep(1000);
            BringToFront();
            MessageBox.Show("로그인 해주세요.");
            Thread.Sleep(1000);

            // 로그인 될때까지 대기
            while (true)
            {
                try
                {
                    if (eventDriver.FindElement(By.CssSelector(".login-name")).Displayed)
                    {
                        System.Console.WriteLine("로그인 성공");
                        break;
                    }
                }
                catch (Exception)
                {
                    //Console.WriteLine($": '{e}'");
                }
                Thread.Sleep(2000);
            }

            blindDriver = dc.GetDriver(new String[] { "--headless", "window-size=1920x1080", "disable-gpu", "user - agent = Mozilla / 5.0(Macintosh; Intel Mac OS X 10_12_6) AppleWebKit / 537.36(KHTML, like Gecko) Chrome / 61.0.3163.100 Safari / 537.36", "lang =ko_KR" });
            // blindDriver = dc.GetDriver();

            blindDriver.Navigate().GoToUrl("https://www.wooribank.com/");

            ReadOnlyCollection <Cookie> _cookies = eventDriver.Manage().Cookies.AllCookies;

            eventDriver.ExecuteScript("$('body').append('<div id=\"k-shield\" style=\"position: fixed; color: white; width: 100%;height: 100%;background: rgba(255, 0, 0, 0.6);top: 0;text-align: center; padding-top:250px; font-size: 30px; font-weight: bold; z-index: 1000;\" >기다려주세요</div>');");

            foreach (Cookie item in _cookies)
            {
                blindDriver.Manage().Cookies.AddCookie(item);
            }
            Thread.Sleep(1000);
            blindDriver.Navigate().GoToUrl("https://spib.wooribank.com/pib/Dream?withyou=PSINQ0013"); // 게좌 화면
            Thread.Sleep(1000);
            eventDriver.Quit();

            AccountList.ItemsSource = dc.SetAccountList(blindDriver);

            BringToFront();

            MessageBox.Show("계좌를 클릭해주세요.");
        }
示例#11
0
        private void Start()
        {
            EventFiringWebDriver driver = new EventFiringWebDriver(new ChromeDriver());

            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1);
            GoToCatalog(driver);
            _driver = driver;

            var userNameField = _driver.FindElement(By.Name("username"));

            userNameField.SendKeys("admin");
            var passwordField = _driver.FindElement(By.Name("password"));

            passwordField.SendKeys("admin");
            var loginButton = _driver.FindElement(By.TagName("button"));

            loginButton.Click();

            browserLogs = new List <string>();
        }
示例#12
0
        public static IWebElement GetElement(By by, int timeoutSeconds = 10)
        {
            WaitElement(by, timeoutSeconds);

            if (Driver.FindElements(by).Count > 0)
            {
                return(Driver.FindElement(by));
            }

            return(null);
        }
示例#13
0
        public static bool EditIsEnabled(EventFiringWebDriver driver)
        {
            try
            {
                return(driver.FindElement(WebTablePage.Edit).Enabled);
            }

            catch ()
            {
            }
        }
        public void TheBaiduSwitchWindowTest()
        {
            //IWebDriver driver = new ChromeDriver();//谷歌浏览器
            IWebDriver driver = new EventFiringWebDriver(new ChromeDriver());



            driver.Navigate().GoToUrl("http://tieba.baidu.com/f/search/adv");

            //找到注册元素
            IWebElement register = driver.FindElement(By.CssSelector("#com_userbar>ul>li:nth-child(5)>div>a"));

            register.Click();

            //显示所有标识
            IList <string> listHand = driver.WindowHandles;//拿到所有标识

            //切换到注册窗口再输入12345
            driver.SwitchTo().Window(listHand[1]);
            driver.FindElement(By.Name("userName")).SendKeys("12345");
        }
        public void Login()
        {
            driver.Url = "http://google.com";
            var element = wait.Until(d => d.FindElement(By.Name("q")));

            element.SendKeys("webdriver");
            new Actions(this.driver).MoveToElement(driver.FindElement(By.CssSelector("img[alt=Google]"))).Click().Perform();
            var okButton = wait.Until(d => d.FindElement(By.Name("_btnK")));

            okButton.Click();
            wait.Until(d => d.Title.Equals("webdriver - Поиск в Google"));
        }
示例#16
0
        public void SomeTestMethod1InListeners()
        {
            webDriver = new ChromeDriver();
            EventFiringWebDriver driver = new EventFiringWebDriver(webDriver);

            //driver.ElementClicked += new EventHandler<WebElementEventArgs>(firingDriver_ElementClicked);

            driver.Manage().Window.Maximize();
            driver.Manage().Cookies.DeleteAllCookies();
            driver.Url = "http://executeautomation.com/demosite/index.html?UserName=fdgf&Password=dfgdfg&Login=Login";
            driver.FindElement(By.Name("UserName")).SendKeys("Rupesh");
            driver.Close();
            driver.Quit();
        }
示例#17
0
        public void ProductLogs()
        {
            driver.Url = "http://localhost/litecart/admin/login.php";
            driver.FindElement(By.Name("username")).SendKeys("admin");
            driver.FindElement(By.Name("password")).SendKeys("admin");
            driver.FindElement(By.Name("login")).Click();
            wait.Until(ExpectedConditions.TitleIs("My Store"));

            driver.Url = "http://localhost/litecart/admin/?app=catalog&doc=catalog&category_id=1";
            driver.FindElement(By.CssSelector("td:nth-child(3) > a")).Click();

            products(By.CssSelector("td:nth-child(3) > a"));
        }
示例#18
0
        // 계좌 선택
        private void AccountList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            blindDriver.Navigate().GoToUrl("https://spib.wooribank.com/pib/Dream?withyou=PSINQ0028"); // 상세조회 화면
            Thread.Sleep(1000);
            blindDriver.ExecuteScript("beforeAddDate('4');");

            try
            {
                while (blindDriver.FindElement(By.CssSelector(".pop-content")).Displayed)
                {
                    Thread.Sleep(1000);
                }
            }
            catch (Exception)
            {
                Console.WriteLine("조회중");
            }

            List <PayVO> list = new List <PayVO>();

            IReadOnlyCollection <IWebElement> elList = blindDriver.FindElements(By.CssSelector(".gridHeaderTableDefault .grid_body_row"));

            foreach (IWebElement el in elList)
            {
                PayVO payVO = new PayVO();
                payVO.No      = el.FindElement(By.CssSelector("td:nth-child(1)")).Text;
                payVO.PayDt   = el.FindElement(By.CssSelector("td:nth-child(2)")).Text;
                payVO.Briefs  = el.FindElement(By.CssSelector("td:nth-child(3)")).Text;
                payVO.Memo    = el.FindElement(By.CssSelector("td:nth-child(4)")).Text;
                payVO.OutAmt  = el.FindElement(By.CssSelector("td:nth-child(5)")).Text;
                payVO.InAmt   = el.FindElement(By.CssSelector("td:nth-child(6)")).Text;
                payVO.Balance = el.FindElement(By.CssSelector("td:nth-child(7)")).Text;
                payVO.Point   = el.FindElement(By.CssSelector("td:nth-child(8)")).Text;

                list.Add(payVO);
            }

            PayList.ItemsSource = list;
        }
示例#19
0
 public static void ClickGenderFeMale(EventFiringWebDriver driver)
 {
     TestBase.Log(TestBase.Report, $"Clique no botão 'Feminino': {text}");
     driver.FindElement(RegisterPage.GenderFeMale).Click();
 }
示例#20
0
 public static void SelectDateOfBirthMonthByValue(EventFiringWebDriver driver, string value)
 {
     TestBase.Log(TestBase.Report, $"Selecione o mês da data de nascimento por valor: {text}");
     new SelectElement(driver.FindElement(RegisterPage.DateOfBirthMonth)).SelectByValue(value);
 }
示例#21
0
 public static void ClickSkipSignIn(this EventFiringWebDriver driver)
 {
     TestBase.Log(TestBase.Report, "Clique no botão 'Skip Sign In'");
     driver.FindElement(IndexPage.SkipSignIn).Click();
 }
示例#22
0
 public static void SelectDateOfBirthMonthByIndex(EventFiringWebDriver driver, int index)
 {
     TestBase.Log(TestBase.Report, $"Selecione o mês da data de nascimento por index: {text}");
     new SelectElement(driver.FindElement(RegisterPage.DateOfBirthMonth)).SelectByIndex(index);
 }
示例#23
0
 public static void SelectCountryByIndex(EventFiringWebDriver driver, int index)
 {
     TestBase.Log(TestBase.Report, $"Selecione o país por index: {text}");
     new SelectElement(driver.FindElement(RegisterPage.Country)).SelectByIndex(index);
 }
示例#24
0
 public void Login()
 {
     driver.FindElement(By.Name("username")).SendKeys("admin");
     driver.FindElement(By.Name("password")).SendKeys("admin");
     driver.FindElement(By.Name("login")).Click();
 }
示例#25
0
 // Ctrl + H  > para substituir todas as variaveis com um nome igual
 public static void SetFirstName(EventFiringWebDriver driver, string text)
 {
     TestBase.Log(TestBase.Report, $"SendKeys primeiro nome: {text}");
     driver.FindElement(RegisterSteps.FirstName).SendKeys(text);
 }
示例#26
0
 public static void SetEmailAddress(EventFiringWebDriver driver, string text)
 {
     TestBase.Log(TestBase.Report, $"SendKeys email: {text}");
     driver.FindElement(RegisterPage.EmailAddress).SendKeys(text);
 }
示例#27
0
 public static void SelectCountryByValue(EventFiringWebDriver driver, string value)
 {
     TestBase.Log(TestBase.Report, $"Selecione o país por valor: {text}");
     new SelectElement(driver.FindElement(RegisterPage.Country)).SelectByValue(value);
 }
示例#28
0
 public static void SelectCountryByText(EventFiringWebDriver driver, string text)
 {
     TestBase.Log(TestBase.Report, $"Selecione o país por texto: {text}");
     new SelectElement(driver.FindElement(RegisterPage.Country)).SelectByText(text);
 }
示例#29
0
 public static void SetPhone(EventFiringWebDriver driver, string text)
 {
     TestBase.Log(TestBase.Report, $"SendKeys telefone: {text}");
     driver.FindElement(RegisterPage.Phone).SendKeys(text);
 }
示例#30
0
 public static void SelectDateOfBirthYearByText(EventFiringWebDriver driver, string text)
 {
     TestBase.Log(TestBase.Report, $"Selecione o ano da data de nascimento por texto: {text}");
     new SelectElement(driver.FindElement(RegisterPage.DateOfBirthYear)).SelectByText(text);
 }