private void Select_FirstSelectedOptions(string driverName) { System.Collections.ObjectModel.Collection <PSObject> coll = new System.Collections.ObjectModel.Collection <PSObject>(); coll.Add((new PSObject(Settings.TestFile05Controls1ElementSelect04Value02Name))); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"$null = Start-SeWebDriver -DriverName '" + driverName + @"' | Enter-SeURL -URL '" + MiddleLevelCode.GetURLFromPath(System.IO.Path.GetFullPath(Settings.TestFile05Controls1)) + @"' | Get-SeWebElement -XPath '" + Settings.TestFile05Controls1ElementSelect04XPath + @"' | Set-SeSelection -Index 1,2,3; " + @"Get-SeWebElement -XPath '" + Settings.TestFile05Controls1ElementSelect04XPath + //@"' | Get-SeSelection -FirstSelected | %{ $_ | Read-SeWebElementText; };", @"' | Get-SeSelection -FirstSelected | Read-SeWebElementText;", coll); }
public void GetWindowByNameTimeout3000Delay5000() { MiddleLevelCode.StartProcessWithForm( UIAutomationTestForms.Forms.WinFormsEmpty, TimeoutsAndDelays.Form_Delay5000); CmdletUnitTest.TestRunspace.RunAndGetTheException( @"if ((Get-UiaWindow -Name " + MiddleLevelCode.TestFormNameEmpty + " -timeout 3000 " + ")) { 0; } else { 1; }", "CmdletInvocationException", // 20130318 //"Failed to get the window by: process name: '' process Id: window title: 'WinFormsEmpty'"); // 20131108 //"Failed to get the window by: process name: '', process Id: , window title: 'WinFormsEmpty', automationId: '', className: ',"); // 20140110 // "Failed to get window in 3000 seconds by: process name: '', process Id: , window title: 'WinFormsEmpty', automationId: '', className: ''"); "Failed to get window in 3000 milliseconds by: process name: '', process Id: , window title: 'WinFormsEmpty', automationId: '', className: ''."); }
public void GetMenuBarByAutomationIDTimeoutDefault() { string auId = "MenuBar111"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.MenuBar, "aaa", auId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaMenuBar -AutomationId " + auId + " | " + "Read-UiaControlAutomationId", auId); }
public void Invoke_ControlContextMenu_from_window_coordinated() { string expectedResult = "WindowMenuLevel1-2"; MiddleLevelCode.StartProcessWithForm( UIAutomationTestForms.Forms.WinFormsWithMenus, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"[string]$menuItemName = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Invoke-UiaControlContextMenu -X 50 -Y 50 | Get-UiaMenuItem -Name '" + expectedResult + "' | Invoke-UiaMenuItemClick | Read-UiaControlName; " + @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaList | Get-UiaListItem -Name '" + expectedResult + "' | Read-UiaControlName;", expectedResult); }
public void GetListBoxByAutomationIDTimeout2000() { string auId = "List111"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.List, "aaa", auId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaList -AutomationId " + auId + " -timeout 2000 | " + "Read-UiaControlAutomationId", auId); }
public void Invoke_ListItem_Toggle1() { string expectedResult = "SelectedIndexChanged"; MiddleLevelCode.StartProcessWithForm( UIAutomationTestForms.Forms.WinFormsFull, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"$null = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + @" | Get-UiaList -AutomationId checkedListBox1 " + @" | Get-UiaListItem -Name a1 | Invoke-UiaListItemToggle;" + @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + @" | Get-UiaList -AutomationId listBox1 | " + @"Get-UiaListItem -Name " + expectedResult + " | Read-UiaControlName;", expectedResult); }
public void GetControlAncestors() { string auId = "Button111"; string formName = MiddleLevelCode.TestFormNameEmpty; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.Button, "aaa", auId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaControl -AutomationId " + auId + " | Get-UiaControlAncestors -ControlType Window | Read-UiaControlName;", formName); }
private void TestPrm_Id_WebElementInput(string driverName) { System.Collections.ObjectModel.Collection <PSObject> coll = new System.Collections.ObjectModel.Collection <PSObject>(); coll.Add((new PSObject(Settings.TestFile05Controls1ElementLink03Answer))); coll.Add((new PSObject(Settings.TestFile05Controls1ElementLink04Answer))); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Start-SeWebDriver -DriverName '" + driverName + @"' | Enter-SeURL -URL '" + MiddleLevelCode.GetURLFromPath(System.IO.Path.GetFullPath(Settings.TestFile05Controls1)) + @"' | Get-SeWebElement -Id '" + Settings.TestFile05Controls1ElementLinksDiv + @"' -First | Get-SeWebElement -Id '" + Settings.TestFile05Controls1ElementLinkIds + //@"' | %{ $_ | Read-SeWebElementText; }", @"' | Read-SeWebElementText;", coll); }
public void Invoke_Hyperlink_Click() { string expectedResult = "Invoked"; MiddleLevelCode.StartProcessWithForm( UIAutomationTestForms.Forms.WinFormsFull, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"$null = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaHyperlink -Name linkLabel1 | Invoke-UiaHyperlinkClick;" + @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaList -AutomationId listBox1 | " + "Get-UiaListItem -Name " + expectedResult + " | Read-UiaControlName;", expectedResult); }
public void GetTableByTitleTimeout2000Delay4000() { //string name = "Table222"; string name = "Properties Window"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.Table, "\"" + name + "\"", "btn", TimeoutsAndDelays.Control_Timeout2000Delay4000_Delay); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaTable -Name '" + name + "' -timeout 2000 | " + "Read-UiaControlName", name); }
public void ControlType_Existing() { const string expectedName = "btnName"; const string expectedAutomationId = "btnAuId"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, ControlType.Button, expectedName, expectedAutomationId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1( @"if ((Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " -au " + MiddleLevelCode.TestFormNameEmpty + " | Wait-UiaControlState -SearchCriteria @{controlType=\"button\"})) { 1; } else { 0; }"); }
public void GetRadioButtonByAutomationIDTimeout3000Delay500() { string auId = "RadioButton111"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.RadioButton, "aaa", auId, TimeoutsAndDelays.Control_Timeout3000Delay500_Delay); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaRadioButton -AutomationId " + auId + " -timeout 3000 | " + "Read-UiaControlAutomationId", auId); }
// the same as InvokeSelectItem_RadioButton() public void InvokeSelectionItemState_RadioButton() { string name1 = "RadioButton1"; string auId1 = "rb111"; string name2 = "RadioButton2"; string auId2 = "rb222"; string expectedResult = "True"; ControlToForm ctf = new ControlToForm( System.Windows.Automation.ControlType.RadioButton, name1, auId1, TimeoutsAndDelays.Control_Delay0); System.Collections.ArrayList arrList = new System.Collections.ArrayList(); arrList.Add(ctf); ctf = new ControlToForm( System.Windows.Automation.ControlType.RadioButton, name2, auId2, TimeoutsAndDelays.Control_Delay0); arrList.Add(ctf); MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, (ControlToForm[])arrList.ToArray(typeof(ControlToForm))); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"$null = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaRadioButton -AutomationId '" + auId1 + "' | Invoke-UiaRadioButtonSelectItem -ItemName '" + name1 + @"';" + @"Get-UiaRadioButton -AutomationId '" + auId1 + "' | Get-UiaRadioButtonSelectionItemState;", expectedResult); }
public void InvokeToggleStateGet_CheckBox_Off() { string name = "check_box"; string automationId = "chbx"; string expectedResult = "False"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.CheckBox, name, automationId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaCheckBox -Name '" + name + "' | Get-UiaCheckBoxToggleState;", expectedResult); }
public void Invoke_ButtonX2_Click() { string expectedResult = "Invoked*"; MiddleLevelCode.StartProcessWithForm( UIAutomationTestForms.Forms.WinFormsFull, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"$null = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaButton -Name button* | Invoke-UiaButtonClick;" + @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaList -AutomationId listBox1 | " + "Get-UiaListItem -Name " + expectedResult + " | Read-UiaControlName;", new Collection <PSObject> { new PSObject("Invoked2"), new PSObject("Invoked") }); }
public void ConvertToHashtable_AutomationId() { string auId = "Button111"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.Button, "aaa", auId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"$hashtable = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaControl -AutomationId " + auId + " | ConvertTo-UiaHashtable; " + // 20120831 // ?? "$hashtable['AutomationId'];", //"$hashtable[4].Value;", auId); }
public void GetTableByAutomationIDTimeout2000() { string auId = "Table111"; string name = "Properties Window"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.Table, "aaa", auId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaPane -AutomationId " + auId + " -timeout 2000 | Get-UiaTable -Name '" + name + "' | " + "Read-UiaControlName", name); }
public void Preferences_TimeoutAfterFail_Control() { string name = "Button333"; string timeoutInterval = "4000"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, TimeoutsAndDelays.Form_Delay0, System.Windows.Automation.ControlType.Button, name, "btn", TimeoutsAndDelays.Control_Delay0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"[UIAutomation.Preferences]::Timeout = " + timeoutInterval + "; " + @"try{ $null = Get-UiaWindow -n '" + UIAutomationTestForms.Forms.WinFormsEmpty + "' | Get-UiaButton -n '111' -IsCritical;} catch {} " + @"[UIAutomation.Preferences]::Timeout;", UIAutomation.Preferences.AfterFailTurboTimeout.ToString()); }
public void ListItem_RemoveFromSelection() { string expectedResult = "False"; MiddleLevelCode.StartProcessWithForm( UIAutomationTestForms.Forms.WinFormsFull, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"$null = (Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + @" | Get-UiaListItem a001).Select(); " + @"$null = (Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + @" | Get-UiaListItem b002).AddToSelection();" + @"$null = (Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + @" | Get-UiaListItem a001).RemoveFromSelection(); " + @"(Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + @" | Get-UiaListItem a001).IsSelected;", expectedResult); }
public void Invoke_TreeItem_Collapse() { string expectedResult = "Invoked"; string expectedResult1 = "CmdletInvocationException"; // 20130219 //string expectedResult2 = "Get-UiaTreeItem: timeout expired for class: ' + , control type: TreeItem, title: Node1"; // 20131129 // string expectedResult2 = @"Get-UiaTreeItem: timeout expired for control with class: + '', control type: 'TreeItem', title: 'Node1', automationId: '', value: ''"; // 20140110 // string expectedResult2 = @"Get-UiaTreeItem: timeout expired for control with class: + '', control type: 'System.String[]', title: 'Node1', automationId: '', value: ''"; // 20140111 // string expectedResult2 = @"Get-UiaTreeItem: failed to get control in 10000 milliseconds by: title: 'Node1', automationId: '', className: '', value: ''."; string expectedResult2 = @"failed to get control in 10000 milliseconds by: title: 'Node1', automationId: '', className: '', value: ''."; //string expectedResult2 = "GetUiaTreeItem: timeout expired for class: ' + , control type: TreeItem, title: Node1"; //string expectedResult2 = "A generic error occurred in GDI+."; MiddleLevelCode.StartProcessWithForm( UIAutomationTestForms.Forms.WinFormsFull, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"$null = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaTreeItem -Name Node0 | Invoke-UiaTreeItemExpand;" + @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaList -AutomationId listBox1 | " + "Get-UiaListItem -Name Invoked | Read-UiaControlName;", expectedResult); CmdletUnitTest.TestRunspace.RunAndGetTheException( @"$null = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaTreeItem -Name Node0 | Invoke-UiaTreeItemCollapse;" + @"$null = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaTreeItem -Name Node1;", expectedResult1, expectedResult2); }
public void RegisterMenuOpenedEvent() { string text = "File"; string eventType = "AutomationElementIdentifiers.MenuOpenedEvent"; MiddleLevelCode.StartProcessWithForm( UIAutomationTestForms.Forms.WinFormsFull, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"$null = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + @" | Register-UiaMenuOpenedEvent " + @"-EventAction {$i = 1;}; " + @"$null = Get-UiaMenuItem -Name '" + text + @"' | Invoke-UiaMenuItemClick -PassThru | Invoke-UiaMenuItemClick; " + @"$null = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + @" | Invoke-UiaControlClick; " + @"[UIAutomation.CurrentData]::LastEventType", eventType); }
public void ConvertToSearchCriteria_Default_AutomationId() { string auId = "Button111"; string result = "True"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, System.Windows.Automation.ControlType.Button, "aaa", auId, 0); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"$hashtable = Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " | Get-UiaControl -AutomationId " + auId + " | ConvertTo-UiaSearchCriteria; " + @"$hashtable.Contains('AutomationId=""" + auId + @"""');", result); }
public void GetControlPreviousSibling() { string name1 = "Button111"; string auId1 = "btn111"; string name2 = "Button222"; string auId2 = "btn22"; System.Collections.ArrayList arrList = new System.Collections.ArrayList(); arrList.Add( new ControlToForm( System.Windows.Automation.ControlType.Button, name1, auId1, TimeoutsAndDelays.Control_Delay0)); arrList.Add( new ControlToForm( System.Windows.Automation.ControlType.Button, name2, auId2, TimeoutsAndDelays.Control_Delay0)); ControlToForm[] ctf = (ControlToForm[])arrList.ToArray(typeof(ControlToForm)); string formName = MiddleLevelCode.TestFormNameEmpty; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, ctf); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual( @"Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + @" | Get-UiaButton -Name '" + name2 + "' | Get-UiaControlPreviousSibling | " + "Read-UiaControlAutomationId;", auId1); }
public void NameAutomationId_NonExisting_Delay() { const string expectedName = "btnName"; const string expectedAutomationId = "btnAuId"; MiddleLevelCode.StartProcessWithFormAndControl( UIAutomationTestForms.Forms.WinFormsEmpty, 0, ControlType.Button, expectedName, expectedAutomationId, TimeoutsAndDelays.Control_Delay4000); CmdletUnitTest.TestRunspace.RunAndEvaluateAreEqual1( @"if ((Get-UiaWindow -pn " + MiddleLevelCode.TestFormProcess + " -au " + MiddleLevelCode.TestFormNameEmpty + " | Wait-UiaControlState -SearchCriteria @{name=\"" + expectedName + "\";automationid=\"" + expectedAutomationId + "\"})) { 1; } else { 0; }"); }
private void Select_SelectAllOptions_WrongInput(string driverName) { System.Collections.ObjectModel.Collection <PSObject> coll = new System.Collections.ObjectModel.Collection <PSObject>(); coll.Add((new PSObject(Settings.TestFile05Controls1ElementSelect04Value01Name))); coll.Add((new PSObject(Settings.TestFile05Controls1ElementSelect04Value02Name))); coll.Add((new PSObject(Settings.TestFile05Controls1ElementSelect04Value03Name))); coll.Add((new PSObject(Settings.TestFile05Controls1ElementSelect04Value04Name))); CmdletUnitTest.TestRunspace.RunAndGetTheException( @"$null = Start-SeWebDriver -DriverName '" + driverName + @"' | Enter-SeURL -URL '" + MiddleLevelCode.GetURLFromPath(System.IO.Path.GetFullPath(Settings.TestFile05Controls1)) + @"' | Get-SeWebElement -XPath '" + Settings.TestFile05Controls1ElementSelect04XPath + @"' | Set-SeSelection -All; " + @"Get-SeWebElement -XPath '" + Settings.TestFile05Controls1ElementButton01XPath + //@"' | Get-SeSelection -Selected | %{ $_ | Read-SeWebElementText; };", @"' | Get-SeSelection -Selected | Read-SeWebElementText;", "ParameterBindingException", "A positional parameter cannot be found that accepts argument 'button'."); }
public void TearDown() { MiddleLevelCode.DisposeRunspace(); }
public void SetUp() { MiddleLevelCode.PrepareRunspace(); }
public void DisposeRunspace() { MiddleLevelCode.DisposeRunspace(); }
public void PrepareRunspace() { MiddleLevelCode.PrepareRunspaceForParamChecks(); }
public void IE_PageRefresh_IE() { PageRefresh( Settings.DriverNameInternetExplorer, MiddleLevelCode.GetURLFromPath(System.IO.Path.GetFullPath(Settings.TestFile05Controls1))); }