Exemplo n.º 1
0
 public void GoogleSearch()
 {
     selenium.Open("http://www.google.com/webhp");
     Assert.AreEqual("Google", selenium.GetTitle());
     selenium.Type("q", "Selenium OpenQA");
     Assert.AreEqual("Selenium OpenQA", selenium.GetValue("q"));
     selenium.Click("btnG");
     selenium.WaitForPageToLoad("5000");
     Assert.IsTrue(selenium.IsTextPresent("www.openqa.org"));
     Assert.AreEqual("Selenium OpenQA - Google Search", selenium.GetTitle());
 }
Exemplo n.º 2
0
 public void TestMethod3()
 {
     string URL = "http://www.abb.com";
     selenium = new DefaultSelenium("localhost", 4444, "*firefox", URL);
     selenium.Start();
     selenium.Open("/");
     Assert.AreEqual("The ABB Group - Automation and Power Technologies", selenium.GetTitle());
     selenium.Type("searchInput", "Robot");
     selenium.Click("search");
     selenium.WaitForPageToLoad("10000");
     Assert.AreEqual("The ABB Group", selenium.GetTitle());
     Assert.AreEqual("Robot", selenium.GetValue("searchInput"));
 }
Exemplo n.º 3
0
 private void handleKnownTestException(Exception e)
 {
     Console.Error.Write("Details: ");
     if (e.Message.Length > 0)
     {
         Console.Error.WriteLine(e.Message);
         if (Regex.IsMatch(e.Message, "ERROR: Element .* not found"))
         {
             Console.Error.WriteLine("Location:" + selenium.GetLocation());
             Console.Error.WriteLine("Page title: " + selenium.GetTitle());
             Console.Error.WriteLine("Fields are:");
             foreach (var field in selenium.GetAllFields())
             {
                 Console.Error.WriteLine(field);
             }
         }
     }
     else if (e is AssertionException)
     {
         Console.Error.WriteLine("Assertion failed. No message provided.");
     }
     else
     {
         Console.Error.WriteLine(
             "No useful exception message. Try to improve exception handling in WebTester once underlying problem is discovered. Main exception ToString: " + e);
     }
 }
Exemplo n.º 4
0
        public string GetTitle()
        {
            bool actRes = false; string errStr = "", resStr = "";

            try
            {
                resStr = selenium.GetTitle();
                actRes = true;
            }
            catch (System.Exception ex)
            {
                errStr = ex.ToString();
            }

            res = new ResultClass()
            {
                Decp = "GetValue",
                Res  = actRes ? "pass" : "fail",
                Tdev = " ms",
                Err  = errStr,
            };
            BaseListOfResItems.Add(res);

            return(resStr);
        }
