//public static string GetDynamicPageSource(string uri, int timeout, string postData, string cookie)
        //{
        //    string pageSource = string.Empty;
        //    Encoding encoding = Encoding.UTF8;

        //    byte[] buf = null;
        //    int retryiesLeft = 5;
        //    buf = encoding.GetBytes(postData);

        //    while (string.IsNullOrEmpty(pageSource) && retryiesLeft-- > 0)
        //    {
        //        HttpWebRequest request = WebRequest.Create(uri) as HttpWebRequest;
        //        request.Timeout = timeout;
        //        request.Headers["Cookie"] = cookie;
        //        request.UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2";
        //        request.Method = "POST";
        //        request.ContentType = "application/x-www-form-urlencoded";
        //        request.ContentLength = buf.Length;
        //        request.GetRequestStream().Write(buf, 0, buf.Length);
        //        using (WebResponse response = request.GetResponse())
        //        {
        //            StreamReader sr = new StreamReader(response.GetResponseStream());
        //            pageSource = sr.ReadToEnd();
        //        }
        //    }
        //    if (pageSource == string.Empty)
        //    {
        //        throw new Exception(string.Format("Cannot download page {0}b with post data {1}", uri, postData));
        //    }
        //    return pageSource;
        //}

        //public static HttpWebResponse GetResponse(string uri, int timeout, string postData)
        //{
        //    string pageSource = string.Empty;
        //    Encoding encoding = Encoding.UTF8;

        //    byte[] buf = null;
        //    buf = encoding.GetBytes(postData);


        //    HttpWebRequest request = WebRequest.Create(uri) as HttpWebRequest;
        //    request.Timeout = timeout;
        //    //request.Headers["Cookie"] = "80922B3FB48D76DD2F6A268906563EC5.simpn9; Path=/ism";
        //    request.UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2";
        //    request.Method = "POST";
        //    request.ContentType = "application/x-www-form-urlencoded";
        //    request.ContentLength = buf.Length;
        //    request.GetRequestStream().Write(buf, 0, buf.Length);
        //    return request.GetResponse() as HttpWebResponse;
        //}

        //private void DataCaptureFromSetSmart(string symbol)
        //{
        //    string loginUrl = "http://www.setsmart.com/ism/login.jsp";
        //    string loginPostData = "txtLogin=25932633&txtPassword=reuters1&hidBrowser=null&hidLang=English";
        //    string searchUrl = "http://www.setsmart.com/ism/companyprofile.html";
        //    string searchData = "symbol=" + symbol;
        //    var req = GetResponse(loginUrl, 10000, loginPostData);
        //    var cookie = req.Headers["Set-Cookie"];
        //    cookie = cookie.Substring(0, cookie.IndexOf(";")).Trim();
        //    var content = GetDynamicPageSource(searchUrl, 10000, searchData, cookie);

        //}

        /**
         * Grab Data from http://isin.krx.co.kr/
         *
         */
        //private void DataCaptureFromSET()
        //{
        //    String symbolType = "SET";
        //    int startPosition = configObj.start_position;
        //    int endPosition = configObj.end_position;

        //    try
        //    {

        //        selenium.SetTimeout("50000");
        //        selenium.OpenWindow("/set/todaynews.do?language=en&country=US", "parentWindow");
        //        selenium.WaitForPopUp("parentWindow", "50000");
        //        selenium.SelectWindow("parentWindow");

        //        //No defination for searching end of position
        //        if (configObj.end_position == 0)
        //        {
        //            while (selenium.IsElementPresent("//tr[2]/td/table/tbody/tr[" + startPosition + "]/td[3]"))
        //            {
        //                String symbolStr = selenium.GetText("//tr[2]/td/table/tbody/tr[" + startPosition + "]/td[3]");
        //                if (symbolStr == symbolType)
        //                {
        //                    String headlineStr = selenium.GetText("//tr[2]/td/table/tbody/tr[" + startPosition + "]/td[4]");
        //                    if (headlineStr.Contains("adds new") && (headlineStr.Contains("CC") || headlineStr.Contains("CB") || headlineStr.Contains("CA") || headlineStr.Contains("CD") || headlineStr.Contains("CE") || headlineStr.Contains("CF")))
        //                    {

        //                        String htmlUrl = selenium.GetAttribute("//tr[2]/td/table/tbody/tr[" + startPosition + "]/td[5]/a[text()='HTML']@href");
        //                        selenium.OpenWindow(htmlUrl, "detailWindow" + startPosition);
        //                        selenium.WaitForPopUp("detailWindow" + startPosition, "10000");
        //                        selenium.SelectWindow("detailWindow" + startPosition);

        //                        String txtFile = selenium.GetText("//pre");

        //                        //here call txt analysis method
        //                        DataAnalysis(txtFile);

        //                        count++;
        //                        selenium.SelectWindow("parentWindow");

        //                    }
        //                }

        //                startPosition = startPosition + 2;
        //            }//end while

        //        }
        //        else if (configObj.end_position >= configObj.start_position)
        //        {
        //            for (int i = startPosition; i <= endPosition; i = i + 2)
        //            {
        //                String symbolStr = selenium.GetText("//tr[2]/td/table/tbody/tr[" + startPosition + "]/td[3]");
        //                if (symbolStr == symbolType)
        //                {
        //                    String headlineStr = selenium.GetText("//tr[2]/td/table/tbody/tr[" + startPosition + "]/td[4]");
        //                    if (headlineStr.Contains("adds new") && (headlineStr.Contains("CC") || headlineStr.Contains("CB") || headlineStr.Contains("CA") || headlineStr.Contains("CD") || headlineStr.Contains("CE") || headlineStr.Contains("CF")))
        //                    {

        //                        String htmlUrl = selenium.GetAttribute("//tr[2]/td/table/tbody/tr[" + startPosition + "]/td[5]/a[text()='HTML']@href");
        //                        selenium.OpenWindow(htmlUrl, "detailWindow" + startPosition);
        //                        selenium.WaitForPopUp("detailWindow" + startPosition, "10000");
        //                        selenium.SelectWindow("detailWindow" + startPosition);

        //                        String txtFile = selenium.GetText("//pre");

        //                        //here call txt analysis method
        //                        DataAnalysis(txtFile);

        //                        count++;
        //                        selenium.SelectWindow("parentWindow");

        //                    }
        //                }
        //            }//end for

        //        }//end else if
        //        else
        //        {
        //            logger.LogErrorAndRaiseException("end_position must bigger than start_position");
        //        }

        //    }//end try
        //    catch (SeleniumException e)
        //    {
        //        logger.LogErrorAndRaiseException(e.ToString());
        //        ClearTest();

        //    }

        //}//end DataCaptureFromSET()

        /**
         * Get ISIN number from http://isin.krx.co.kr by specific official code
         *
         */
        private String DataCaptureFromSetSmart(String officialCode)
        {
            ISelenium setsmart = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.setsmart.com");

            try
            {
                setsmart.Start();
                setsmart.UseXpathLibrary("javascript-xpath");
                setsmart.Open("/ism/login.jsp");
                setsmart.WaitForPageToLoad("60000");
                setsmart.Type("txtLogin", configObj.username);
                setsmart.Type("txtPassword", configObj.password);
                setsmart.Click("//input[@type='image']");
                //setsmart.Click("//input[@type='image' and @onclick='return validate();']");
                setsmart.WaitForPageToLoad("60000");
                setsmart.Click("link=Company Profile");
                setsmart.WaitForPageToLoad("60000");
                setsmart.Type("symbol", officialCode);
                setsmart.Click("//input[@type='image']");
                //setsmart.Click("//input[@name='submit' and @value='go' and @type='image' and @onclick=' return validateSubmit(); ']");

                System.Threading.Thread.Sleep(3000);

                String isinNumber = setsmart.GetText("//table[3]/tbody/tr[26]/td[2]");

                setsmart.Click("link=LOGOUT");
                setsmart.Stop();

                //return isinNumber.Substring(isinNumber.IndexOf("Local") + 8, isinNumber.IndexOf("Foreign") - 9);
                return(isinNumber.Substring(isinNumber.IndexOf("Local") + 7, isinNumber.Length - isinNumber.IndexOf("Local") - 7));
            }
            catch (SeleniumException e)
            {
                setsmart.Stop();
                logger.LogErrorAndRaiseException(e.ToString());
                return(e.ToString());
            }
        }