예제 #1
0
        private static string GetJxsscResult(string drawNo)
        {
            var url = "http://data.shishicai.cn/jxssc/haoma/";

            var driver = new PhantomJSDriver { Url = url };
            driver.Navigate();

            // the driver can now provide you with what you need (it will execute the script)
            // get the source of the page
            var source = driver.PageSource;

            // fully navigate the dom
            var drawResultElements = driver.FindElementByClassName("newNum").FindElements(By.CssSelector("table[class='data_tab'] tbody tr"));
            var result = string.Empty;

            foreach (var draws in drawResultElements)
            {
                var drawElemnet = draws.Text.Split(' ');
                if (drawElemnet[0].Contains(drawNo))
                {
                    result = string.Join(",", drawElemnet.Select(o => o.ToString()).ToArray());
                    break;
                }
            }

            driver.Close();
            return result;
        }
예제 #2
0
        public void WithoutPassenger()
        {
            using (var webdriver = new PhantomJSDriver())
            {
                webdriver.Navigate().GoToUrl("http://www.amazon.co.uk");
                var myElement = webdriver.FindElementById("twotabsearchtextbox");

                myElement.Click();
                myElement.SendKeys("Game of thrones");

                var goButton = webdriver.FindElementByClassName("nav-searchbar");
                goButton.Submit();

                var allH2s = webdriver.FindElementsByTagName("h2");

                var oneWithGameOfThrones = allH2s.Where(x => x.Text == "Game of Thrones - Season 4");

                Assert.That(oneWithGameOfThrones, Is.Not.Null);
            }
        }