Пример #1
0
        private static void SelectDropDown(string xpath, string value)
        {
            var education = TestWebDriver.FindElement(By.XPath(xpath));
            //create select element object
            var selectElement = new SelectElement(education);

            //select by value
            selectElement.SelectByText(value);
        }
Пример #2
0
        public void Kilauea_Test()
        {
            int    startIndex;
            int    endIndex;
            string textTochange;

            string url = "https://volcanoes.usgs.gov/vhp/archive_search.html";

            NewMethod(url);

            SelectDropDown("//select[@id='typecd']", "Daily Update");
            SelectDropDown("//select[@id='vcd']", "Kilauea");

            List <string> dateList = GetDates();
            string        startDate, endDate;

            foreach (string value in dateList)
            {
                startDate = value.Substring(0, 10);
                endDate   = value.Substring(11, 10);

                TypeText("//input[@id='startdate']", startDate);
                TypeText("//input[@id='enddate']", endDate);
                TestWebDriver.FindElement(By.XPath("//input[@id='enddate']")).SendKeys(Keys.Tab);

                Thread.Sleep(3000);
                ClickElement("//input[@type='submit']");
                Thread.Sleep(3000);

                textTochange = GetText("//div[@id='results_DIV']");

                #region old
                //try
                //{
                //    startIndex = textTochange.IndexOf("class=\"text-center\"");
                //    endIndex = textTochange.IndexOf("<b>KILAUEA VOLCANO</b>");
                //    RemoveTags(textTochange, startIndex, endIndex);

                //    startIndex = textTochange.IndexOf("<b>KILAUEA VOLCANO</b>");
                //    endIndex = textTochange.IndexOf("name=\"summary\"");
                //    RemoveTags(textTochange, startIndex, endIndex);

                //    startIndex = textTochange.IndexOf("name=\"summary\"");
                //    endIndex = textTochange.IndexOf("Lava Flow Observations:");
                //    RemoveTags(textTochange, startIndex, endIndex);

                //    startIndex = textTochange.IndexOf("Lava Flow Observations:");
                //    endIndex = textTochange.IndexOf("Puʻu ʻŌʻō Observations:");
                //    RemoveTags(textTochange, startIndex, endIndex);

                //    startIndex = textTochange.IndexOf("Puʻu ʻŌʻō Observations:");
                //    endIndex = textTochange.IndexOf("Summit Observations:");
                //    RemoveTags(textTochange, startIndex, endIndex);

                //    startIndex = textTochange.IndexOf("Summit Observations:");
                //    endIndex = textTochange.IndexOf("Sulfur Dioxide Emission Rate estimation caveat:");
                //    RemoveTags(textTochange, startIndex, endIndex);

                //    startIndex = textTochange.IndexOf("Sulfur Dioxide Emission Rate estimation caveat:");
                //    endIndex = textTochange.IndexOf("Background:");
                //    RemoveTags(textTochange, startIndex, endIndex);

                //    startIndex = textTochange.IndexOf("Background:");
                //    endIndex = textTochange.IndexOf("Hazard Summary:");
                //    RemoveTags(textTochange, startIndex, endIndex);
                //    Trace.Write(Environment.NewLine);

                //}
                //catch (Exception e)
                //{
                //    Trace.Write(Environment.NewLine);
                //}
                #endregion
                textTochange = PrepareData(textTochange);
                Thread.Sleep(3000);
                ClickElement("//a[@class='search-control ssf']");
                Thread.Sleep(3000);
            }
        }
Пример #3
0
 private static void TypeText(string xpath, string value)
 {
     TestWebDriver.FindElement(By.XPath(xpath)).Clear();
     TestWebDriver.FindElement(By.XPath(xpath)).SendKeys(value);
 }
Пример #4
0
 private static void ClickElement(string xpath)
 {
     TestWebDriver.FindElement(By.XPath(xpath)).Click();
 }
Пример #5
0
 private static string GetText(string xpath)
 {
     return(TestWebDriver.FindElement(By.XPath(xpath)).GetAttribute("innerHTML"));
 }