コード例 #1
0

        
コード例 #2
0
        static void Main(string[] args)
        {
            IWebDriver driver = new FirefoxDriver();

            driver.Url = "https://tanlaktanya.taszi.hu";
            driver.Manage().Window.Maximize();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
            driver.FindElement(By.LinkText("Belépés")).Click();
            driver.FindElement(By.Id("username")).SendKeys("seleniumtest");
            driver.FindElement(By.Id("password")).SendKeys("a1234567" + Keys.Enter);

            driver.FindElement(By.LinkText("Programozás")).Click();
            driver.FindElement(By.LinkText("Szoftverfejlesztő (14d13b)")).Click();

            //IList<IWebElement> elemek = driver.FindElements(By.XPath("/html/body/div[2]/div/div[4]/div/div/div[1]/div/div/div/ul/li[2]/div[3]"));
            IList <IWebElement> elemek = driver.FindElements(By.XPath("//*[@id=\"section-0\"]"));

            ////*[@id="section-1"]
            Console.WriteLine($"Elemek száma:{elemek.Count}");

            for (int i = 0; i < elemek.Count; i++)
            {
                Console.WriteLine(elemek[i].Text);
            }

            driver.FindElement(By.LinkText("Kilépés")).Click();

            Thread.Sleep(8000);

            driver.Close();

            Console.ReadKey();
        }
コード例 #3
0
        public void PowerTest()
        {
            //initialise pre reqs
            double     expectedResult;
            IWebDriver driver = new FirefoxDriver();

            //navigate to website
            driver.Navigate().GoToUrl("http://www.calculator.net");

            //select equation sequence
            //5^2 expected 25
            driver.FindElement(By.XPath("/html/body/div[3]/div/table/tbody/tr/td[1]/table/tbody/tr[2]/td[2]/div/div[2]/span[2]")).Click();
            driver.FindElement(By.XPath(pow)).Click();
            driver.FindElement(By.XPath("/html/body/div[3]/div/table/tbody/tr/td[1]/table/tbody/tr[2]/td[2]/div/div[3]/span[2]")).Click();

            //Gather result into a web element
            IWebElement resultElement = driver.FindElement(By.XPath(resultField));
            //convert result to a numerical value
            double result = double.Parse(resultElement.Text);

            //expected result for compare
            expectedResult = 25;

            //close browser
            driver.Close();

            //assert statement
            Assert.AreEqual(result, expectedResult);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            IWebDriver driver = new FirefoxDriver();

            driver.Manage().Window.Maximize();
            driver.Navigate().GoToUrl("http://google.com");


            PageFactory.InitElements(driver, Page.GooglePage);
            Page.GooglePage.input.SendKeys("selenium");
            driver.Close();
        }
コード例 #5
0
        static void Main(string[] args)
        {
            var driver = new FirefoxDriver()
            {
                Url = "http://localhost/selenium/index.php"
            };

            Thread.Sleep(2000);
            var element = driver.FindElementByName("imie");

            element.SendKeys("Jan");
            var element3 = driver.FindElementByName("nazwisko");

            element3.SendKeys("Kowalski");
            var element2 = driver.FindElementByName("submit");

            element2.Click();
            Thread.Sleep(5000);
            driver.Close();
        }