コード例 #1
0
 public void beforeClass()
 {
     Driver = new FirefoxDriver();
     Selenium = new WebDriverBackedSelenium(Driver, Utils.baseUrl);
     Selenium.Start();
     Selenium.WindowMaximize();
 }
コード例 #2
0
        public virtual void SetupTest()
        {
            path = ConfigurationManager.AppSettings["ContentPath"].ToString();
            driver = new FirefoxDriver();

            selenium = new WebDriverBackedSelenium(driver, ConfigurationManager.AppSettings["_3DRURL"]);
            verificationErrors = new StringBuilder();
            selenium.Start();
            selenium.Open("/Default.aspx");
            selenium.WindowFocus();
            isSeleniumRunning = true;
        }
コード例 #3
0
        static void Main(string[] args)
        {
            try
            {
                string baseUrl = "http://www.amazon.com/";
                if (args.Length >= 1)
                {
                    baseUrl = args[0];
                }

                string filename;
                if (args.Length >= 2)
                {
                    filename = args[1];
                }
                else
                {
                    Uri uri = new Uri(baseUrl);
                    filename = uri.Host.Replace(".", "-") + @".har";
                }

                // Uncomment to enable SSL support
                // Fiddler.CONFIG.IgnoreServerCertErrors = true;
                // FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

                // Varibale to store the list of items downloaded
                var sessions = new List<Fiddler.Session>();
                var newSessions = new List<Fiddler.Session>();
                int browserProcessId = -1;

                // As each HTTP item is downloaded add it to our list.
                // We will export this list later.
                Fiddler.FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS)
                {
                    Monitor.Enter(sessions);
                    // Only record HTTP traffic by our browser process
                    if (browserProcessId == oS.LocalProcessID)
                    {
                        sessions.Add(oS);
                    }
                    Monitor.Exit(sessions);
                };

                Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
                {
                    // Record the process id for the first URL we go to,
                    // this is the browser that we lanched with Selenium
                    // Could also do extra verification here, for example
                    // check that it is a child process, of this process.
                    // That requires some heavy Win32 API usage, so I've
                    // skipped it here.
                    if (browserProcessId == -1 && oS.fullUrl == baseUrl)
                    {
                        browserProcessId = oS.LocalProcessID;
                    }

                    // Only record HTTP traffic by our browser process
                    if (browserProcessId == oS.LocalProcessID)
                    {
                        Monitor.Enter(newSessions);
                        newSessions.Add(oS);
                        Monitor.Exit(newSessions);
                    }
                };

                // Start Fiddler on port 8877.
                // Register as the system wide proxy.
                Fiddler.FiddlerApplication.Startup(8877, FiddlerCoreStartupFlags.Default);

                /////////////////////////////////////////////////
                // Begin selenium test
                /////////////////////////////////////////////////

                var webDriver = new OpenQA.Selenium.Firefox.FirefoxDriver();
                var selenium = new Selenium.WebDriverBackedSelenium(webDriver, baseUrl);

                selenium.Start();
                selenium.Open(baseUrl);

                // Wait until 3 seconds of HTTP idle (no request being processed for 3 seconds)
                // or a 30 second timeout.
                // 'result' will be false if items are still being downloaded when the timeout
                // occurs.
                bool result = WaitHttpIdle(sessions, 3000, 30000);
                selenium.Stop();

                /////////////////////////////////////////////////
                // End selenium test
                /////////////////////////////////////////////////

                // Load the HAR file exporter (this only has to be done once per process).
                // The following DLL was downloaded from:
                // https://www.fiddler2.com/dl/FiddlerCore-BasicFormats.zip
                // It is currently only loadable with FiddlerCode 2.2.9.9.
                String path = Path.Combine(Path.GetDirectoryName
                    (Assembly.GetExecutingAssembly().Location), @"FiddlerCore-BasicFormats.dll");
                FiddlerApplication.oTranscoders.ImportTranscoders(path);

                // Export fiddler sessions to HAR file
                Monitor.Enter(sessions);
                var oExportOptions = new Dictionary<string, object>();
                oExportOptions.Add("Filename", filename);
                bool fiddler = Fiddler.FiddlerApplication.DoExport("HTTPArchive v1.2", sessions.ToArray(), oExportOptions, null);
                sessions.Clear();
                Monitor.Exit(sessions);
            }
            finally
            {
                // Shutdown fiddler, this removes Fiddler as the system proxy.
                Fiddler.FiddlerApplication.Shutdown();
                Thread.Sleep(500);
            }
        }
