示例#1
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();
        }
        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();
        }
示例#3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //// ChromeDriver cd = new ChromeDriver();

            // profile
            // turn off webRTC
            FirefoxProfile firefoxProfile = new FirefoxProfile();

            if ((bool)cbProxyWebRTC.IsChecked)
            {
                firefoxProfile.SetPreference("media.peerconnection.enabled", false);
            }

            if ((bool)cbProxyEnabled.IsChecked)
            {
                // changes proxy
                string proxy_ip   = txtProxyIp.Text;
                int    proxy_port = int.Parse(txtProxyPort.Text);

                firefoxProfile.SetPreference("network.proxy.type", 1);
                firefoxProfile.SetPreference("network.proxy.http", proxy_ip);
                firefoxProfile.SetPreference("network.proxy.http_port", proxy_port);
                firefoxProfile.SetPreference("network.proxy.ssl", proxy_ip);
                firefoxProfile.SetPreference("network.proxy.ssl_port", proxy_port);
            }

            // init
            FirefoxDriver cd = new FirefoxDriver(firefoxProfile);

            if (!(bool)cbIsachInfo.IsChecked)
            {
                // go to link
                if (!String.IsNullOrEmpty(txtLink.Text))
                {
                    cd.Url = txtLink.Text;
                }
                else
                {
                    cd.Url = "https://whoer.net/";
                }

                cd.Navigate();
            }
            else
            {
                cd.Url = "https://isach.info/login.php";
                cd.Navigate();

                var search = cd.FindElementById("user_name");
                search.SendKeys(txtUser.Text);

                search = cd.FindElementById("user_password");
                search.SendKeys(passPass.Password);

                search.SendKeys(Keys.Return);

                // sleep
                Thread.Sleep(4000);

                // go home
                cd.Url = "https://isach.info";
                cd.Navigate();
            }
        }