Example #1
0
        public void When_IPressTheLink(string linkName)
        {
            Link link = Browser.Link(Find.ByText(linkName));

            link.WaitUntilExists(2);
            link.Click();
        }
        private void LogIn(IE browser)
        {
            if (browser.Links.Count(link => link.Title == "Log back into your account") > 0)
            {
                // Just been logged out. Need to press the above link
                browser.Link(Find.ByTitle("Log back into your account")).Click();
            }
            else
            {
                browser.Link(Find.ByTitle("Sign in ")).Click();
            }

            if (browser.Links.Count(link => link.Title == "Log back into your account") > 0)
            {
                // Just been logged out. Need to press the above link
                browser.Link(Find.ByTitle("Log back into your account")).Click();
            }

            browser.TextField(Find.ById("frmLogin:strCustomerLogin_userID")).Value = Config.UserId;
            browser.TextField(Find.ById("frmLogin:strCustomerLogin_pwd")).Value    = Config.Password;
            browser.Form(Find.ByName("frmLogin")).Submit();

            LloydsGroupHelpers.FillLloydsGroupMemorableInformation(browser, Config);
            browser.Element(Find.ByName("frmentermemorableinformation1:btnContinue")).Click();
        }
Example #3
0
 public override void Do(IE ie)
 {
     if (ie == null)
     {
         ie = Wxs.Instance.Ie;
     }
     try
     {
         if (lnkAttributeValue.Contains("*"))
         {
             lnkAttributeValue = lnkAttributeValue.Replace("*", String.Empty);
             ie.Link(Find.By(lnkAttributeName,
                             new Regex(lnkAttributeValue))).Click();
         }
         else
         {
             ie.Link(Find.By(lnkAttributeName, lnkAttributeValue)).Click();
         }
         Wxs.Instance.Log.Debug(
             String.Format("Link {0}[{1}] clicked", lnkAttributeName, lnkAttributeValue));
     }
     catch (Exception e)
     {
         Wxs.Instance.Log.Error("Error Clicking Link : " + name, e);
     }
 }
Example #4
0
        public static WatiN.Core.Link GetLink(IE ie, HControl control)
        {
            switch (control.Attribute.ToLower())
            {
            case AttributeType.Id:
            {
                Link link = ie.Link(Find.ById(control.Value));
                if (link.Exists)
                {
                    return(link);
                }
                return(null);
            }

            case AttributeType.Name:
            {
                Link link = ie.Link(Find.ByName(control.Value));
                if (link.Exists)
                {
                    return(link);
                }
                return(null);
            }

            case AttributeType.Class:
            {
                Link link = ie.Link(Find.ByClass(control.Value));
                if (link.Exists)
                {
                    return(link);
                }
                return(null);
            }

            case AttributeType.Text:
            {
                Link link = ie.Link(Find.ByText(control.Value));
                if (link.Exists)
                {
                    return(link);
                }
                return(null);
            }

            default:
            {
                Link link = ie.Link(Find.ByText(control.Value));
                if (link.Exists)
                {
                    return(link);
                }
                return(null);
            }
            }
        }
Example #5
0
        public void login()
        {
            browser = new IE();
            browser.ClearCache();
            browser.ClearCookies();
            Utils.GoTo(browser, "http://www.tribalwars.net/sv-se/page/logout");
            Utils.GoTo(browser, "http://www.tribalwars.net");
            //browser.Body.Focus();
            browser.TextField(Find.ById("user")).TypeText(username);
            browser.TextField(Find.ById("password")).TypeText(password);
            System.Console.WriteLine("Clicking login.");
            browser.Link(Find.ByClass("btn-login")).Click();
            System.Console.WriteLine("Waiting");
            Div wContainer = browser.Div(Find.ByClass("worlds-container"));

            wContainer.WaitUntilExists();
            System.Console.WriteLine("Going to world");
            Utils.GoTo(browser, "http://www.tribalwars.net/sv-se/page/play/" + world);
            System.Console.WriteLine("Logged in");
            while (browser.Html == null)
            {
                System.Threading.Thread.Sleep(100);
            }
            Utils.CheckBotProtection(browser.Html);
            isLoggedIn = true;
            // Give browser object to villages.
            foreach (Village village in villages)
            {
                village.SetBrowser(ref browser);
                village.SetWorld(world);
            }
        }