コード例 #4
0
        static void Main(string[] args)
        {
            try
            {
                string baseUrl = "http://www.webmetrics.com";
                if (args.Length >= 1)
                {
                    baseUrl = args[0];
                }

                string filename;
                if (args.Length >= 2)
                {
                    filename = args[1];
                }
                else
                {
                    Uri uri = new Uri(baseUrl);
                    filename = uri.Host.Replace(".", "-") + @".har";
                }

                // Uncomment to enable SSL support
                // Fiddler.CONFIG.IgnoreServerCertErrors = true;
                // FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

                // Varibale to store the list of items downloaded
                var sessions = new List<Fiddler.Session>();

                // As each HTTP item is downloaded add it to our list.
                // We will export this list later.
                Fiddler.FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS)
                {
                    Monitor.Enter(sessions);
                    sessions.Add(oS);
                    Monitor.Exit(sessions);
                };

                // As each HTTP item is downloaded add it to our list.
                // We will export this list later.
                Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
                {
                    if (!new Regex(baseUrl).IsMatch(oS.fullUrl))
                    {
                        oS.utilCreateResponseAndBypassServer();
                        oS.responseCode = 200;
                    }
                };

                // Start Fiddler on port 8877.
                // Register as the system wide proxy.
                Fiddler.FiddlerApplication.Startup(8877, FiddlerCoreStartupFlags.Default);

                /////////////////////////////////////////////////
                // Begin selenium test
                /////////////////////////////////////////////////

                var webDriver = new OpenQA.Selenium.Firefox.FirefoxDriver();
                var selenium = new Selenium.WebDriverBackedSelenium(webDriver, baseUrl);

                selenium.Start();
                selenium.Open(baseUrl);
                selenium.WaitForPageToLoad("30000");
                selenium.Stop();

                /////////////////////////////////////////////////
                // End selenium test
                /////////////////////////////////////////////////

                // Load the HAR file exporter (this only has to be done once per process).
                // The following DLL was downloaded from:
                // https://www.fiddler2.com/dl/FiddlerCore-BasicFormats.zip
                // It is currently only loadable with FiddlerCode 2.2.9.9.
                String path = Path.Combine(Path.GetDirectoryName
                    (Assembly.GetExecutingAssembly().Location), @"FiddlerCore-BasicFormats.dll");
                FiddlerApplication.oTranscoders.ImportTranscoders(path);

                // Export fiddler sessions to HAR file
                Monitor.Enter(sessions);
                var oExportOptions = new Dictionary<string, object>();
                oExportOptions.Add("Filename", filename);
                bool fiddler = Fiddler.FiddlerApplication.DoExport("HTTPArchive v1.2", sessions.ToArray(), oExportOptions, null);
                sessions.Clear();
                Monitor.Exit(sessions);
            }
            finally
            {
                // Shutdown fiddler, this removes Fiddler as the system proxy.
                Fiddler.FiddlerApplication.Shutdown();
                Thread.Sleep(500);
            }
        }
コード例 #5
0
ファイル: Common.cs プロジェクト: hemap/PhoenixAutomationRepo
        /// <summary>
        /// Login to Openbet admin
        /// </summary>
        /// Authour: pradeep
        /// Created Date: 02-Feb-2012
        public ISelenium LogOnToAdmin()
        {
            IWebDriver ffDriver = new FirefoxDriver();
            ISelenium myBrowser = new WebDriverBackedSelenium(ffDriver, FrameGlobals.AdminBase);
            myBrowser.Start();
            myBrowser.Open(FrameGlobals.AdminBase);
            ffDriver.Manage().Window.Maximize();
            myBrowser.WaitForPageToLoad(FrameGlobals.PageLoadTimeOut);
            // PreProd has some issues
            myBrowser.Refresh();
            myBrowser.WaitForPageToLoad(FrameGlobals.PageLoadTimeOut);

            myBrowser.Type(AdminSuite.CommonControls.AdminHomePage.UsrNmeTxtBx, FrameGlobals.AdminUserName);
            myBrowser.Type(AdminSuite.CommonControls.AdminHomePage.PwdTxtBx, FrameGlobals.AdminPassWord);
            myBrowser.WaitForPageToLoad(FrameGlobals.PageLoadTimeOut);
            myBrowser.Click(AdminSuite.CommonControls.AdminHomePage.LoginBtn);
            myBrowser.WaitForPageToLoad(FrameGlobals.PageLoadTimeOut);
            Thread.Sleep(2000);

            return myBrowser;
        }
