Пример #1
0
        public void SearchBookName()
        {
            searchBook = ReadExcel.GetDataTable_OLE("SearchBook"); // Get test data from excel sheet

            try
            {
                driver.FindElement(SearchTextBox).SendKeys(searchBook.Rows[0]["Quotes"].ToString()); // Get input data from excel
                driver.FindElement(SearchButton).Click();

                IWebElement searchResult = CommonFunctions.WaitForElementVisible(driver, SearchResult); //Dynamic wait


                if (searchResult.Text.Contains("No results"))
                {
                    ilog.LogInfo("No book found for given input .please change the search parameters");
                }

                else if (searchResult.Text.Contains("Page 1 of about 1 results"))
                {
                    ilog.LogInfo("Found 1 book for given input. the book name is : " + driver.FindElement(BookFound).Text.ToString());
                }

                else
                {
                    ilog.LogException("Found more than 1 book for given input. please refine the  search parameters");
                }
            }

            catch (Exception ex)
            {
                ilog.LogException("Found exception during test execution : " + ex.Message);
                screenshot = driver as ITakesScreenshot;
                screenshot.GetScreenshot().SaveAsFile(AppDomain.CurrentDomain.BaseDirectory + "\\Logs\\Error.jpeg");
            }
        }
 public IWebDriver LaunchUrl()
 {
     driverloc = XmlHelper.GetElement("chrome");
     driver    = Browsers.setBrowserDriver(driverloc, "chrome");
     dt        = ReadExcel.GetDataTable_OLE("Login");
     driver.Navigate().GoToUrl(dt.Rows[0]["AppURL"].ToString());
     return(driver);
 }