Example #6
0
        public void LocatingThings()
        {
            using (var browser = new IE("http://www.pluralsight.com"))
            {
                //// Get a reference to a HTML input element, type=text, id=Name
                //TextField applicantName = browser.TextField(Find.ById("Name"));

                //// Get a reference to a HTML link element with id=HelpLink
                //Link helpHyperlink = browser.Link(Find.ById("HelpLink"));

                //// Get a reference to a HTML input element, type=submit, id=ApplyNow
                //Button applyButton = browser.Button(Find.ById("ApplyNow"));

                //// Get a reference to a HTML paragraph element, id=Name
                //Para nameParagraph = browser.Para(Find.ById("Name"));



                TextField applicantName = browser.TextField(Find.ById("Name"));

                Link helpHyperlink = browser.Link(Find.ById("HelpLink"));

                Button applyButton = browser.Button(Find.ById("ApplyNow"));

                Para nameParagraph = browser.Para(Find.ById("Name"));
            }
        }
Example #7
0
        private List <string> GetDiscussionUrls(IE ie, string siteUrl)
        {
            List <string> discussions = new List <string>();

            ie.GoTo(siteUrl);
            ie.WaitForComplete();

            bool done = false;

            ie.Link(Find.ById("discussionTab")).Click();
            while (!done)
            {
                ie.WaitForComplete();
                foreach (var div in ie.Divs)
                {
                    if (div.ClassName == "post_content")
                    {
                        discussions.Add(div.Link(Find.First()).Url);
                    }
                }

                var pag  = ie.List(Find.ById("discussion_pagination"));
                var link = pag.Link(Find.ByText("Next"));
                if (link.Exists)
                {
                    link.Click();
                }
                else
                {
                    done = true;
                }
            }

            return(discussions);
        }
Example #8
0
 public void BrowsingByGenreReturnsAlbumList()
 {
     using (var browser = new IE("http://localhost:1200/"))
     {
         browser.Link(Find.ByText("Rock")).Click();
         Assert.IsTrue(browser.List(Find.ById("album-list")).Children().Any());
     }
 }
Example #9
0
        public void Adding_Items_ToCart()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Pop")).Click();

                browser.Link(Find.ByText("Frank")).Click();

                browser.Link(Find.ByText("Add to cart")).Click();

                Assert.IsTrue(browser.ContainsText("8.99"));
            }
        }
 protected void Logout()
 {
     using (TestLog.BeginSection("Lgout from sharpcms adminpage"))
     {
         Ie.Link(Find.ByText("Log out")).Click();
         Assert.IsTrue(Ie.ContainsText("Login"), "Expected to find \"Login \" on the page.");
     }
 }
Example #11
0
 public void TestFollowLink()
 {
     _ie.GoTo(_webServer.BaseUrl + "Home/Index");
     Assert.That(_ie.Url.EndsWith("Home/Index"), "Should open with index");
     _ie.Link(Find.ById("link_to_about")).Click();
     Assert.That(_ie.Url.EndsWith("Home/About"), "Expected change in url");
     Assert.That(_ie.ContainsText("About Page"), "Site should contain 'About page'");
 }
Example #12
0
        public void Home_ClickOnRockContainsRockAlbumText_True()
        {
            using (var browser = new IE("http://localhost:1100/"))
            {
                browser.BringToFront();

                browser.Link(Find.ByText("Rockssss")).Click();
                Assert.IsTrue(browser.ContainsText("Rock Albums"));
            }
        }
Example #13
0
        public void RemoveItemsFromCart()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Pop")).Click();

                browser.Link(Find.ByText("Frank")).Click();

                browser.Link(Find.ByText("Add to cart")).Click();

                browser.Link(Find.BySelector("a.RemoveLink")).Click();

                Assert.IsTrue(browser.ContainsText("0"));
            }
        }