コード例 #6
0
        static void Main(string[] args)
        {
            try
            {
                string baseUrl = "http://www.amazon.com/";
                if (args.Length >= 1)
                {
                    baseUrl = args[0];
                }

                string filename;
                if (args.Length >= 2)
                {
                    filename = args[1];
                }
                else
                {
                    Uri uri = new Uri(baseUrl);
                    filename = uri.Host.Replace(".", "-") + @".har";
                }

                // Uncomment to enable SSL support
                // Fiddler.CONFIG.IgnoreServerCertErrors = true;
                // FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

                // Varibale to store the list of items downloaded
                var sessions         = new List <Fiddler.Session>();
                var newSessions      = new List <Fiddler.Session>();
                int browserProcessId = -1;

                // As each HTTP item is downloaded add it to our list.
                // We will export this list later.
                Fiddler.FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS)
                {
                    Monitor.Enter(sessions);
                    // Only record HTTP traffic by our browser process
                    if (browserProcessId == oS.LocalProcessID)
                    {
                        sessions.Add(oS);
                    }
                    Monitor.Exit(sessions);
                };

                Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
                {
                    // Record the process id for the first URL we go to,
                    // this is the browser that we lanched with Selenium
                    // Could also do extra verification here, for example
                    // check that it is a child process, of this process.
                    // That requires some heavy Win32 API usage, so I've
                    // skipped it here.
                    if (browserProcessId == -1 && oS.fullUrl == baseUrl)
                    {
                        browserProcessId = oS.LocalProcessID;
                    }

                    // Only record HTTP traffic by our browser process
                    if (browserProcessId == oS.LocalProcessID)
                    {
                        Monitor.Enter(newSessions);
                        newSessions.Add(oS);
                        Monitor.Exit(newSessions);
                    }
                };

                // Start Fiddler on port 8877.
                // Register as the system wide proxy.
                Fiddler.FiddlerApplication.Startup(8877, FiddlerCoreStartupFlags.Default);

                /////////////////////////////////////////////////
                // Begin selenium test
                /////////////////////////////////////////////////

                var webDriver = new OpenQA.Selenium.Firefox.FirefoxDriver();
                var selenium  = new Selenium.WebDriverBackedSelenium(webDriver, baseUrl);

                selenium.Start();
                selenium.Open(baseUrl);

                // Wait until 3 seconds of HTTP idle (no request being processed for 3 seconds)
                // or a 30 second timeout.
                // 'result' will be false if items are still being downloaded when the timeout
                // occurs.
                bool result = WaitHttpIdle(sessions, 3000, 30000);
                selenium.Stop();

                /////////////////////////////////////////////////
                // End selenium test
                /////////////////////////////////////////////////

                // Load the HAR file exporter (this only has to be done once per process).
                // The following DLL was downloaded from:
                // https://www.fiddler2.com/dl/FiddlerCore-BasicFormats.zip
                // It is currently only loadable with FiddlerCode 2.2.9.9.
                String path = Path.Combine(Path.GetDirectoryName
                                               (Assembly.GetExecutingAssembly().Location), @"FiddlerCore-BasicFormats.dll");
                FiddlerApplication.oTranscoders.ImportTranscoders(path);

                // Export fiddler sessions to HAR file
                Monitor.Enter(sessions);
                var oExportOptions = new Dictionary <string, object>();
                oExportOptions.Add("Filename", filename);
                bool fiddler = Fiddler.FiddlerApplication.DoExport("HTTPArchive v1.2", sessions.ToArray(), oExportOptions, null);
                sessions.Clear();
                Monitor.Exit(sessions);
            }
            finally
            {
                // Shutdown fiddler, this removes Fiddler as the system proxy.
                Fiddler.FiddlerApplication.Shutdown();
                Thread.Sleep(500);
            }
        }
