public async Task OnGetElement_ItRetrievesItemsByBaseType() { await Window.SetXamlContent(@"<TextBox x:Name=""TestName""/>"); IVisualElement <TextBoxBase> element = await Window.GetElement <TextBoxBase>("/TextBoxBase"); Assert.AreEqual("TestName", await element.GetName()); }
public async Task OnGetElement_ItRetrievesElementByAutomationIdValue() { await Window.SetXamlContent(@" <Grid> <TextBox x:Name=""MyTextBox"" Text=""Text"" AutomationProperties.AutomationId=""TextBoxId""/> </Grid>"); IVisualElement <TextBox> element = await Window.GetElement <TextBox>("[AutomationProperties.AutomationId=\"TextBoxId\"]"); Assert.AreEqual("MyTextBox", await element.GetName()); }
public async Task OnGetElement_WithNonGenericReference_CanCastToGeneric() { // Arrange await using TestRecorder recorder = new(App); await Window.SetXamlContent(@"<StackPanel x:Name=""Panel"" />"); IVisualElement panel = await Window.GetElement("Panel"); //Act IVisualElement <StackPanel> stackPanel = panel.As <StackPanel>(); //Assert Assert.AreEqual("Panel", await stackPanel.GetName()); recorder.Success(); }
public async Task OnGetProperty_WhenPropertyIsDependencyObject_GetVisualElement() { // Arrange await using TestRecorder recorder = new(App); await Window.SetXamlContent(@" <StackPanel x:Name=""Panel""> <StackPanel.ContextMenu> <ContextMenu x:Name=""TestContextMenu""/> </StackPanel.ContextMenu> </StackPanel>"); IVisualElement <StackPanel> stackPanel = await Window.GetElement <StackPanel>("Panel"); //Act IVisualElement <ContextMenu>?contextMenu = await stackPanel.GetContextMenu(); //Assert Assert.IsNotNull(contextMenu); Assert.AreEqual("TestContextMenu", await contextMenu.GetName()); recorder.Success(); }