public void Launch_UsingNewInstanceOfABrowserWindow_CanUsePartialWindowTitle() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test 1 2 3</title> </head> <body> <button id=""buttonId"" >Button</button> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); //Act HtmlButton button = browserWindow.Find <HtmlButton>(By.Id("buttonId")); //Assert Assert.AreEqual(button.InnerText, "Button"); Trace.WriteLine(browserWindow.Uri.ToString()); browserWindow.Close(); } }
public void HtmlComboBox_Items_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <select id=""selectId""> <option>Cricket</option> <option>Football</option> <option>Tennis</option> </select> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); //Act HtmlComboBox comboBox = browserWindow.Find <HtmlComboBox>(By.Id("selectId")); //Assert Assert.AreEqual("Football", comboBox.Items[1]); Assert.IsTrue(comboBox.Items.Contains("Cricket")); browserWindow.Close(); } }
public void SelectItem_ByIndexOnHtmlComboBox_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <select id=""selectId""> <option>Cricket</option> <option>Football</option> <option>Tennis</option> </select> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); //Act HtmlComboBox comboBox = browserWindow.Find <HtmlComboBox>(By.Id("selectId")); comboBox.SelectIndex(1); //Assert Assert.AreEqual("Football", comboBox.SelectedItem); browserWindow.Close(); } }
public void LabelFor_OnHtmlLabel_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <form> <label for=""male"">Male</label> <input type=""radio"" name=""sex"" id=""male"" value=""male""><br> <label for=""female"">Female</label> <input type=""radio"" name=""sex"" id=""female"" value=""female""><br> <label id=""other"" for=""other"">Other</label> <input type=""radio"" name=""sex"" id=""other"" value=""other""><br> <input type=""submit"" value=""Submit""> </form> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); HtmlLabel label = browserWindow.Find <HtmlLabel>(By.Id("other")); //Assert Assert.AreEqual("other", label.LabelFor); browserWindow.Close(); } }
public void HtmlFileInput_SetFile_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <input name=""inputName"" type=""file"" id=""inputId"" /> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); HtmlFileInput fileInput = browserWindow.Find <HtmlFileInput>(By.Id("inputId")); string tempInputFilePath = Path.GetTempFileName(); //Act fileInput.FileName = tempInputFilePath; browserWindow.Close(); File.Delete(tempInputFilePath); } }
public void SetText_OnHtmlEdit_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <div id=""div1""> <input type=""text""/> </div> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); HtmlDiv div = browserWindow.Find <HtmlDiv>(By.Id("div1")); HtmlEdit inputTextBox = div.Find <HtmlEdit>(); //Act inputTextBox.Text = "text"; //Assert Assert.AreEqual("text", inputTextBox.Text); browserWindow.Close(); } }
public void Click_OnHtmlInputButtonWithEqualsSignInSearchPropertyValue_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <input type=""submit"" value=""="" onclick=""alert('onclick');""/> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); HtmlInputButton button = browserWindow.Find <HtmlInputButton>(By.ValueAttribute("=")); //Act button.Click(); browserWindow.PerformDialogAction(BrowserDialogAction.Ok); browserWindow.Close(); } }
public void Get_UsingMultipleValuesOfClassAttributeWithContainsOperatorOfHtmlSpan_ReturnsTheSpecificElementWithAllSpecifiedClassValues() { // Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <span name=""span1"" class=""class1"" /> <span name=""span2"" class=""class1 class4"" /> <span name=""span3"" class=""class1 class2 class3"" /> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); HtmlSpan span3 = browserWindow.Find <HtmlSpan>(By .ClassContains("class1") .AndClassContains("class2")); // Act and Assert Assert.AreEqual("span3", span3.SourceControl.Name); browserWindow.Close(); } }
public void GetSelectedValue_OfRadioButton_Succeeds() { // Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <input type=""radio"" name=""radio:tab1:gender.type.male"" value=""male"" checked=checked>Male</input><br/> <input type=""radio"" name=""radio:tab1:gender.type.female"" value=""female"">Female</input><br/> <input type=""radio"" name=""radio:tab1:gender.type.other"" value=""other"">Other</input><br/> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); // Act HtmlRadioButton genderTypeMale = browserWindow.Find <HtmlRadioButton>(By.Name("radio:tab1:gender.type.male")); // Assert Assert.IsTrue(genderTypeMale.Selected); Assert.AreEqual("male", genderTypeMale.ValueAttribute); browserWindow.Close(); } }
public void GetHtmlDiv_ByClass_Succeeds() { // Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <div class=""button""><a href=""/main"">main text</a></div> <div class=""button""><a href=""/about"">about text</a></div> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); // Act HtmlDiv div = browserWindow.Find <HtmlDiv>(By.Class("button")); HtmlHyperlink about = browserWindow.Find <HtmlHyperlink>(By.SearchProperties("InnerText=about text;href~about")); HtmlDiv div2 = about.Parent as HtmlDiv; // Assert Assert.IsTrue(div.Exists); Assert.AreEqual("main text", div.SourceControl.InnerText); Assert.IsTrue(about.Exists); Assert.IsTrue(div2.Exists); Assert.AreEqual("about text", div2.SourceControl.InnerText); browserWindow.Close(); } }
public void GetHtmlRow_ById_Succeeds() { // Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <table class=""cart"" cellspacing=""0""> <tbody> <tr id=""555002_gp2""> <td> banana </td> </tr> </tbody> </table> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); // Act HtmlRow row = browserWindow.Find <HtmlRow>(By.Id("555002_gp2")); // Assert Assert.IsTrue(row.Exists); browserWindow.Close(); } }
public void Launch_TempHtmlFileWithInputWithMaxLength_CanSetTextWhichExceedsMaxLength() { // Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <input id=""input"" type=""text"" maxlength=10 /> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); HtmlEdit input = browserWindow.Find <HtmlEdit>(By.Id("input")); // Act string inputText = "12345678901"; string outputText = "1234567890"; Keyboard.SendKeys(input.SourceControl, inputText); // Assert Assert.AreEqual(input.Text, outputText); browserWindow.Close(); } }
public void Launch_TempHtmlFile_CanFindHyperlinkByHref() { // Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <div class=""login"" style=""border: none;""> <div class=""member_box""> <span>APPLY FOR MEMBERSHIP</span> <a href=""/registration""> </a> </div> </body> </html>")) { // Act var browserWindow = BrowserWindow.Launch(webPage.FilePath); // Assert HtmlHyperlink SignUpHyperLink = browserWindow.Find <HtmlHyperlink>(By.SearchProperties("href~registration")); Assert.IsTrue(SignUpHyperLink.Exists, "SignUp not found"); browserWindow.Close(); } }
public void SetText_UsingScreenObjects_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <div id=""div1"" > <div id=""div2"" > <input type=""text"" id=""edit""/> </div> </div> </body> </html>")) { var page = Page.Launch <HtmlTestPage>(webPage.FilePath); //Act page.Div1.Div2.Edit.Text = "test"; //Assert Assert.IsTrue(page.Div1.Div2.Edit.Exists); } }
public void HtmlCheckBox_DisabledByStyle_ControlExistsAndCanGetCheckedState() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <input type=""checkbox"" id=""checkBoxId"" disabled=""disabled"" name=""checkBoxName"" checked=""checked"" /> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); //Act HtmlCheckBox checkBox = browserWindow.Find <HtmlCheckBox>(By.Id("checkBoxId")); //Assert Assert.IsTrue(checkBox.Exists); Assert.IsTrue(checkBox.Checked); browserWindow.Close(); } }
public void SetText_OnHtmlPassword_Succeeds() { // Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <div class=""row textbox"" id=""idDiv_PWD_PasswordTb""> <div style=""width: 100%; position: relative;""> <input name=""passwd"" id=""i0118"" aria-labelledby=""idDiv_PWD_PasswordExample"" type=""password"" autocomplete=""off""> <div class=""phholder"" style=""left: 0px; top: 0px; width: 100%; position: absolute; z-index: 5;""> <div class=""placeholder"" id=""idDiv_PWD_PasswordExample"" aria-hidden=""true"" style=""cursor: text;"">Password</div> </div> </div> </div> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); HtmlPassword txtPwd = browserWindow.Find <HtmlPassword>(By.Id("i0118")); // Act txtPwd.Text = "hello"; // TODO: Assert browserWindow.Close(); } }
public void SelectItem_UsingHtmlComboBoxThatAlertsOnChange_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <select id=""selectId"" onchange=""alert('onchange');""> <option>Apple</option> <option>Banana</option> <option>Carrot</option> </select> </body> </html>")) { var window = BrowserWindow.Launch(webPage.FilePath); HtmlComboBox comboBox = window.Find <HtmlComboBox>(By.Id("selectId")); comboBox.SetFocus(); //Act // select item "Banana" Keyboard.SendKeys(comboBox.SourceControl, "{DOWN}"); window.PerformDialogAction(BrowserDialogAction.Ok); window.Close(); } }
public void Click_OnHtmlHyperlink_InTableWithEmptyCell_Succeeds() { // Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <table id=""tableId""> <tr id=""row""> <td></td> <td><a href=""#"">Details</a></td> </tr> </table> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); var table = browserWindow.Find <HtmlTable>(By.Id("tableId")); HtmlCell cell = table.GetCell(0, 1); HtmlHyperlink hyperlink = cell.Find <HtmlHyperlink>(); // Act hyperlink.Click(); // TODO: Assert browserWindow.Close(); } }
public void SelectedItems_OnHtmlList_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <select id=""selectId"" multiple=""multiple""> <option value=""1"">1</option> <option value=""2"">2</option> <option value=""3"">3</option> </select> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); HtmlList list = browserWindow.Find <HtmlList>(By.Id("selectId")); string[] itemsToSelect = { "1", "2" }; //Act list.SelectedItems = itemsToSelect; //Assert CollectionAssert.AreEqual(itemsToSelect, list.SelectedItems); browserWindow.Close(); } }
public void InnerText_OnHtmlComboBoxWithDisabledItems_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <select id=""selectId""> <option value=""1"">1</option> <option value=""2"" disabled=""disabled"">2</option> <option value=""3"" disabled=""disabled"">3</option> </select> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); HtmlComboBox comboBox = browserWindow.Find <HtmlComboBox>(By.Id("selectId")); //Assert Assert.AreEqual(3, comboBox.ItemCount); CollectionAssert.AreEqual(new[] { "1", "2", "3" }, comboBox.Items); Assert.AreEqual("1 2 3", comboBox.InnerText.Trim()); browserWindow.Close(); } }
[Ignore] // this test currently fails public void HtmlButton_HiddenByStyle_ControlExistsAndCanAssertOnStyle() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <button id=""buttonId"" style=""display: none;"" >Hidden</button> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); //Act HtmlButton button = browserWindow.Find <HtmlButton>(By.Id("buttonId")); //Assert Assert.IsTrue(button.Exists); Assert.IsTrue(button.SourceControl.ControlDefinition.Contains("style=\"display: none;\"")); browserWindow.Close(); } }
public void ClickAllControlsOnPage_UsingReflection_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <a href=""#"">test</a> <button>test</button> <input type=""text"" value=""test""/> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); ControlBase a = browserWindow.Find <HtmlHyperlink>(By.SearchProperties("InnerText=test")); a.Click(); List <Type> list = new List <Type>(); list.Add(typeof(HtmlHyperlink)); list.Add(typeof(HtmlButton)); list.Add(typeof(HtmlEdit)); MethodInfo getMethodInfo = typeof(UITestControlExtensions).GetMethod("Find", BindingFlags.Public | BindingFlags.Static); foreach (Type t in list) { MethodInfo test = getMethodInfo.MakeGenericMethod(t); ControlBase control; if ((t == typeof(HtmlEdit)) || (t == typeof(HtmlTextArea))) { control = (ControlBase)test.Invoke(null, new object[] { browserWindow, By.ValueAttribute("test") }); } else { //window.Find<t>("InnerText=test"); control = (ControlBase)test.Invoke(null, new object[] { browserWindow, By.SearchProperties("InnerText=test") }); } //Act control.Click(); if (control is HtmlEdit) { (control as HtmlEdit).Text = "text"; } else if (control is HtmlTextArea) { (control as HtmlTextArea).Text = "text"; } } browserWindow.Close(); } }
public void LowerLeft() { using (var homePage = new TempWebPage(Home)) { // Arrange var mainPage = Page.Launch <MainPage>(homePage.FilePath); // Assert Assert.IsTrue(mainPage.LowerLeft.RadioButtonExists); } }
public void UpperRight() { using (var homePage = new TempWebPage(Home)) { // Arrange var mainPage = Page.Launch <MainPage>(homePage.FilePath); // Assert Assert.IsTrue(mainPage.UpperRight.CheckBoxExists); } }
public void RebasedUpperLeft() { using (var homePage = new TempWebPage(Home)) { // Arrange var mainPage = Page.Launch <MainPage>(homePage.FilePath); // Assert Assert.IsTrue(mainPage.RebasedUpperLeft.Self.Exists); Assert.IsTrue(mainPage.RebasedUpperLeft.CheckBoxExists); } }
public void RebasedLowerRight() { using (var homePage = new TempWebPage(Home)) { // Arrange var mainPage = Page.Launch <MainPage>(homePage.FilePath); // Assert Assert.IsTrue(mainPage.RebasedLowerRight.Self.Exists); Assert.IsTrue(mainPage.RebasedLowerRight.RadioButtonExists); } }
public void HtmlTable_GetCellValueUsingTableWithTHInTBODY_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <table id=""tableId"" border=""1""> <tbody> <tr> <th>Lun</th> <th>Used Space</th> <th>Free Space</th> <th>Usage %</th> <th> </th> </tr> <tr> <td>LUN_04</td> <td>26534605227</td> <td>15405750418</td> <td> <dl> <dd> <dl> <dd> <span>64.27%</span> </dd> </dl> </dd> </dl> </td> <td></td> </tr> </tbody> </table> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); var table = browserWindow.Find <HtmlTable>(By.Id("tableId")); //Act table.FindRowAndClick("LUN_04", 0, HtmlTableSearchOptions.NormalTight); //Assert Assert.AreEqual("LUN_04", table.GetCellValue(1, 0).Trim()); browserWindow.Close(); } }
public void NavigateToNonModalDialog() { using (var aboutPage = new TempWebPage(About)) using (var homePage = new TempWebPage(string.Format(Home, Path.GetFileName(aboutPage.FilePath)))) { // Arrange var mainPage = Page.Launch <MainPage>(homePage.FilePath); // Act var dialogScreen = mainPage.MiddlePageObject.NavigateToAboutPage(); // Assert Assert.IsTrue(dialogScreen.FrameworkMessageExists); } }
public void StepThroughWizard() { using (var finishedWebPage = new TempWebPage(Finished)) using (var addressWebPage = new TempWebPage(string.Format(Address, Path.GetFileName(finishedWebPage.FilePath)))) using (var nameWebPage = new TempWebPage(string.Format(Name, Path.GetFileName(addressWebPage.FilePath)))) { // Arrange var namePage = Page.Launch <NamePage>(nameWebPage.FilePath); var workflow = new WizardWorkflow(namePage); // Act FinishedPage finishedPage = workflow.StepThrough(); // Assert Assert.IsTrue(finishedPage.CongratulationsExists); } }
public void Launch_PageObjects_CanFindUnorderedListsByTagAndClassName() { // Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <div id=""feed_tabs"" class=""ui-tabs""> <ul class=""dataFeedTab ui-tabs-nav""> <li data-bind-iterate=""."" class=""ui-tabs-selected ui-state-active""> <a href=""#ui-tabs-1"" data-bind=""createTabLink"" data-bind-type=""function"" class=""JQtab"">Attack Correlation Details</a> </li> <li data-bind-iterate="""" iterate-limit="""" class=""""> <a href=""#ui-tabs-2"" data-bind=""createTabLink"" data-bind-type=""function"" class=""JQtab"">Common Details</a> </li> <li data-bind-iterate="""" iterate-limit="" class=""> <a href=""#ui-tabs-3"" data-bind=""createTabLink"" data-bind-type=""function"" class=""JQtab"">Exposure Details</a> </li> <li data-bind-iterate="""" iterate-limit="""" class=""""><a href=""#ui-tabs-4"" data-bind=""createTabLink"" data-bind-type=""function"" class=""JQtab"">IP Reputation Feed</a> </li> </ul> </div> </body> </html>")) { // Act var page = Page.Launch <HtmlTestPageFeeds>(webPage.FilePath); var cus = new CUITControls.HtmlCustom(page.DivFeedTabs.SourceControl); cus.SearchProperties.Add(CUITControls.HtmlControl.PropertyNames.TagName, "ul", PropertyExpressionOperator.EqualTo); cus.SearchProperties.Add(CUITControls.HtmlControl.PropertyNames.Class, "dataFeedTab ui-tabs-nav", PropertyExpressionOperator.EqualTo); Assert.IsTrue(cus.Exists); Assert.IsTrue(page.CustomDataFeedTabsNav.Exists); // Assert Assert.IsTrue(page.CustomDataFeedTabsNav.Exists); Assert.IsTrue(page.CustomDataFeedTabsNav1.Exists); Assert.IsTrue(page.CustomDataFeedTabsNav2.Exists); } }