예제 #1
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();
        }
예제 #2
0
        public void LogTest()
        {
            //initialise pre reqs
            double     expectedResult;
            IWebDriver driver = new FirefoxDriver();

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

            //select equation sequence
            //log 1000 (expected 3) auto base 2
            driver.FindElement(By.XPath(log)).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[1]")).Click();
            driver.FindElement(By.XPath("/html/body/div[3]/div/table/tbody/tr/td[1]/table/tbody/tr[2]/td[2]/div/div[4]/span[1]")).Click();
            driver.FindElement(By.XPath("/html/body/div[3]/div/table/tbody/tr/td[1]/table/tbody/tr[2]/td[2]/div/div[4]/span[1]")).Click();
            driver.FindElement(By.XPath("/html/body/div[3]/div/table/tbody/tr/td[1]/table/tbody/tr[2]/td[2]/div/div[4]/span[1]")).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 = 3;

            //close browser
            driver.Close();

            //assert statement
            Assert.AreEqual(result, expectedResult);
        }
예제 #3
0
        public void LoginTest()
        {
            driver.Navigate().GoToUrl("http://*****:*****@id='loginForm']/form/div[4]/div/input")).Click();
            Thread.Sleep(2000);

            String actual = driver.FindElement(By.XPath(".//*[@id='logoutForm']/ul/li[1]")).Text;

            Assert.AreEqual("Hello Admin!", actual);
        }
예제 #4
0
        static void Main(string[] args)
        {
            IWebDriver driver = new FirefoxDriver();

            driver.Navigate().GoToUrl(@"https://pokemon-arena.co.il/");
            Console.WriteLine(driver.Url);
            //Login
            IWebElement _username = driver.FindElement(By.CssSelector("input[name='username']"));
            IWebElement _password = driver.FindElement(By.CssSelector("input[name='password']"));

            _username.SendKeys("YossiBz");
            _password.SendKeys("123456");
            driver.FindElement(By.CssSelector("input[name='login']")).Click();

            //Home Page
            Actions     action   = new Actions(driver);
            IWebElement _actions = driver.FindElement(By.CssSelector(".pokeicon.i-swords"));

            action.MoveToElement(_actions).Build().Perform();
            driver.FindElement(By.CssSelector("li.pokeicon.i-swords>ul>li>a")).Click();

            //Attack_Map
            driver.FindElement(By.CssSelector("input[alt='Grass field']")).Click();
            string      _pokemonName  = driver.FindElement(By.Id("pokemon_naam")).Text;
            IWebElement computer_life = driver.FindElement(By.Id("computer_life"));
            IWebElement pokemon_life  = driver.FindElement(By.Id("pokemon_life"));

            if (_pokemonName.IndexOf("Dratini") != -1 || _pokemonName.IndexOf("Gengar") != -1)
            {
                while (computer_life.GetCssValue("width") != "0px" && pokemon_life.GetCssValue("width") != "px")
                {
                    driver.FindElement(By.ClassName("attacko2")).Click();
                }
            }
            else if (_pokemonName.IndexOf("Charizard") != -1)
            {
                while (computer_life.GetCssValue("width") != "0px" && pokemon_life.GetCssValue("width") != "px")
                {
                    driver.FindElement(By.ClassName("attacko1")).Click();
                }
            }
            else if (_pokemonName.IndexOf("Poliwhirl") != -1 || _pokemonName.IndexOf("Horsea") != -1)
            {
                while (computer_life.GetCssValue("width") != "0px" && pokemon_life.GetCssValue("width") != "px")
                {
                    driver.FindElement(By.ClassName("attacko4")).Click();
                }
            }

            // driver.Quit();
        }
예제 #5
0
        public void TestFindYandex()
        {
            firefox.Navigate().GoToUrl("https://yandex.ru/");
            firefox.FindElement(By.Id("text")).SendKeys("Алгту");
            firefox.FindElement(By.XPath("//button[@type='submit']")).Click();
            String actualy = firefox.FindElementByClassName("organic__url-text").Text;

            Assert.AreEqual("Алтайский государственный технический университет", actualy);
        }