Exemplo n.º 5
0
        public void SetupClass()
        {
            base.StartServer();
            selenium = new DefaultSelenium("localhost", 4444, "*chrome", ConfigurationManager.AppSettings["baseUrl"]);
            selenium.Start();
            verificationErrors = new StringBuilder();

            selenium.DeleteAllVisibleCookies();

            selenium.Open("/dna/mbfood/");
            // To Do
            // too general, could crash test if a topic happened to have the wrong name 
            Assert.IsFalse(selenium.IsTextPresent("error"));
            Assert.IsFalse(selenium.IsTextPresent("There has been a problem"));

            selenium.Click("link=Sign in");
            selenium.Click("bbcid_username");
            selenium.Type("bbcid_username", "mpgsuper");
            selenium.Type("bbcid_password", "ratbags");
            selenium.Click("signin");
            selenium.WaitForPageToLoad("30000");

            // going this way so as to be certain to get the right site options without thinking about it
            selenium.Click("link=Site Options");
            selenium.WaitForPageToLoad("30000");

            // check a) where we are b) BBC site requirements for page titles https://confluence.dev.bbc.co.uk/display/DNA/Meta+Data - note that this title breaks those guidelines
            Assert.AreEqual("BBC - Food - DNA Administration - Site Options - Food", selenium.GetTitle());
            Assert.IsTrue(selenium.IsElementPresent("//input[@name='sov_49_General_CustomBarlesquePath']");

            stateOfOption = selenium.GetValue("//input[@name='so_49_General_CustomBarlesquePath' and @type='radio' and @checked='']/@value");
            valueOfOption = selenium.GetValue("//input[@name='so_49_General_CustomBarlesquePath' and @type='text']");
        }
Exemplo n.º 6
0
        public void GoogleSearch()
        {
            //Opens up Google
            selenium.Open("http://www.google.com/webhp");

            //Verifies that the title matches
            Assert.AreEqual("Google", selenium.GetTitle());
            selenium.Type("q", "Selenium OpenQA");

            //Verifies that it can find the Selenium website
            Assert.AreEqual("Selenium OpenQA", selenium.GetValue("q"));
            selenium.Click("btnG");
            selenium.WaitForPageToLoad("5000");
            Assert.IsTrue(selenium.IsTextPresent("www.openqa.org"));
            Assert.AreEqual("Selenium OpenQA - Google Search", selenium.GetTitle());
        }
Exemplo n.º 7
0
 public void TheNewTest()
 {
     selenium.Open("/");
     selenium.Type("q", "selenium rc");
     selenium.Click("btnG");
     selenium.WaitForPageToLoad("30000");
     Console.WriteLine("selenium rc - Google Search" + "/Vs/" + selenium.GetTitle());
 }
Exemplo n.º 8
0
 /// <summary>
 /// Instantiates a new Home Page object. Pass in the Selenium object created in the test SetUp().
 /// When the object in instantiated it will navigate to the root
 /// </summary>
 /// <param name="selenium">Selenium Object created in the tests
 public Home(ISelenium selenium)
 {
     this._selenium = selenium;
     if (!selenium.GetTitle().Contains("home"))
     {
         selenium.Open("/");
     }
 }
Exemplo n.º 9
0
        private void setupBrowser()
        {
            // NOTE: These base URLs only work for systems who happen to have the same integration and localhost suffix (For example, localhost/RlePersonnel and integration.redstapler.biz/RlePersonnel).
            // Systems like MITCalendar will not work until we come up with a better solution.

            // NOTE: This should not be hard-coded.
            var baseUrl = "https://integration.redstapler.biz/";

            if (ConfigurationStatics.IsDevelopmentInstallation)
            {
                if (ConfigurationStatics.InstallationConfiguration.WebApplications.Any(wa => wa.SupportsSecureConnections))
                {
                    baseUrl = "https://localhost/";
                }
                else
                {
                    baseUrl = "http://localhost/";
                }
            }


            selenium = new DefaultSelenium("localhost" /*location of Selenium server*/, 4444, @"*firefox3 C:\Program Files (x86)\Mozilla Firefox\firefox.exe", baseUrl);
            selenium.Start();

            if (ConfigurationStatics.IsIntermediateInstallation)
            {
                executeSeleniumBlock(
                    "Intermediate log on",
                    delegate {
                    // NOTE: We need to go to the specific URL here instead of relying on a redirect, or Selenium will time out or otherwise fail (it sucks at following redirects).
                    selenium.Open("/" + ConfigurationStatics.InstallationConfiguration.SystemShortName + "/Ewf/IntermediateLogIn.aspx?ReturnUrl=");
                    // NOTE: Does not work for MIT Calendar, etc.
                    selenium.Type("ctl00_ctl00_main_contentPlace_ctl12_theTextBox", ConfigurationStatics.SystemGeneralProvider.IntermediateLogInPassword);
                    // NOTE: Move g8Summit to machine configuration file.
                    SubmitForm(selenium);
                    selenium.WaitForPageToLoad("30000");
                });
            }
            if (UserManagementStatics.UserManagementEnabled /* && FormsAuthStatics.FormsAuthEnabled */)
            {
                executeSeleniumBlock(
                    "Forms log on",
                    delegate {
                    // NOTE: System-name approach suffers from same problem as above.
                    selenium.Open("/" + ConfigurationStatics.InstallationConfiguration.SystemShortName + "/Ewf/UserManagement/LogIn.aspx?ReturnUrl=");

                    // NOTE: I don't think we need waits after opens.
                    selenium.WaitForPageToLoad("30000");
                    Assert.IsTrue(selenium.GetTitle().EndsWith("Log In"));
                    // NOTE: For RSIS, we need the ability to pass a different email address and a different password for testing.
                    //selenium.Type( "ctl00_ctl00_main_contentPlace_emailAddress_theTextBox", ConfigurationStatics.SystemGeneralProvider.FormsLogInEmail );
                    //selenium.Type( "ctl00_ctl00_main_contentPlace_password_theTextBox", ConfigurationStatics.SystemGeneralProvider.FormsLogInPassword );
                    SubmitForm(selenium);
                    selenium.WaitForPageToLoad("30000");
                });
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Instantiates a new Home Page object. Pass in the Selenium object created in the test SetUp(). 
 /// When the object in instantiated it will navigate to the root
 /// </summary>
 /// Selenium Object created in the tests
 public Home(ISelenium selenium)
 {
     this._selenium = selenium;
     if (!selenium.GetTitle().Contains("home"))
     {
         selenium.Open("/");
     }
     selenium.WindowMaximize();
 }
Exemplo n.º 11
0
 public void TheMercuryTour_03_RemoteControlTest()
 {
     selenium.Open("http://newtours.demoaut.com/");
     Assert.AreEqual("Welcome: Mercury Tours", selenium.GetTitle());
     selenium.Type("name=userName", "invalidUN");
     selenium.Type("name=password", "invalidPW");
     selenium.Click("name=login");
     selenium.WaitForPageToLoad("30000");
 }
Exemplo n.º 12
0
 public void TheTest01Test(string login)
 {
     selenium.Open("/KARA_WEB/deconnexion.do");
     selenium.Type("idUtilisateur", "0088195");
     selenium.Type("motDePasse", "2697");
     selenium.Click("B1");
     selenium.WaitForPageToLoad("30000");
     selenium.Click("bt_3_0");
     selenium.WaitForPageToLoad("30000");
     selenium.Select("codeGestion", "label=Migration Forfaits Bloqués vers Abo - Ajout");
     selenium.Type("numAppelAjt", "0640684010");
     selenium.Type("numICCIDAjt", "89331072970067505032");
     selenium.Click("B2");
     selenium.WaitForPageToLoad("30000");
     selenium.Click("//img[@onclick='valider()']");
     selenium.WaitForPageToLoad("30000");
     selenium.Type("numTitAjt", "100001");
     selenium.Type("numCtrAjt", "000001");
     selenium.Type("numPtFactAjt", "03");
     selenium.Click("B2");
     selenium.WaitForPageToLoad("30000");
     selenium.Select("choixUtilisateur", "label=Utilisateur = pt facturation");
     selenium.WaitForPageToLoad("30000");
     selenium.Click("B2");
     selenium.WaitForPageToLoad("30000");
     selenium.Select("choixOffre", "label=Nouvelle offre");
     selenium.WaitForPageToLoad("30000");
     selenium.Select("choixCible", "label=Gamme SFR Evolution Pro");
     selenium.Click("B2");
     selenium.WaitForPageToLoad("30000");
     selenium.Select("champ_1", "label=SFR Evolution Pro 3H");
     selenium.WaitForPageToLoad("30000");
     selenium.Click("btnsuiv");
     selenium.WaitForPageToLoad("30000");
     Assert.AreEqual("V&S KARA - Les Offres", selenium.GetTitle());
     selenium.Click("btnsuiv");
     selenium.WaitForPageToLoad("30000");
     selenium.Click("btnsuiv");
     selenium.WaitForPageToLoad("30000");
     selenium.Select("champ_1", "label=Liste Rouge");
     selenium.Select("champ_12", "label=Controle Parental Inactif");
     selenium.Click("btnsuiv");
     selenium.WaitForPageToLoad("30000");
     selenium.Type("champ_2", "");
     selenium.Click("B2");
     selenium.Type("champ_2", "8");
 }
Exemplo n.º 13
0
        public void TestMethod1()
        {
            selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.com/");
            selenium.Start();

            selenium.Open("/");
            selenium.Type("q", "selenium rc");
            selenium.Click("btnG");
            selenium.WaitForPageToLoad("30000");
            Assert.AreEqual("selenium rc - Google Search", selenium.GetTitle());

            try
            {
                selenium.Stop();
            }
            catch (Exception)
            {
                // Ignore errors if unable to close the browser
            }
        }
        public void ShouldCommunicateWithSilverNibbleApplication()
        {
            Assert.AreEqual("SilverNibbles", selenium.GetTitle());
            // verifies default properties in the silverlight object
            Assert.AreEqual(640, silvernium.ActualWidth());
            Assert.AreEqual(460, silvernium.ActualHeight());

            // verifies user defined properties and methods
            // content.SilverNibbles.StartingSpeed;,  returns 5
            Assert.AreEqual("5", silvernium.GetPropertyValue("StartingSpeed"));
            // content.SilverNibbles.NewGame('1');,  returns null
            Assert.AreEqual("null", silvernium.Call("NewGame", "1"));


            // testing set and get for a user defined property
            Assert.AreEqual("5", silvernium.GetPropertyValue("StartingSpeed"));
            // setting the property
            silvernium.SetPropertyValue("StartingSpeed", "8");
            // getting it again
            Assert.AreEqual("8", silvernium.GetPropertyValue("StartingSpeed"));
        }
        private void setupBrowser()
        {
            // NOTE: These base URLs only work for systems who happen to have the same integration and localhost suffix (For example, localhost/RlePersonnel and integration.redstapler.biz/RlePersonnel).
            // Systems like MITCalendar will not work until we come up with a better solution.

            // NOTE: This should not be hard-coded.
            var baseUrl = "https://integration.redstapler.biz/";

            if( ConfigurationStatics.IsDevelopmentInstallation ) {
                if( ConfigurationStatics.InstallationConfiguration.WebApplications.Any( wa => wa.SupportsSecureConnections ) )
                    baseUrl = "https://localhost/";
                else
                    baseUrl = "http://localhost/";
            }

            selenium = new DefaultSelenium( "localhost" /*location of Selenium server*/, 4444, @"*firefox3 C:\Program Files (x86)\Mozilla Firefox\firefox.exe", baseUrl );
            selenium.Start();

            if( ConfigurationStatics.IsIntermediateInstallation ) {
                executeSeleniumBlock(
                    "Intermediate log on",
                    delegate {
                        // NOTE: We need to go to the specific URL here instead of relying on a redirect, or Selenium will time out or otherwise fail (it sucks at following redirects).
                        selenium.Open( "/" + ConfigurationStatics.InstallationConfiguration.SystemShortName + "/Ewf/IntermediateLogIn.aspx?ReturnUrl=" );
                        // NOTE: Does not work for MIT Calendar, etc.
                        selenium.Type( "ctl00_ctl00_main_contentPlace_ctl12_theTextBox", ConfigurationStatics.SystemGeneralProvider.IntermediateLogInPassword );
                        // NOTE: Move g8Summit to machine configuration file.
                        SubmitForm( selenium );
                        selenium.WaitForPageToLoad( "30000" );
                    } );
            }
            if( UserManagementStatics.UserManagementEnabled && FormsAuthStatics.FormsAuthEnabled ) {
                executeSeleniumBlock(
                    "Forms log on",
                    delegate {
                        // NOTE: System-name approach suffers from same problem as above.
                        selenium.Open( "/" + ConfigurationStatics.InstallationConfiguration.SystemShortName + "/Ewf/UserManagement/LogIn.aspx?ReturnUrl=" );

                        // NOTE: I don't think we need waits after opens.
                        selenium.WaitForPageToLoad( "30000" );
                        Assert.IsTrue( selenium.GetTitle().EndsWith( "Log In" ) );
                        // NOTE: For RSIS, we need the ability to pass a different email address and a different password for testing.
                        selenium.Type( "ctl00_ctl00_main_contentPlace_emailAddress_theTextBox", ConfigurationStatics.SystemGeneralProvider.FormsLogInEmail );
                        selenium.Type( "ctl00_ctl00_main_contentPlace_password_theTextBox", ConfigurationStatics.SystemGeneralProvider.FormsLogInPassword );
                        SubmitForm( selenium );
                        selenium.WaitForPageToLoad( "30000" );
                    } );
            }
        }