Example #14
0
        public void Check_That_When_Logged_In_As_Admin_Then_Add_Product_Works()
        {
            var result = false;
            using (IE netWindow = new IE("http://localhost:49573/default.aspx"))
            {
                LoginAsAdmin(netWindow);

                netWindow.Link(Find.ById("ctl00_ucHeader_lnkAdminPage")).Click();
                #region hidden new way
                netWindow.Link(Find.ById(new Regex("AdminPage$")));
                #endregion
                
                netWindow.WaitForComplete();

                netWindow.Button(Find.ById("ctl00_ucHeader_lnkProductAdmin")).Click();
                netWindow.WaitForComplete();

                netWindow.Button(Find.ById("ctl00_ContentPlaceHolder1_RadDock1_C_btnAddProduct")).Click();
                netWindow.WaitForComplete();

                netWindow.TextField(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_txtProductName")).TypeText(String.Format("Paul Test Product {0}", DateTime.Now.Ticks.ToString()));
                netWindow.SelectList(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ddlProductManufacturer")).SelectByValue("3");
                netWindow.SelectList(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ddlCategoryList")).SelectByValue("2");
                netWindow.WaitForComplete(100);
                netWindow.SelectList(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ddlSubCategoryList")).SelectByValue("2");
                netWindow.WaitForComplete();
                netWindow.Link(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_btnAddCombo")).Click();
                netWindow.WaitForComplete();
                netWindow.TextField(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_txtProductPrice")).TypeText("19.99");
                netWindow.TextField(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_txtProductModel")).TypeText("Paul Test Model 1");
                netWindow.Link(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_btnSave")).Click();

                netWindow.WaitForComplete();

                Span resultMessage = netWindow.Span(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ucMessage_lblMessage"));
                if (resultMessage.Text == "New Product created successfuly")
                {
                    result = true;
                }
            }
            Assert.IsTrue(result);
        }
Example #15
0
        public static void GoToEmployerHomePage(this IE browser)
        {
            var employerHomeUrl = new ReadOnlyApplicationUrl(true, "~/employers");

            browser.GoTo(employerHomeUrl.AbsolutePath);
            if (browser.Links.Exists("overridelink"))
            {
                browser.Link("overridelink").Click();
            }
            browser.WaitForComplete();
        }
Example #16
0
        public void UploadImage(IE ie, string filePath)
        {
            ie.Link(Find.ById("uploadImage")).Click();

            var fu = ie.FileUpload(Find.ByClass("ImageUpload"));

            fu.Set(filePath);

            ie.Button(Find.ById("ctl00_cphAdmin_btnUploadImage")).Click();
            ie.WaitForComplete();
        }
Example #17
0
        public void UploadVideo(IE ie, string filePath)
        {
            ie.Link(Find.ById("uploadVideo")).Click();

            var fu = ie.FileUpload(Find.ById("ctl00_cphAdmin_txtUploadVideo"));

            fu.Set(filePath);

            ie.Button(Find.ById("ctl00_cphAdmin_btnUploadVideo")).Click();
            ie.WaitForComplete();
        }
        public void submit_timesheet_with_one_entry()
        {
            _browser.Navigate("/");
            _ie.TextField(Find.ById("txtUserName")).TypeText(USER_NAME);
            _ie.TextField(Find.ById("txtPassword")).TypeText(PASSWORD);
            _ie.Button(Find.ById("lBtnLogin")).Click();

            _ie.SelectList(Find.ById("WeekEnding1")).SelectByValue(CURRENT_WEEK_END);
            _ie.SelectList(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_ddlDate")).SelectByValue(CURRENT_WEEK_END);
            _ie.SelectList(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_ddlEarnCode")).Select("Non billable- Regular Projects");
            _ie.TextField(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_txtHours")).TypeText("8");

            _ie.SelectList(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_udfControl_udf1_ddlValue")).SelectByValue("1");
            _ie.SelectList(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_udfControl_udf2_ddlValue")).SelectByValue("CON000000003932");
            _ie.SelectList(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_udfControl_udf3_ddlValue")).SelectByValue("ADMIN");
            _ie.SelectList(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_udfControl_udf4_ddlValue")).SelectByValue("0000516167");

            _ie.Link(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_lbtnSaveDetail")).Click();
            _ie.Link(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_SubmitButton")).Click();
            _ie.Link(Find.ById("lBtnSubmit")).Click();
        }
Example #19
0
        public Browser Authorize(string login, string password)
        {
            Browser browser = new IE("https://www.codeplex.com/site/login");

            browser.GoTo("https://www.codeplex.com/site/login");
            browser.Link("CodePlexLogin").Click();
            browser.TextField("UserName").TypeText(login);
            browser.TextField("Password").TypeText(password);
            browser.Button("loginButton").Click();

            return(browser);
        }
Example #20
0
 public void TestGoogle()
 {
     using (var browser = new IE())
     {
         browser.Setup();
         browser.GoTo("http://www.google.com.au/");
         browser.TextField(Find.ByName("q")).TypeText("Hello WatiN");
         browser.Button(Find.ByName("btnG")).Click();
         var link = browser.Link(Find.ByUrl("http://watin.org"));
         Assert.AreEqual(link.Text, "WatiN");
     }
 }
Example #21
0
        public void Should_be_able_to_edit_conference()
        {
            using (var ie = new IE("http://localhost:8084"))
            {
                var conferencesLink = ie.Link(Find.ByText("Conferences"));
                conferencesLink.Click();

                var editCodeMashLink = ie.Link(Find.ByText("Edit"));
                editCodeMashLink.Click();

                var nameBox = ie.TextField(Find.ByName("Name"));
                nameBox.TypeText("CodeMashFoo");

                var submitBtn = ie.Button(Find.ByValue("Save"));
                submitBtn.Click();

                ie.Url.ShouldEqual("http://localhost:8084/Conference");

                ie.ContainsText("CodeMashFoo").ShouldBeTrue();
            }
        }
Example #22
0
 private void CheckConversationMode(string radioButtonName)
 {
     GoTo(page);
     IE.RadioButton("ConversationStates1_" + radioButtonName).Checked = true;
     IE.Link("ConversationStates1_btnStart").Click();
     AssertText("MockEntity In Conversation: 0");
     IE.Button("ConversationStates1_btnUpdate").Click();
     AssertText("MockEntity In Conversation: 1");
     IE.Button("ConversationStates1_btnCommit").Click();
     AssertText("Congratulations test passed! ");
     AssertText("MockEntity In Conversation: NULL");
     AssertText("MockEntity in DB: 1");
 }
Example #23
0
 public void CancelTest()
 {
     GoTo(page);
     IE.Link("ConversationStates1_btnStart").Click();
     AssertText("MockEntity In Conversation: 0");
     AssertText("MockEntity in DB: NULL");
     IE.Button("ConversationStates1_btnUpdate").Click();
     AssertText("MockEntity In Conversation: 1");
     AssertText("MockEntity in DB: NULL");
     IE.Button("ConversationStates1_btnCancel").Click();
     AssertText("MockEntity In Conversation: NULL");
     AssertText("MockEntity in DB: NULL");
 }
Example #24
0
        private void EnterProjectBillableHours(string hours, string dayOfTheWeek, string contractLine, string contractNo, string activityId, string projectId, string earningsCode)
        {
            _ie.SelectList(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_ddlDate")).Select(dayOfTheWeek);
            _ie.SelectList(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_ddlEarnCode")).Select(earningsCode);
            _ie.TextField(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_txtHours")).TypeText(hours);

            _ie.SelectList(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_udfControl_udf1_ddlValue")).Select(contractLine);
            _ie.SelectList(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_udfControl_udf2_ddlValue")).Select(contractNo);
            _ie.SelectList(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_udfControl_udf3_ddlValue")).Select(activityId);
            _ie.SelectList(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_udfControl_udf4_ddlValue")).Select(projectId);

            _ie.Link(Find.ById("repHourlyTimeCards_ctl00_uclHourlyTime_lbtnSaveDetail")).Click();
        }
Example #25
0
        public void Login_Successful_Should_Have_LogOut_Link()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Admin")).Click();

                //browser.Element(x => x.)

                browser.TextField(Find.ById("UserName")).TypeText("administrator");

                browser.TextField(Find.ById("Password")).TypeText("password123!");

                browser.Element(Find.BySelector("input.LogOn")).Click();

                Assert.IsTrue(browser.Link(Find.ByText("Log Out")).Exists);

                browser.Link(Find.ByText("Log Out")).Click();
            }
        }
Example #26
0
        public static string FillData(IE ie, HControl control, string data)
        {
            int i = 0;

            while (i < Loop)
            {
                i++;
                try
                {
                    switch (control.Control.ToLower())
                    {
                    case ControlType.AHref:
                        ie.Link(GetControl(ie, control)).Click();
                        break;

                    case ControlType.AHrefNoText:
                        ie.GoTo(control.Value);
                        break;

                    case ControlType.Button:
                        ie.Button(GetControl(ie, control)).Click();
                        break;

                    case ControlType.Div:
                        ie.Div(GetControl(ie, control)).Click();
                        break;

                    case ControlType.TextArea:
                        ie.TextField(GetControl(ie, control)).Value = data;
                        break;

                    case ControlType.TextBox:
                        ie.TextField(GetControl(ie, control)).Value = data;
                        break;
                    }
                    ie.WaitForComplete();

                    return(string.Empty);
                }
                catch (Exception ex)
                {
                    if (i == Loop)
                    {
                        return(ex.Message);
                    }
                    Thread.Sleep(60000);
                }
            }
            return(string.Empty);
        }
Example #27
0
        public void Check_That_When_Logged_In_As_Admin_Then_Admin_Link_Goes_To_Admin_HomePage()
        {
            var url = string.Empty;
            //Act
            using (IE netWindow = new IE("http://localhost:49573/default.aspx"))
            {
                LoginAsAdmin(netWindow);

                netWindow.Link(Find.ById("ctl00_ucHeader_lnkAdminPage")).Click();
                netWindow.WaitForComplete();

                url = netWindow.Url;
            }
            Assert.AreEqual("http://localhost:49573//administration/default.aspx", url);
        }
Example #28
0
        public static void DownLoadFile(IE browser)
        {
            browser.Link(Find.ByText("File Download")).ClickNoWait();

            Thread.Sleep(1000);
            AutomationElementCollection dialogElements = AutomationElement.FromHandle(FindWindow(null, "Internet Explorer")).FindAll(TreeScope.Children, Condition.TrueCondition);

            foreach (AutomationElement element in dialogElements)
            {
                if (element.Current.Name.Equals("Save"))
                {
                    var invokePattern = element.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
                    invokePattern.Invoke();
                }
            }
        }
        public void UnsuccessfulAdministrationLogin()
        {
            bool result;

            using (var browser = new IE("http://localhost:1200/"))
            {
                browser.Link(Find.ByText("Admin")).Click();
                browser.TextField(Find.ById("UserName")).TypeText("admin");
                browser.TextField(Find.ById("Password")).TypeText("admin");

                browser.Element(Find.ByValue("Log On")).Click();

                result = browser.ContainsText("Login was unsuccessful.");
            }

            Assert.That(result, "Browser Url is incorrect");
        }
Example #30
0
        public void Login_WithoutUsernameAndPassword_Should_Have_ErrorMessage()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Admin")).Click();

                browser.Element(Find.BySelector("input.LogOn")).Click();

                Assert.IsTrue(browser.ContainsText("The User name field is required"));

                Assert.IsTrue(browser.ContainsText("The Password field is required."));
            }
        }