Powered By Blogger

Search Here!

Showing posts with label Search Text using Pagination. Show all posts
Showing posts with label Search Text using Pagination. Show all posts

Thursday, April 26, 2012

Selenium RC: Search Text using Pagination !

Sometimes, we want to search a value in absence of search function due to it's not implemented. There is a problem through Selenium to get the value in a table that contains pagination. This method helps you to find search value from the table using pagination.  tableName is the Table locator and searchText is the name of the text that you want to search.


        public static int SearchTextFromPaginationGrid(string tableName, string searchText)
        {
            ISelenium Selenium = GetSeleniumInstance();
            int table_employee;
            string gridID = string.Empty; ;
            bool value = true;
            do
            {
                string get_text = Selenium.GetText(gridIDLoc);
                 table_employee  = get_text.IndexOf(searchText);
                if (gridIDLoc.Contains("'"))
                {
                    string[] SplittedLoc = gridIDLoc.Split('\'');
                    gridID = SplittedLoc[1];
                }
                value = Selenium.IsElementPresent("id=" + gridID + "$next");
                if (value == true)
                {
                    Selenium.Click("id=" + gridID + "$next");
                    Thread.Sleep(2000);
                }
                WaitUntilElement(gridID);
            } while (value && table_txt < 0);
            return  table_employee;
        }