コード例 #1
0
        public RegisterUserPoland()
        {
            _logger.Trace("Start RegisterUserPoland constructor");
#if UsePhantomJSDriver
            _driver = new PhantomJSDriver();
#else
            var prof = new FirefoxProfile();
            prof.SetPreference("browser.startup.homepage_override.mstone",
                               "ignore");
            prof.SetPreference("startup.homepage_welcome_url.additional",
                               "about:blank");
            prof.EnableNativeEvents = false;
            _driver = new FirefoxDriver(prof);
#endif
            _driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMinutes(15));
            _driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromMinutes(15));
            _driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromMinutes(15));
            Error    = false;
            Canceled = false;
            RegistrarionDateAvailability = DialogResult.None;
#if UseDefaultSelenium
            int       port     = 4444; //2310;
            ISelenium selenium = new DefaultSelenium("localhost", port, "*firefox C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe", mainUrl);
#endif
            _logger.Trace("End RegisterUserPoland constructor");
        }
コード例 #2
0
        /// <summary>
        /// Creates an instance of selenium to be used by the user
        /// </summary>
        /// <param name="serverHost">the server hosting the site to be tested</param>
        /// <param name="serverPort">the port that selenium use for running</param>
        /// <param name="browserString">string holding the browser that we want to test in</param>
        /// <param name="browserUrl">Url to open to begin testing</param>
        /// <returns>Instance of selenium ready to use</returns>
        /// <exception cref="ArgumentNullException">This exception is thrown if any of the expected
        /// string arguments are passed as null or empty string</exception>
        public ISelenium CreateInstance(string serverHost, int serverPort, string browserString, string browserUrl)
        {
            if (string.IsNullOrEmpty(serverHost))
            {
                throw new ArgumentNullException("serverHost");
            }

            if (string.IsNullOrEmpty(browserString))
            {
                throw new ArgumentNullException("browserString");
            }

            if (string.IsNullOrEmpty(browserUrl))
            {
                throw new ArgumentNullException("browserUrl");
            }

            // If the actual selenium server isn't running then we need to start it up
            if (!SeleniumServerStarted)
            {
                Server.Start();
            }

            ISelenium newInstance = new DefaultSelenium(serverHost, serverPort, browserString, browserUrl);

            Instances.Add(newInstance);

            newInstance.Start();

            return(newInstance);
        }
コード例 #3
0
        public void SmokeTest()
        {
            this.testURL = "http://localhost/test/WebTestIntro/SmokeTest.aspx";

            this.browser = new DefaultSelenium("localhost", 4444, "*iexplore", this.testURL);
            this.browser.Start();
            this.browser.Open(this.testURL);
            Assert.AreEqual(this.testURL, this.browser.GetLocation());
        }
コード例 #4
0
        [SetUp()] protected void SetUp()
        {
            this.testURL = @"http://localhost/test/WebTestIntro/BirthdayClubMemberInfo.aspx";

            // 4444 is the default port for the Selenium Server
            this.browser = new DefaultSelenium("localhost", 4444, "*iexplore", this.testURL);
            this.browser.Start();
            this.browser.Open(this.testURL);
            Assert.AreEqual(this.testURL, this.browser.GetLocation());
        }
コード例 #5
0
        public void SearchAndWaitBySeleniumRemoteControl()
        {
            //not working on latest IE and FireFox versions
            ISelenium sel = new DefaultSelenium("localhost", 4444, "*iehta", "http://www.google.com");

            sel.Start();
            sel.Open("http://www.google.com/");
            sel.Type("q", "FitNesse");
            sel.Click("btnG");
            sel.WaitForPageToLoad("3000");
        }
コード例 #6
0
        public static ISelenium InitializeWebTest()
        {
            // ISelenium selenium = new DefaultSelenium("localhost", 4444, "*iexplore", startPage);
            ISelenium selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://localhost:4444");

            selenium.Start();

            //  selenium.Open(startPage);
            //selenium.WaitForPageToLoad("30000");

            return(selenium);
        }
コード例 #7
0
        protected void SetUp()
        {
            // set test URL
            this.testURL = "http://localhost/test/WebTestIntro/SeleniumExample.aspx";

            // Instantiate Selenium and start the browser (I believe this is where it actually creates a browser window)
            // 4444 is the default port for the Selenium Server
            this.browser = new DefaultSelenium("localhost", 4444, "*iexplore", this.testURL);
            this.browser.Start();

            // navigate to the page
            this.browser.Open(this.testURL);

            // verify we made it to the page
            Assert.AreEqual(this.testURL, this.browser.GetLocation());
        }
