private static void TranslateHtmlInputSubmit(HtmlInputSubmit obj) { if (obj != null) { obj.Value = TagReplace(obj.Value); } }
public EditNameForm(Manager manager) { this.manager = manager; this.NewNameLabel = manager.ActiveBrowser.Find.ByContent <HtmlControl>("l:New Name"); this.NewNameField = manager.ActiveBrowser.Find.ById <HtmlInputText>("userNewName"); this.ChangeName = manager.ActiveBrowser.Find.ByAttributes <HtmlInputSubmit>("value=Change Name"); this.Cancel = manager.ActiveBrowser.Find.ByAttributes <HtmlInputSubmit>("value=Cancel"); }
/// <summary> /// Press subscribe button not styled page /// </summary> public void ClickSubscribeButtonNotStyledPage() { HtmlInputSubmit subscribeButton = EM.EmailCampaigns.SubscribeFormFrontend.SubscribeInputButton .AssertIsPresent("Subscribe button"); subscribeButton.MouseClick(); ActiveBrowser.WaitUntilReady(); ActiveBrowser.WaitForAsyncJQueryRequests(); }
/// <summary> /// Press unsubscribe button not styled /// </summary> public void ClickUnsubscribeButtonNotStyled() { HtmlInputSubmit unsubscribeButton = EM.EmailCampaigns.UnsubscribeFrontend.UnsubscribeButtonHybridPage .AssertIsPresent("Unsubscribe button"); unsubscribeButton.MouseClick(); ActiveBrowser.WaitUntilReady(); ActiveBrowser.WaitForAsyncJQueryRequests(); }
public EditPasswordForm(Manager manager) { this.manager = manager; this.NewPasswordLabel = manager.ActiveBrowser.Find.ByContent("l:New Password"); this.CurrentPasswordField = manager.ActiveBrowser.Find.ById <HtmlInputPassword>("userCurrentPassword"); this.NewPasswordField = manager.ActiveBrowser.Find.ById <HtmlInputPassword>("password"); this.ConfirmPasswordField = manager.ActiveBrowser.Find.ById <HtmlInputPassword>("userConfirmNewPassword"); this.ChangePassword = manager.ActiveBrowser.Find.ByAttributes <HtmlInputSubmit>("value=Change Password"); this.Cancel = manager.ActiveBrowser.Find.ByAttributes <HtmlInputSubmit>("value=Cancel"); }
public void AssertRequiredFieldValidation() { manager.ActiveBrowser.NavigateTo("http://automatetheplanet.com/healthy-diet-menu-generator/"); HtmlInputSubmit generateButton = manager.ActiveBrowser.Find.ByName <HtmlInputSubmit>("_ninja_forms_field_28"); generateButton.Click(); var requiredField = manager.ActiveBrowser.Find.ByXPath <HtmlContainerControl>("//*[@id='ninja_forms_field_18_error']/p"); requiredField.AssertContent().InnerText(ArtOfTest.Common.StringCompareType.Exact, "This is a required field"); }
public void TelerikTestStudioFrameworkBasicActions() { manager.ActiveBrowser.NavigateTo("http://automatetheplanet.com/healthy-diet-menu-generator/"); HtmlInputSubmit generateButton = manager.ActiveBrowser.Find.ByName <HtmlInputSubmit>("_ninja_forms_field_28"); HtmlInputCheckBox additionalSugarCheckbox = manager.ActiveBrowser.Find.ById <HtmlInputCheckBox>("ninja_forms_field_18"); HtmlInputText firstNameTextInput = manager.ActiveBrowser.Find.ByXPath <HtmlInputText>("//*[@id='ninja_forms_field_23']"); HtmlSelect burgersSelect = manager.ActiveBrowser.Find.ByName <HtmlSelect>("ninja_forms_field_21"); HtmlInputRadioButton coffeeRadioButton = manager.ActiveBrowser.Find.ByExpression <HtmlInputRadioButton>("value=^1 x Trenta"); coffeeRadioButton.Check(isChecked: true, invokeOnChange: true, invokeOnClickChanged: true); burgersSelect.SelectByText("10 x Double Cheeseburgers"); firstNameTextInput.Text = "Anton"; additionalSugarCheckbox.Check(isChecked: true, invokeOnChange: true, invokeOnClickChanged: true); generateButton.Click(); }
public void SubmitAdTest() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // Find all the required elements on the page HtmlForm form = Find.ById <HtmlForm>("Form2"); IList <HtmlSelect> selectsList = form.Find.AllByTagName <HtmlSelect>("select"); IList <HtmlInputText> textInputsList = form.Find.AllByTagName <HtmlInputText>("input"); HtmlInputPassword passwordField = form.Find.ById <HtmlInputPassword>("txtPassword"); HtmlTextArea description = form.Find.ById <HtmlTextArea>("txtDescription"); HtmlInputSubmit submit = form.Find.ById <HtmlInputSubmit>("submit"); // Enter data into the input fields Actions.ScrollToVisible(submit.BaseElement, ScrollToVisibleType.ElementBottomAtWindowBottom); selectsList[(int)Selects.Year].SelectByText("1956"); selectsList[(int)Selects.Make].SelectByText("Ford"); textInputsList[(int)TextInputFields.Model].Text = "T-Bird"; textInputsList[(int)TextInputFields.Price].Text = "175000"; textInputsList[(int)TextInputFields.Phone].Text = "555-122-5544"; textInputsList[(int)TextInputFields.Email].Text = "*****@*****.**"; selectsList[(int)Selects.AllowEmail].SelectByText("Yes"); description.Text = "Beautifully restored two tone red & white classic T-Bird. Just like factory mint condition. Actual mileage is 175,600."; textInputsList[(int)TextInputFields.FirstName].Text = "Willard"; textInputsList[(int)TextInputFields.LastName].Text = "Laird"; textInputsList[(int)TextInputFields.Company].Text = "Laird Auto Restoration"; textInputsList[(int)TextInputFields.Address].Text = "147 Industrial Dr."; textInputsList[(int)TextInputFields.City].Text = "Sacramento"; selectsList[(int)Selects.State].SelectByText("California"); textInputsList[(int)TextInputFields.Zip].Text = "22746"; textInputsList[(int)TextInputFields.UserName].Text = "wlaird335"; passwordField.Text = "lairdinc"; // Submit the ad submit.Click(); }
public void TestSignin(User admin) { // Precondition // Test Steps LoginPage loginPage = Pages.Application.Get().Login(); UsersPage usersPage = loginPage.SuccessAdminLogin(admin); //UsersPage usersPage = Application.Get().Login().SuccessAdminLogin(admin); // // Check Assert.AreEqual("LV-204 ISTQB", usersPage.GetUsernameText()); // // Return to previous state loginPage = usersPage.GotoLogOut(); // // Check Assert.AreEqual("SoftServe Language School", loginPage.GetLoginDescriptionText()); //-------------------------------------------------------------- //[Test] Manager manager; Settings mySettings = new Settings(); // // Precondition mySettings.Web.DefaultBrowser = BrowserType.Chrome; manager = new Manager(mySettings); manager.Start(); manager.LaunchNewBrowser(); manager.ActiveBrowser.NavigateTo("https://wow.training.local/Index#/Home"); // IList <HtmlControl> description = manager.ActiveBrowser.Find.AllByXPath <HtmlControl>("//div[@class='text-primary']/h2/small"); Console.WriteLine("description = " + description.Count); if ((description.Count == 0) && (manager.ActiveBrowser.BrowserType == BrowserType.Chrome)) { for (int i = 0; i < 5; i++) { manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab); } manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Space); manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab); manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab); manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter); } Thread.Sleep(1000); HtmlButton loginButton = manager.ActiveBrowser.Find.ByAttributes <HtmlButton>("class=btn btn-success"); loginButton.Click(); HtmlInputEmail loginInput = manager.ActiveBrowser.Find.ByAttributes <HtmlInputEmail>("ng-model=email"); loginInput.Text = "*****@*****.**"; Thread.Sleep(1000); HtmlInputPassword passwordInput = manager.ActiveBrowser.Find.ByAttributes <HtmlInputPassword>("ng-model=password"); passwordInput.Text = "q2w3e4r5"; Thread.Sleep(1000); HtmlInputSubmit submitInput = manager.ActiveBrowser.Find.ByName <HtmlInputSubmit>("loginButton"); submitInput.Click(); Thread.Sleep(2000); // Check HtmlSpan userAccount = manager.ActiveBrowser.Find.ByAttributes <HtmlSpan>("ng-bind=userName"); Assert.AreEqual("Mariana Medynska", userAccount.TextContent); //Steps--------------------------------------------------------------------------------------------- HtmlSpan managerButton = manager.ActiveBrowser.Find.ByContent <HtmlSpan>("p:Manager"); managerButton.Click(); //# cursorStyle > span:nth-child(2) // //*[@id="cursorStyle"]/span[1] HtmlSpan groupsButton = manager.ActiveBrowser.Find.ByContent <HtmlSpan>("l:Groups"); managerButton.Click(); // //*[@id="teaching-tools"]/li/ul/li[4]/a/span //#teaching-tools > li > ul > li:nth-child(4) > a > span var myGroupsText = manager.ActiveBrowser.Find.ByXPath("//h2['My Groups']"); Assert.AreEqual("My Groups", myGroupsText.TextContent); // #myJum > div > div.container.ng-scope > div:nth-child(1) > div > h2 // //*[@id="myJum"]/div/div[3]/div[1]/div/h2 // //h2["My Groups"] HtmlButton editPencilButton = manager.ActiveBrowser.Find.ByAttributes <HtmlButton>("//*[@id='myJum']/div/div[3]/div[4]/table/tbody/tr[2]/td[3]/a"); editPencilButton.Click(); //#myJum > div > div.container.ng-scope > div.panel.panel-default > table > tbody > tr:nth-child(2) > td:nth-child(3) > a // //*[@id="myJum"]/div/div[3]/div[4]/table/tbody/tr[2]/td[3]/a //Check if Test_M //var testMGroup = manager.ActiveBrowser.Find.ByAttributes<HtmlDiv>("class=col-md-4 text-left blod-text ng-binding"); //testMGroup.Get //class = col-md-4 text-left blod-text ng-binding //# myJum > div > div.container.ng-scope > div:nth-child(2) > h3.col-md-4.text-left.blod-text.ng-binding // //*[@id="myJum"]/div/div[3]/div[2]/h3[1] HtmlButton selectDropdown = manager.ActiveBrowser.Find.ByAttributes <HtmlButton>("class=dropdown-toggle ng-binding btn btn-default"); selectDropdown.Click(); HtmlControl selectDropDownDialog = manager.ActiveBrowser.Find.ByAttributes <HtmlControl>("class=dropdown-menu dropdown-menu-form"); //selectDropDownDialog. - check names in the lists at least five HtmlAnchor checkAll = manager.ActiveBrowser.Find.ByContent <HtmlAnchor>("p:Check All"); checkAll.Click(); // how to check if names are checked/unchecked HtmlAnchor UnCheckAll = manager.ActiveBrowser.Find.ByAttributes <HtmlAnchor>("class=glyphicon glyphicon-remove"); UnCheckAll.Click(); HtmlInputSearch studentSearchByName = manager.ActiveBrowser.Find.ByAttributes <HtmlInputSearch>("class=form-control ng-pristine ng-valid ng-touched"); HtmlButton submitChangesButton = manager.ActiveBrowser.Find.ByAttributes <HtmlButton>("class=btn btn-default center- block"); manager.Dispose(); Console.WriteLine("done"); }
public void FindingControls() { // Find the first table on the page. HtmlTable outertable = Find.ByTagIndex <HtmlTable>("table", 0); Assert.IsTrue(outertable.Rows.Count == 3); // Find the first table inside the outer table // // Note: HtmlContainerControls have a Find object // associated with them that scopes all the Find.Byxx searches // to elements contained within them only. // So even if you have multiple controls with similar contained // elements, this will help avoid any conflicts. // Also, note how we are referencing the innertable using index 0 // since it is the first table inside our outer table. // HtmlTable innerTable = outertable.Find.ByTagIndex <HtmlTable>("table", 0); // Special Find for tables. HtmlTableCell cell = innerTable.Find.TableCell("TD21"); Assert.IsTrue(cell.TextContent.Equals("TD21")); // Find all HtmlInputImage controls with 'src' containing partial value 'logo' IList <HtmlInputImage> imgCtrls = Find.AllByAttributes <HtmlInputImage>("src=~logo"); // There should only be one HtmlInputText control. All controls // That match the attribute list but fail validation by the HtmlInputText control // will be ignored. Assert.AreEqual(1, imgCtrls.Count); // Find the <div> section containing the Eastern US Division sales report HtmlDiv EasternUSDivision = Find.ByContent <HtmlDiv>("Eastern US Division", FindContentType.TextContent); Assert.IsNotNull(EasternUSDivision); // Traverse the control tree upwards too. You can easily // Find the container control of a certain type from its children. // Find the owner form of the submit button HtmlInputSubmit submitButton = Find.ById <HtmlInputSubmit>("submit"); HtmlForm form = submitButton.Parent <HtmlForm>(); // Get the name of the frame targeted by the form string myFrame = form.Target; Assert.AreEqual("_self", myFrame); // Find the 3rd text input field on the form. Index is 0 based, so we enter 2 to mean the 3rd one. HtmlInputText input = form.Find.ByTagIndex <HtmlInputText>("input", 2); Assert.IsNotNull(input); // Find the table that contains this cell. HtmlTable table = cell.Parent <HtmlTable>(); Assert.IsTrue(table.ID.Equals(innerTable.ID)); // Find the parent table of this inner table. HtmlTable table2 = table.Parent <HtmlTable>(); Assert.IsTrue(table2.ID.Equals(outertable.ID)); // Find the form this table is contained in. HtmlForm form1 = table2.Parent <HtmlForm>(); Assert.IsTrue(form1.ID.Equals("form1")); // Note: if Find.IgnoreFindAllControlMismatch is set to false, the // Find.Allxx<>() method will throw when encounters a control that matches the search // criteria but fails to be the desired HTMLControl. // TIP: The above example is to show the functionality of the Find.Byxx<> function. // It is not recommended to use loose attribute finds like the one above since it will // match many controls on the page that will be ignored. The better the find constraints // are the more performant the search is. // For example, the above Find can be enhanced by doing ("id=~1","type=text") }
public void TestMethod3() { Manager manager; Settings mySettings = new Settings(); // // Precondition //mySettings.Web.DefaultBrowser = BrowserType.FireFox; //mySettings.Web.DefaultBrowser = BrowserType.InternetExplorer; mySettings.Web.DefaultBrowser = BrowserType.Chrome; //mySettings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle; mySettings.UnexpectedDialogAction = UnexpectedDialogAction.HandleAndContinue; manager = new Manager(mySettings); manager.Start(); manager.LaunchNewBrowser(); manager.ActiveBrowser.NavigateTo("https://wow.training.local/Index#/Home"); // IList <HtmlControl> description = manager.ActiveBrowser.Find.AllByXPath <HtmlControl>("//div[@class='text-primary']/h2/small"); Console.WriteLine("description = " + description.Count); if ((description.Count == 0) && (manager.ActiveBrowser.BrowserType == BrowserType.Chrome)) { for (int i = 0; i < 5; i++) { manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab); } manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Space); manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab); manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab); manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter); } Thread.Sleep(1000); // // Manager.Current.DialogMonitor.AddDialog(AlertDialog.CreateAlertDialog(Manager.Current.ActiveBrowser, DialogButton.OK)); Manager.Current.DialogMonitor.Start(); // // Check JS injection Manager.Current.ActiveBrowser.Actions.InvokeScript("alert('Ha-Ha-Ha')"); Thread.Sleep(4000); //string strBool = Actions.InvokeScript("Alert('Ha-Ha-Ha')"); // //Manager.Current.ActiveBrowser.Actions. // //ConfirmDialog confirmDialog = ConfirmDialog.CreateConfirmDialog(Manager.Current.ActiveBrowser,DialogButton.OK); //confirmDialog.HandlerDelegate = new DialogHandlerDelegate(this.ConfirmHandleDialog); //Manager.Current.DialogMonitor.AddDialog(confirmDialog); //Manager.Current.DialogMonitor.Start(); // Click the button //Manager.Current.ActiveBrowser.Action.MouseClickItem(RSSControls.Applications.ApplicationsEditLoginPage.DeleteQuestion); //confirmDialog.WaitUntilHandled(); //Manager.Current.DialogMonitor.RemoveDialog(confirmDialog); //Manager.Current.DialogMonitor.Stop(); // // Test Steps HtmlButton loginButton = manager.ActiveBrowser.Find.ByAttributes <HtmlButton>("class=btn btn-success"); loginButton.Click(); //HtmlInputEmail loginInput = manager.ActiveBrowser.Find.ByAttributes<HtmlInputEmail>("class=form-control ng-pristine ng-valid ng-valid-email ng-touched"); HtmlInputEmail loginInput = manager.ActiveBrowser.Find.ByAttributes <HtmlInputEmail>("ng-model=email"); loginInput.Text = "*****@*****.**"; Thread.Sleep(1000); HtmlInputPassword passwordInput = manager.ActiveBrowser.Find.ByAttributes <HtmlInputPassword>("ng-model=password"); passwordInput.Text = "irawow123"; Thread.Sleep(1000); HtmlInputSubmit submitInput = manager.ActiveBrowser.Find.ByName <HtmlInputSubmit>("loginButton"); submitInput.Click(); Thread.Sleep(2000); // // Check HtmlSpan userAccount = manager.ActiveBrowser.Find.ByAttributes <HtmlSpan>("ng-bind=userName"); //Console.WriteLine("HtmlSpan userAccount done"); Assert.AreEqual("LV-204 ISTQB", userAccount.TextContent); //Console.WriteLine("Assert.AreEqual LV - 204 ISTQB done"); // // Return to previous state manager.ActiveBrowser.Find.ById <HtmlDiv>("dropdownBtn").Click(); //Console.WriteLine("dropdownBtn done"); Thread.Sleep(2000); // logout manager.ActiveBrowser.Find.ByAttributes <HtmlAnchor>("ng-click=logOut()").Click(); //Manager.Current.ActiveBrowser.Actions.InvokeScript("logOut();"); Console.WriteLine("ng-click=logOut() done"); Thread.Sleep(2000); //HtmlControl loginDescription = manager.ActiveBrowser.Find.ByXPath<HtmlControl>("//div[@class='text-primary']/h2/small"); var loginDescription = manager.ActiveBrowser.Find.ByXPath("//div[@class='text-primary']/h2/small"); Console.WriteLine("loginDescription done loginDescription.TextContent = " + loginDescription.TextContent); Assert.AreEqual("SoftServe Language School", loginDescription.TextContent); // manager.Dispose(); Console.WriteLine("done"); }