public void SetText_UsingControlsDefinedInObjectRepositoryHierarchy_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <div id=""div1"" > <div id=""div2"" > <input type=""text"" id=""edit""/> </div> </div> </body> </html>")) { var window = BrowserWindowUnderTest.Launch <HtmlTestPage>(tempFile.FilePath); //Act window.div1.div2.edit.Text = "test"; //Assert Assert.IsTrue(window.div1.div2.edit.Exists); Assert.IsTrue(window.div1.div2.Exists); Assert.IsTrue(window.div1.Exists); window.Close(); } }
public void GetBrowserWindow_WithDynamicWindowTitle_CanInteractWithWindow() { // Arrange string page2GenericWindowTitle = "window title 2"; string page2DynamicGenericWindowTitle = "the window title changed"; string homePageGenericWindowTitle = "Clicking the buttons changes the window title"; DynamicBrowserWindowTitleRepository home = BrowserWindowUnderTest.Launch <DynamicBrowserWindowTitleRepository>(currentDirectory + "/DynamicBrowserWindowTitle.html"); home.btnGoToPage2.Click(); DynamicBrowserWindowTitleRepository page2 = DynamicBrowserWindowUnderTest.GetBrowserWindow <DynamicBrowserWindowTitleRepository>(page2GenericWindowTitle); page2.btnChangeWindowTitle.Click(); // Checkpoint Assert.IsTrue(page2.Title.Contains(page2DynamicGenericWindowTitle), page2.Title); // Act page2 = DynamicBrowserWindowUnderTest.GetBrowserWindow <DynamicBrowserWindowTitleRepository>(page2DynamicGenericWindowTitle); page2.btnGoToHomePage.Click(); page2.SetWindowTitle(homePageGenericWindowTitle); // Assert Assert.IsTrue(page2.Title.Contains(homePageGenericWindowTitle), page2.Title); page2.Close(); }
public void HtmlParagraph_InnertText_Succeeds() { var bWin = BrowserWindowUnderTest.Launch(currentDirectory + "/TestHtmlPage.html"); Assert.IsTrue(bWin.Find <HtmlParagraph>(By.Id("para1")).InnerText.Contains("HtmlParagraph")); bWin.Close(); }
public void Launch_TempHtmlFileWithInputWithMaxLength_CanSetTextWhichExceedsMaxLength() { // Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <input id=""input"" type=""text"" maxlength=10 /> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlEdit input = window.Find <HtmlEdit>(By.Id("input")); // Act string inputText = "12345678901"; string outputText = "1234567890"; Keyboard.SendKeys(input.SourceControl, inputText); // Assert Assert.AreEqual(input.Text, outputText); window.Close(); } }
[Ignore] // this test currently fails public void HtmlButton_HiddenByStyle_ControlExistsAndCanAssertOnStyle() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <button id=""buttonId"" style=""display: none;"" >Hidden</button> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); //Act HtmlButton button = window.Find <HtmlButton>(By.Id("buttonId")); //Assert Assert.IsTrue(button.Exists); Assert.IsTrue(button.SourceControl.ControlDefinition.Contains("style=\"display: none;\"")); window.Close(); } }
public void SelectItem_UsingHtmlComboBoxThatAlertsOnChange_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<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 = BrowserWindowUnderTest.Launch(tempFile.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 HtmlCheckBox_DisabledByStyle_ControlExistsAndCanGetCheckedState() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <input type=""checkbox"" id=""checkBoxId"" disabled=""disabled"" name=""checkBoxName"" checked=""checked"" /> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); //Act HtmlCheckBox checkBox = window.Find <HtmlCheckBox>(By.Id("checkBoxId")); //Assert Assert.IsTrue(checkBox.Exists); Assert.IsTrue(checkBox.Checked); window.Close(); } }
public void SelectedItems_OnHtmlList_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var bWin = new BrowserWindowUnderTest("test"); HtmlList list = bWin.Find <HtmlList>(By.Id("selectId")); string[] itemsToSelect = { "1", "2" }; //Act list.SelectedItems = itemsToSelect; //Assert CollectionAssert.AreEqual(itemsToSelect, list.SelectedItems); bWin.Close(); } }
public void SetText_OnHtmlEdit_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <div id=""div1""> <input type=""text""/> </div> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlDiv div = window.Find <HtmlDiv>(By.Id("div1")); HtmlEdit inputTextBox = div.Find <HtmlEdit>(); //Act inputTextBox.Text = "text"; //Assert Assert.AreEqual("text", inputTextBox.Text); window.Close(); } }
public void Click_OnHtmlInputButtonWithEqualsSignInSearchPropertyValue_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <input type=""submit"" value=""="" onclick=""alert('onclick');""/> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlInputButton button = window.Find <HtmlInputButton>(By.ValueAttribute("=")); //Act button.Click(); window.PerformDialogAction(BrowserDialogAction.Ok); window.Close(); } }
public void InnerText_OnHtmlComboBoxWithDisabledItems_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlComboBox comboBox = window.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()); window.Close(); } }
public void LabelFor_OnHtmlLabel_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlLabel label = window.Find <HtmlLabel>(By.Id("other")); //Assert Assert.AreEqual("other", label.LabelFor); window.Close(); } }
public void HtmlInputButton_ClickInIFrame_Succeeds() { var bWin = BrowserWindowUnderTest.Launch(currentDirectory + "/iframe_test.html"); bWin.Find <HtmlInputButton>(By.ValueAttribute("Log In")).Click(); bWin.Close(); }
public void HtmlFileInput_SetFile_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <input name=""inputName"" type=""file"" id=""inputId"" /> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlFileInput fileInput = window.Find <HtmlFileInput>(By.Id("inputId")); string tempInputFilePath = Path.GetTempFileName(); //Act fileInput.FileName = tempInputFilePath; window.Close(); File.Delete(tempInputFilePath); } }
public void Launch_UsingNewInstanceOfABrowserWindow_CanUsePartialWindowTitle() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test 1 2 3</title> </head> <body> <button id=""buttonId"" >Button</button> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); //Act HtmlButton button = window.Find <HtmlButton>(By.Id("buttonId")); //Assert Assert.AreEqual(button.InnerText, "Button"); Trace.WriteLine(window.Uri.ToString()); window.Close(); } }
public void Click_OnHtmlHyperlink_InTableWithEmptyCell_Succeeds() { // Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); var table = window.Find <HtmlTable>(By.Id("tableId")); HtmlCell cell = table.GetCell(0, 1); HtmlHyperlink hyperlink = cell.Find <HtmlHyperlink>(); // Act hyperlink.Click(); // TODO: Assert window.Close(); } }
public void SetText_OnHtmlPassword_Succeeds() { // Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlPassword txtPwd = window.Find <HtmlPassword>(By.Id("i0118")); // Act txtPwd.Text = "hello"; // TODO: Assert window.Close(); } }
public void Get_UsingMultipleValuesOfClassAttributeWithContainsOperatorOfHtmlSpan_ReturnsTheSpecificElementWithAllSpecifiedClassValues() { // Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlSpan span3 = window.Find <HtmlSpan>(By .Class("class1", PropertyExpressionOperator.Contains) .AndClass("class2", PropertyExpressionOperator.Contains)); // Act and Assert Assert.AreEqual("span3", span3.SourceControl.Name); window.Close(); } }
public void SelectItem_ByIndexOnHtmlComboBox_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <select id=""selectId""> <option>Cricket</option> <option>Football</option> <option>Tennis</option> </select> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); //Act HtmlComboBox comboBox = window.Find <HtmlComboBox>(By.Id("selectId")); comboBox.SelectIndex(1); //Assert Assert.AreEqual("Football", comboBox.SelectedItem); window.Close(); } }
public void GetHtmlDiv_ByClass_Succeeds() { // Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); // Act HtmlDiv div = window.Find <HtmlDiv>(By.Class("button")); HtmlHyperlink about = window.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); window.Close(); } }
public void GetHtmlRow_ById_Succeeds() { // Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); // Act HtmlRow row = window.Find <HtmlRow>(By.Id("555002_gp2")); // Assert Assert.IsTrue(row.Exists); window.Close(); } }
public void ClickAllControlsOnPage_UsingReflection_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <a href=""#"">test</a> <button>test</button> <input type=""text"" value=""test""/> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); IControlBase a = window.Get<HtmlHyperlink>("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(BrowserWindowUnderTest).GetMethod("Get"); foreach(Type t in list) { MethodInfo test = getMethodInfo.MakeGenericMethod(t); IControlBase control; if ((t == typeof(HtmlEdit)) || (t == typeof(HtmlTextArea))) { control = (IControlBase)test.Invoke(window, new object[] { "Value=test" }); } else { //window.Get<t>("InnerText=test"); control = (IControlBase)test.Invoke(window, new object[] { "InnerText=test" }); } //Act control.Click(); if (control is HtmlEdit) { (control as HtmlEdit).SetText("text"); } else if (control is HtmlTextArea) { (control as HtmlTextArea).SetText("text"); } } window.Close(); } }
public void ClickAllControlsOnPage_UsingReflection_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <a href=""#"">test</a> <button>test</button> <input type=""text"" value=""test""/> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); ControlBase a = window.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(BrowserWindowUnderTest).GetMethod("Find", new[] { typeof(By) }); foreach (Type t in list) { MethodInfo test = getMethodInfo.MakeGenericMethod(t); ControlBase control; if ((t == typeof(HtmlEdit)) || (t == typeof(HtmlTextArea))) { control = (ControlBase)test.Invoke(window, new object[] { By.ValueAttribute("test") }); } else { //window.Find<t>("InnerText=test"); control = (ControlBase)test.Invoke(window, new object[] { 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"; } } window.Close(); } }
public void Launch_TempHtmlFile_CanFindHyperlinkByHref() { // Arrange using (TempFile tempFile = new TempFile( @"<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 BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); // Assert HtmlHyperlink SignUpHyperLink = window.Find <HtmlHyperlink>(By.SearchProperties("href~registration")); Assert.IsTrue(SignUpHyperLink.Exists, "SignUp not found"); window.Close(); } }
public void GetSelectedValue_OfRadioButton_Succeeds() { // Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); // Act HtmlRadioButton genderTypeMale = window.Find <HtmlRadioButton>(By.Name("radio:tab1:gender.type.male")); // Assert Assert.IsTrue(genderTypeMale.Selected); Assert.AreEqual("male", genderTypeMale.ValueAttribute); window.Close(); } }
public void SlList_InObjectRepository_Succeeds() { SlTestPage oSlTestPage = BrowserWindowUnderTest.Launch <SlTestPage>(silverlightApplicationHtmlPageUrl); oSlTestPage.oList.SelectedIndices = new[] { 2 }; Assert.IsTrue(oSlTestPage.oList.SelectedItemsAsString == "Coded UI Test"); oSlTestPage.Close(); }
public void HtmlParagraph_InObjectRepository_Succeeds() { var testpage = BrowserWindowUnderTest.Launch <TestHtmlPage>(currentDirectory + "/TestHtmlPage.html"); string content = testpage.p.InnerText; Assert.IsTrue(content.Contains("HtmlParagraph")); testpage.Close(); }
public void HtmlTable_ColumnCount_Succeeds() { BrowserWindow.Launch(currentDirectory + "/TestHtmlPage.html"); var bWin = new BrowserWindowUnderTest("A Test"); var tbl = bWin.Find <HtmlTable>(By.Id("calcWithHeaders")); Assert.AreEqual(3, tbl.ColumnCount); bWin.Close(); }
public void HtmlTable_FindRowUsingTableWithoutRowHeaders_Succeeds() { var bWin = BrowserWindowUnderTest.Launch(currentDirectory + "/TestHtmlPage.html"); var tbl = bWin.Find <HtmlTable>(By.Id("calcWithOutHeaders")); tbl.FindRowAndClick("9", 2, HtmlTableSearchOptions.NormalTight); Assert.AreEqual("9", tbl.GetCellValue(2, 2).Trim()); bWin.Close(); }
public void HtmlTable_GetCellValueWithHeaderCell_Succeeds() { var bWin = BrowserWindowUnderTest.Launch(currentDirectory + "/TestHtmlPage.html"); var termTable = bWin.Find <HtmlTable>(By.Id("calcWithHeaderCells")); Assert.AreEqual("3", termTable.GetCellValue(1, 1)); bWin.Close(); }
public void HtmlTable_ClickOnColumnHeader_Succeeds() { BrowserWindow.Launch(currentDirectory + "/TestHtmlPage.html"); var bWin = new BrowserWindowUnderTest("A Test"); var tbl = bWin.Find <HtmlTable>(By.Id("tableWithAlertOnHeaderClick")); tbl.FindHeaderCellAndClick(0, 0); bWin.PerformDialogAction(BrowserDialogAction.Ok); bWin.Close(); }
public void SlComboBox_SelectItem_Succeeds() { BrowserWindowUnderTest.Launch(testSilverlightApplicationHtmlPageUrl); BrowserWindowUnderTest b = new BrowserWindowUnderTest("Home"); b.SetFocus(); SilverlightComboBox oCombo = b.Get<SilverlightComboBox>("AutomationId=comboBox1"); oCombo.SelectItem(3); foreach (string temp in oCombo.Items) { Console.WriteLine(temp); } b.Close(); }
public void SlComboBox_SelectItem_Succeeds() { BrowserWindowUnderTest.Launch(silverlightApplicationHtmlPageUrl); BrowserWindowUnderTest b = new BrowserWindowUnderTest("Home"); b.SetFocus(); SilverlightComboBox oCombo = b.Find<SilverlightComboBox>(By.AutomationId("comboBox1")); oCombo.SelectIndex(3); foreach (UITestControl temp in oCombo.Items) { Console.WriteLine(temp.Name); } b.Close(); }
public void Launch_TempHtmlFileWithInputWithMaxLength_CanSetTextWhichExceedsMaxLength() { // Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <input id=""input"" type=""text"" maxlength=10 /> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlEdit input = window.Get<HtmlEdit>("id=input"); // Act string inputText = "12345678901"; string outputText = "1234567890"; Keyboard.SendKeys(input.UnWrap(), inputText); // Assert Assert.AreEqual(input.GetText(), outputText); window.Close(); } }
public void HtmlButton_HiddenByStyle_ControlExistsAndCanAssertOnStyle() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <button id=""buttonId"" style=""display: none;"" >Hidden</button> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); //Act HtmlButton button = window.Get<HtmlButton>("id=buttonId"); //Assert Assert.IsTrue(button.Exists); Assert.IsTrue(button.UnWrap().ControlDefinition.Contains("style=\"display: none;\"")); window.Close(); } }
public void SetText_OnHtmlEdit_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <div id=""div1""> <input type=""text""/> </div> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlDiv div = window.Get<HtmlDiv>("id=div1"); HtmlEdit inputTextBox = div.Get<HtmlEdit>(); //Act inputTextBox.SetText("text"); //Assert Assert.AreEqual("text", inputTextBox.GetText()); window.Close(); } }
public void SelectedItems_OnHtmlList_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var bWin = new BrowserWindowUnderTest("test"); HtmlList list = bWin.Get<HtmlList>("id=selectId"); string[] itemsToSelect = { "1", "2" }; //Act list.SelectedItems = itemsToSelect; //Assert CollectionAssert.AreEqual(itemsToSelect, list.SelectedItems); bWin.Close(); } }
public void GetChildren_UsingHyperlinks_CanFindHyperlinkByInnerText() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <div id=""div1""> <a href=""#"">A - B - C</a> <a href=""#"">A - F - E</a> <a href=""#"">A - D - E</a> <a href=""#"">Z - B - C</a> <a href=""#"">Z - D - E</a> </div> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); //Act List<IControlBase> collection = window.Get<HtmlDiv>("id=div1").GetChildren(); foreach (IControlBase control in collection) { if (control is HtmlHyperlink) { HtmlHyperlink link = (HtmlHyperlink)control; if (link.InnerText.StartsWith("A")) { Trace.WriteLine(string.Format("found: {0}", link.InnerText)); } } } window.Close(); } }
public void Click_OnHtmlInputButtonWithEqualsSignInSearchParameterValue_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <input type=""submit"" value=""="" onclick=""alert('onclick');""/> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlInputButton button = window.Get<HtmlInputButton>("Value=="); //Act button.Click(); window.PerformDialogAction(BrowserDialogAction.Ok); window.Close(); } }
public void HtmlInputButton_UsingSearchParameterWithValueAsKey_Succeeds() { //Internet Explorer may display the message: Internet Explorer restricted this webpage from running scripts or ActiveX controls. //This security restriction prevents the alert message to appear. //To enable running scripts on the local computer, go to Tools > Internet options > Advanced > Security > [checkmark] Allow active content to run in files on My Computer //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <input type=""submit"" value=""Log In"" onclick=""alert('onclick');""/> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlInputButton button = window.Get<HtmlInputButton>("Value=Log In"); //Act button.Click(); if (BrowserWindowUnderTest.GetCurrentBrowser() is InternetExplorer) { //read JavaScript alert text WinWindow popup = new WinWindow("ClassName=#32770;Name=Message from webpage"); WinText text = popup.Get<WinText>(); Assert.AreEqual("onclick", text.DisplayText); } window.PerformDialogAction(BrowserDialogAction.Ok); window.Close(); } }
public void GetHtmlRow_ById_Succeeds() { // Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); // Act HtmlRow row = window.Get<HtmlRow>("id=555002_gp2"); // Assert Assert.IsTrue(row.Exists); window.Close(); } }
public void HtmlTable_ColumnCount_Succeeds() { BrowserWindow.Launch(currentDirectory + "/TestHtmlPage.html"); var bWin = new BrowserWindowUnderTest("A Test"); var tbl = bWin.Get<HtmlTable>("id=calcWithHeaders"); Assert.AreEqual(3, tbl.ColumnCount); bWin.Close(); }
public void HtmlTable_ClickOnColumnHeader_Succeeds() { BrowserWindow.Launch(currentDirectory + "/TestHtmlPage.html"); var bWin = new BrowserWindowUnderTest("A Test"); var tbl = bWin.Get<HtmlTable>("id=tableWithAlertOnHeaderClick"); tbl.FindHeaderAndClick(0, 0); bWin.PerformDialogAction(BrowserDialogAction.Ok); bWin.Close(); }
public void HtmlTable_FindHeaderAndClick_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <table style=""width: 100%;"" id=""tableId""> <tbody> <tr> <td>Commitment</td> <th>September</th> <th>October</th> <th>November</th> <td>Total</td> </tr> <tr> <td>Beginning Balance</td> <td>¥21,570,253</td> <td>¥21,375,491</td> <td>¥21,200,873</td> <td></td> </tr> <tr> <td>New Purchases</td> <td>¥0</td> <td>¥0</td> <td>¥0</td> <td></td> </tr> <tr> <td>Utilized</td> <td>¥194,762</td> <td>¥174,618</td> <td>¥0</td> <td>¥369,380</td> </tr> <tr> <td>Ending Balance</td> <td>¥21,375,491</td> <td>¥21,200,873</td> <td>¥21,200,873</td> <td></td> </tr> <tr> <td><b>Overage</b></td> <td>¥0</td> <td>¥0</td> <td>¥0</td> <td>¥0</td> <td></td> </tr> <tr> <td><b>Total Usage</b></td> <td>¥194,762</td> <td>¥174,618</td> <td>¥0</td> <td>¥369,380</td> </tr> </tbody> </table> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); var table = window.Get<HtmlTable>("id=tableId"); //Act table.FindHeaderAndClick(0, 2); window.Close(); } }
public void HtmlTable_GetCellValueUsingTableWithTHInTBODY_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); var table = window.Get<HtmlTable>("id=tableId"); //Act table.FindRowAndClick(0, "LUN_04", HtmlTableSearchOptions.NormalTight); //Assert Assert.AreEqual("LUN_04", table.GetCellValue(1, 0).Trim()); window.Close(); } }
public void HtmlTable_GetColumnHeaders_Succeeds() { BrowserWindow.Launch(currentDirectory + "/TestHtmlPage.html"); var bWin = new BrowserWindowUnderTest("A Test"); var tbl = bWin.Get<HtmlTable>("id=calcWithHeaders"); string[] saExpectedValues = { "Header1", "Header2", "Header3" }; string[] saHeaders = tbl.GetColumnHeaders(); Assert.AreEqual(saExpectedValues[0], saHeaders[0]); Assert.AreEqual(saExpectedValues[1], saHeaders[1]); Assert.AreEqual(saExpectedValues[2], saHeaders[2]); bWin.Close(); }
public void Get_UsingMultipleValuesOfClassAttributeWithContainsOperatorOfHtmlSpan_ReturnsTheSpecificElementWithAllSpecifiedClassValues() { // Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlSpan span3 = window.Get<HtmlSpan>("Class~class1;Class~class2"); // Act and Assert Assert.AreEqual("span3", span3.UnWrap().Name); window.Close(); } }
public void HtmlInputButton_GetWithValueContainingWhitespace_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <input name=""inputName"" type=""submit"" value="" Search "" /> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlInputButton button = window.Get<HtmlInputButton>("Value= Search "); //Act button.Click(); window.Close(); } }
public void GetSelectedValue_OfRadioButton_Succeeds() { // Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); // Act HtmlRadioButton genderTypeMale = window.Get<HtmlRadioButton>("Name=radio:tab1:gender.type.male"); // Assert Assert.IsTrue(genderTypeMale.IsSelected); Assert.AreEqual("male", genderTypeMale.ValueAttribute); window.Close(); } }
public void HtmlHyperlink_OnSharePoint2010_Succeeds() { BrowserWindow.Launch("http://myasia/sites/sureba/Default.aspx"); BrowserWindowUnderTest.Authenticate("username", "passwd"); var bWin = new BrowserWindowUnderTest("Suresh Balasubramanian"); bWin.Get<HtmlHyperlink>("Id=idHomePageNewDocument").Click(); var closeLink = bWin.Get<HtmlHyperlink>("Title=Close;class=ms-dlgCloseBtn"); //clicking closeLink directly doesn't work as the maximizeLink is clicked due to the controls being placed too close to each other Mouse.Click(closeLink.UnWrap().GetChildren()[0].GetChildren()[0]); bWin.RunScript(@"STSNavigate2(event,'/sites/sureba/_layouts/SignOut.aspx');"); }
public void GetHtmlDiv_ByClass_Succeeds() { // Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); // Act HtmlDiv div = window.Get<HtmlDiv>("class=button"); HtmlHyperlink about = window.Get<HtmlHyperlink>("InnerText=about text;href~about"); HtmlDiv div2 = about.Parent as HtmlDiv; // Assert Assert.IsTrue(div.Exists); Assert.AreEqual("main text", div.UnWrap().InnerText); Assert.IsTrue(about.Exists); Assert.IsTrue(div2.Exists); Assert.AreEqual("about text", div2.UnWrap().InnerText); window.Close(); } }
public void HtmlFileInput_SetFile_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <input name=""inputName"" type=""file"" id=""inputId"" /> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlFileInput fileInput = window.Get<HtmlFileInput>("Id=inputId"); string tempInputFilePath = Path.GetTempFileName(); //Act fileInput.SetFile(tempInputFilePath); window.Close(); File.Delete(tempInputFilePath); } }
public void Enabled_OnDisabledHtmlInputButton_ReturnsFalse() { // Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <input name=""inputName"" type=""submit"" value=""Click here"" disabled=""disabled"" /> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlInputButton button = window.Get<HtmlInputButton>("Value=Click here"); // Act and Assert Assert.IsFalse(button.Enabled); window.Close(); } }
public void HtmlControl_NonExistent_DoesNotExist() { //Arrange SmartMatchOptions smartMatchOptions = SmartMatchOptions.Control; try { //set SmartMatchOptions to None because we are using .Exists on an invalid control //remember previous setting so that it can be reset smartMatchOptions = Playback.PlaybackSettings.SmartMatchOptions; Playback.PlaybackSettings.SmartMatchOptions = SmartMatchOptions.None; using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); //Act HtmlDiv div = window.Get<HtmlDiv>("Id=invalid"); //Assert Assert.IsFalse(div.Exists); window.Close(); } } finally { //reset default setting Playback.PlaybackSettings.SmartMatchOptions = smartMatchOptions; } }
public void SetText_OnHtmlPassword_Succeeds() { // Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); HtmlPassword txtPwd = window.Get<HtmlPassword>("id=i0118"); // Act txtPwd.SetText("hello"); // TODO: Assert window.Close(); } }
public void HtmlComboBox_Items_Succeeds() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <select id=""selectId""> <option>Cricket</option> <option>Football</option> <option>Tennis</option> </select> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); //Act HtmlComboBox comboBox = window.Get<HtmlComboBox>("Id=selectId"); //Assert Assert.AreEqual("Football", comboBox.Items[1]); Assert.IsTrue(comboBox.ItemExists("Cricket")); window.Close(); } }
public void Click_OnHtmlHyperlink_InTableWithEmptyCell_Succeeds() { // Arrange using (TempFile tempFile = new TempFile( @"<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>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); var table = window.Get<HtmlTable>("Id=tableId"); HtmlCell cell = table.GetCell(0, 1); HtmlHyperlink hyperlink = cell.Get<HtmlHyperlink>(); // Act hyperlink.Click(); // TODO: Assert window.Close(); } }
public void HtmlCheckBox_DisabledByStyle_ControlExistsAndCanGetCheckedState() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test</title> </head> <body> <input type=""checkbox"" id=""checkBoxId"" disabled=""disabled"" name=""checkBoxName"" checked=""checked"" /> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); //Act HtmlCheckBox checkBox = window.Get<HtmlCheckBox>("id=checkBoxId"); //Assert Assert.IsTrue(checkBox.Exists); Assert.IsTrue(checkBox.Checked); window.Close(); } }
public void Launch_TempHtmlFile_CanFindHyperlinkByHref() { // Arrange using (TempFile tempFile = new TempFile( @"<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 BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); // Assert HtmlHyperlink SignUpHyperLink = window.Get<HtmlHyperlink>("href~registration"); Assert.IsTrue(SignUpHyperLink.Exists, "SignUp not found"); window.Close(); } }
public void Launch_UsingNewInstanceOfABrowserWindow_CanUsePartialWindowTitle() { //Arrange using (TempFile tempFile = new TempFile( @"<html> <head> <title>test 1 2 3</title> </head> <body> <button id=""buttonId"" >Button</button> </body> </html>")) { BrowserWindow.Launch(tempFile.FilePath); var window = new BrowserWindowUnderTest("test"); //Act HtmlButton button = window.Get<HtmlButton>("id=buttonId"); //Assert Assert.AreEqual(button.InnerText, "Button"); Trace.WriteLine(window.Uri.ToString()); window.Close(); } }