コード例 #7
0
        static void Main(string[] args)
        {
            try
            {
                string baseUrl = "http://www.webmetrics.com";
                if (args.Length >= 1)
                {
                    baseUrl = args[0];
                }

                string filename;
                if (args.Length >= 2)
                {
                    filename = args[1];
                }
                else
                {
                    Uri uri = new Uri(baseUrl);
                    filename = uri.Host.Replace(".", "-") + @".har";
                }

                // Uncomment to enable SSL support
                // Fiddler.CONFIG.IgnoreServerCertErrors = true;
                // FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

                // Varibale to store the list of items downloaded
                var sessions = new List <Fiddler.Session>();

                // As each HTTP item is downloaded add it to our list.
                // We will export this list later.
                Fiddler.FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS)
                {
                    Monitor.Enter(sessions);
                    sessions.Add(oS);
                    Monitor.Exit(sessions);
                };

                // As each HTTP item is downloaded add it to our list.
                // We will export this list later.
                Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
                {
                    if (!new Regex(baseUrl).IsMatch(oS.fullUrl))
                    {
                        oS.utilCreateResponseAndBypassServer();
                        oS.responseCode = 200;
                    }
                };

                // Start Fiddler on port 8877.
                // Register as the system wide proxy.
                Fiddler.FiddlerApplication.Startup(8877, FiddlerCoreStartupFlags.Default);

                /////////////////////////////////////////////////
                // Begin selenium test
                /////////////////////////////////////////////////

                var webDriver = new OpenQA.Selenium.Firefox.FirefoxDriver();
                var selenium  = new Selenium.WebDriverBackedSelenium(webDriver, baseUrl);

                selenium.Start();
                selenium.Open(baseUrl);
                selenium.WaitForPageToLoad("30000");
                selenium.Stop();

                /////////////////////////////////////////////////
                // End selenium test
                /////////////////////////////////////////////////

                // Load the HAR file exporter (this only has to be done once per process).
                // The following DLL was downloaded from:
                // https://www.fiddler2.com/dl/FiddlerCore-BasicFormats.zip
                // It is currently only loadable with FiddlerCode 2.2.9.9.
                String path = Path.Combine(Path.GetDirectoryName
                                               (Assembly.GetExecutingAssembly().Location), @"FiddlerCore-BasicFormats.dll");
                FiddlerApplication.oTranscoders.ImportTranscoders(path);

                // Export fiddler sessions to HAR file
                Monitor.Enter(sessions);
                var oExportOptions = new Dictionary <string, object>();
                oExportOptions.Add("Filename", filename);
                bool fiddler = Fiddler.FiddlerApplication.DoExport("HTTPArchive v1.2", sessions.ToArray(), oExportOptions, null);
                sessions.Clear();
                Monitor.Exit(sessions);
            }
            finally
            {
                // Shutdown fiddler, this removes Fiddler as the system proxy.
                Fiddler.FiddlerApplication.Shutdown();
                Thread.Sleep(500);
            }
        }
コード例 #8
0
 public virtual void SetupTest(string browser)
 {
     //AddText("Testing URL:" + baseURL, fonttype.ScriptFont);
     AddText("\nBrowser " + browser + " initialized.", fonttype.Browserfont);
     reporterBox.SelectionFont = regulartext;
     switch (browser)
     {
         case "Internet Explorer":
             webdriver = new WebDriverBackedSelenium(new InternetExplorerDriver(),baseURL);
             webdriver.Start();
             break;
         case "Chrome":
             webdriver = new WebDriverBackedSelenium(new ChromeDriver(), baseURL);
             webdriver.Start();
             break;
         case "FireFox":
             webdriver = new WebDriverBackedSelenium(new FirefoxDriver(ffprofile), baseURL);
             webdriver.Start();
             break;
     }
 }
コード例 #9
0
ファイル: Drivers.cs プロジェクト: geeksree/cSharpGeeks
        public void WaitForPageLoaded(int Timeout)
        {
            WebDriverBackedSelenium aDriverBackedSelenium = new WebDriverBackedSelenium(BrowserHandle, Url);

            aDriverBackedSelenium.Start();
            aDriverBackedSelenium.WaitForPageToLoad(Timeout.ToString(CultureInfo.InvariantCulture));
        }