コード例 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SeleniumTesterBase"/> class.
        /// </summary>
        /// <param name="testCaseName">Name of the test case.</param>
        public SeleniumTesterBase(string testCaseName) : base(testCaseName)
        {
            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            browserType = (BrowserType)Enum.Parse(
                typeof(BrowserType),
                ConfigurationManager.AppSettings["BrowserType"],
                true);
            testMachine  = ConfigurationManager.AppSettings["TestMachine"];
            seleniumPort = int.Parse(
                ConfigurationManager.AppSettings["SeleniumPort"],
                CultureInfo.InvariantCulture);
            seleniumSpeed = ConfigurationManager.AppSettings["SeleniumSpeed"];
            browserUrl    = ConfigurationManager.AppSettings["BrowserUrl"];

            string browserExe;

            switch (browserType)
            {
            case BrowserType.InternetExplorer:
                browserExe = "*iexplore";
                break;

            case BrowserType.Firefox:
                browserExe = "*firefox";
                break;

            default:
                throw new NotSupportedException();
            }

            selenium = new DefaultSelenium(testMachine, seleniumPort, browserExe, browserUrl);
            selenium.Start();

            Console.WriteLine("Started Selenium session (browser type={0})", browserType);

            // sets the speed of execution of GUI commands
            if (false == String.IsNullOrEmpty(seleniumSpeed))
            {
                selenium.SetSpeed(seleniumSpeed);
            }
        }
コード例 #9
0
        ///<summary>
        ///Recursive Method, recall this method when timeout or other errors happend
        ///Call PDFAnalysis method to download PDF from from http://www.hkexnews.hk/listedco/listconews/advancedsearch/search_active_main.asp
        ///and extract data from PDF  by specific stock code
        ///</summary>
        ///<param name="index">ricList index</param>
        ///<returns> void </returns>
        private void DataCaptureFromPDF(int index)
        {
            ISelenium pdfSearch1     = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.hkexnews.hk");
            int       start_position = index;

            pdfSearch1.Start();
            try
            {
                pdfSearch1.Open("/listedco/listconews/advancedsearch/search_active_main.asp");
                pdfSearch1.WaitForPageToLoad("60000");

                for (; start_position < ricList.Count; start_position++)
                {
                    pdfSearch1.Type("txt_stock_code", ricList[start_position].ricCodeStr);
                    pdfSearch1.Click("//table[@id='Table1']/tbody/tr[3]/td/table[2]/tbody/tr/td/table/tbody/tr[14]/td[3]/label/a[1]/img");
                    pdfSearch1.WaitForPageToLoad("30000");

                    String pdfUrl = pdfSearch1.GetAttribute("//table[@id='Table4']/tbody/tr[8]/td/table/tbody/tr[3]/td[4]/table/tbody/tr/td/a@href");
                    pdfList.Add(coreObj.PDFAnalysis(pdfUrl, ricList[start_position].ricCodeStr));

                    pdfSearch1.Click("//table[@id='Table5']/tbody/tr/td/table/tbody/tr/td[1]/a/img");
                    pdfSearch1.WaitForPageToLoad("30000");
                }

                pdfSearch1.Close();
                pdfSearch1.Stop();
            }
            catch (Exception ex)
            {
                String errLog = ex.ToString();
                coreObj.WriteLogFile(errLog);
                coreObj.WriteLogFile(ricList[start_position].ricCodeStr);
                coreObj.WriteLogFile("start_position=" + start_position);
                pdfSearch1.Close();
                pdfSearch1.Stop();

                DataCaptureFromPDF(start_position);
            }
        }
コード例 #10
0
ファイル: TestFixtureWeb.cs プロジェクト: nbl852003/iudico
        /// <summary>
        /// Initializes a new instance of the <see cref="SeleniumTesterBase"/> class.
        /// </summary>
        public TestFixtureWeb()
            : base()
        {
            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            browserType = (BrowserType)Enum.Parse(
                typeof(BrowserType),
                ConfigurationManager.AppSettings["SELENIUM_BROWSER"],
                true);
            testMachine  = ConfigurationManager.AppSettings["SELENIUM_HOST"];
            seleniumPort = int.Parse(
                ConfigurationManager.AppSettings["SELENIUM_PORT"],
                CultureInfo.InvariantCulture);
            seleniumSpeed = ConfigurationManager.AppSettings["SELENIUM_SPEED"];
            browserUrl    = ConfigurationManager.AppSettings["SELENIUM_URL"];

            string browserExe;

            switch (browserType)
            {
            case BrowserType.InternetExplorer:
                browserExe = "*iexplore";
                break;

            case BrowserType.Firefox:
                browserExe = "*firefox";
                break;

            default:
                throw new NotSupportedException();
            }

            selenium = new DefaultSelenium(testMachine, seleniumPort, browserExe, browserUrl);
            //selenium.SetTimeout("1000000");

            Console.WriteLine("Started Selenium session (browser type={0})", browserType);
        }
コード例 #11
0
        //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());
            }
        }
コード例 #12
0
 public virtual void Setup()
 {
     Selenium = new DefaultSelenium(localhost, 5555, _browser, "http://www.google.com/");
     Selenium.Start();
 }
コード例 #13
0
 public void SetUp()
 {
     browser = new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:49278");
     browser.Start();
 }
コード例 #14
0
 public void SetupTest()
 {
     mockProcessor = new DynamicMock(typeof(ICommandProcessor));
     processor     = (ICommandProcessor)mockProcessor.MockInstance;
     selenium      = new DefaultSelenium(processor);
 }
コード例 #15
0
 public virtual void Setup()
 {
     browser  = PNUnitServices.Get().GetTestParams();
     Selenium = new DefaultSelenium(localhost, 5555, browser, "http://www.google.com/");
     Selenium.Start();
 }