2014-09-02 6 views
2

Windows 응용 프로그램을 자동화하고 있습니다. 탭 컨트롤 아래에있는 창 요소 (텍스트 상자, 콤보 상자 컨트롤 있음)에 액세스하려고했지만 액세스 할 수 없습니다. 흰색은 null을 반환합니다.흰색/UI 자동화가 탭의 컨테이너 (창 컨트롤)를 인식하지 못합니다.

UI 자동화 TreeWalker (Rawview, 컨트롤보기, 내용보기)와 같은 다른 기술을 시도했지만 아무 도움이되지 않았습니다.

아래 링크에서 이미지를 참조하십시오 https://dl.dropboxusercontent.com/u/68446125/Tab.png https://dl.dropboxusercontent.com/u/68446125/General%20Pane.png

사진 1에서와 같이, 탭 컨트롤은 화이트/UI 자동화에 의해 제대로 검색되지만, 자식 요소는 일반 * 창은 반환되지 않으며이 컨트롤에 액세스 할 수 없습니다입니다 (강조 표시된 그림 2 참조) 첫 번째로 액세스 할 수있는 자식 요소는 "일반 * 탭 항목"입니다.

이상한 것은 Inspect.exe (Windows SDK)에서 이러한 컨트롤에 액세스 할 수 있다는 것입니다. 나는 컨트롤을 검색하기 위해 다음과 같은 방법을 시도했지만 General/Pane은 화이트/UI 자동화를 통해 액세스 할 수 없다.

var tab = Window.Get<Tab>(SearchCriteria.ByControlType(ControlType.Tab).AndByClassName("TwoPageControl")); // Tab control is retrieved properly 
var pane = tab.GetElement(SearchCriteria.ByControlType(ControlType.Pane).AndByText("General*")); // this line returns NULL 

var pane1 = revWindow.GetElement(SearchCriteria.ByControlType(ControlType.Pane).AndByText("General*")); // this line returns NULL 
var pane2 = revWindow.Get<Panel>(SearchCriteria.ByControlType(ControlType.Pane).AndByText("General*"));// throws exception "Failed to get ControlType=pane,Name=General*,ControlType=pane" 

시도한 Windows UI 자동화 코드뿐만 아니라 운.

System.Windows.Automation.Condition cd1 = new AndCondition(
       new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Tab), 
       new PropertyCondition(AutomationElement.ClassNameProperty, "TwoPageControl"));  

      AutomationElement a = window.FindFirst(TreeScope.Descendants, cd1); // Tab control is returned properly here 

      TreeWalker rawViewWalker = TreeWalker.RawViewWalker; 
      AutomationElement cc = rawViewWalker.GetFirstChild(a); // General * Pane is not returned, instead General* Tab item is returned, though it's not the first child. 
      var cd = rawViewWalker.GetNextSibling(cc); // this returns next pane element available, not General * Pane.    

일반 * 창과 탭 컨트롤 아래의 자녀에 대한 액세스 방법을 도와주세요. 어떤 도움이라도 대단히 감사합니다.

답변

1

제 신청서에는 정확히 동일한 문제가있었습니다. Inspect and open source UIAVerify를 사용하여 Pane 요소가 tab 요소의 자식으로 표시되는지 확인합니다. 하지만 .Net 4.5 프로젝트로 확인을 컴파일 할 때 창 요소가 탭의 일부로 표시되지 않았습니다. 내가 그것을 직접 지적했을 때에 만 나타난다. 또한 메인 윈도우의 자손에서 내 창 요소를 검색하지만 아무 것도 없습니다. 나는이 창 콘텐츠를 동적으로 생성하는 것과 관련이 있다고 생각합니다 (다른 tabItem을 선택할 때 다른 내용이 있음을 의미합니다).

트리 관점에서 해당 요소에 액세스 할 수 없다고 생각합니다.

내 솔루션은 AutomationElement.FromPoint 메서드를 사용했습니다. http://msdn.microsoft.com/en-us/library/system.windows.automation.automationelement.frompoint(v=vs.110).aspx

나는 프로그램을 개발하는 사람들과 협조하면이 큰 도움이된다고 생각합니다. Some controls on a page are not visible for MS UI Automation

0

TabPanel 만 해체 할 수 있지만 ContentPresenter는 제외 할 수 있습니다. 선택한 TabItem의 내용을 사용하는 고유 한 ContentPresenter를 만듭니다.

이렇게하면 White가 ContentPresenter에서 컨트롤을 검색 할 수 있습니다.

이것은 해결 방법이며 "무언가가 UIA에서 잘못되어"WPF 코드를 변경해야한다는 것은 수치스러운 일입니다. 그러나 이것이 내가 할 수있는 최선입니다.

<Grid> 

    <Grid.RowDefinitions> 
     <RowDefinition Height="*"/> 
     <RowDefinition Height="Auto"/> 
    </Grid.RowDefinitions> 

    <TabControl x:Name="uiTab" Grid.Row="1"> 

     <TabControl.Template> 
     <ControlTemplate TargetType="TabControl"> 
      <TabPanel IsItemsHost="True" VerticalAlignment="Stretch"/> 
     </ControlTemplate> 
     </TabControl.Template> 

     <TabItem Header="first"> 
     <Button>FIRST</Button> 
     </TabItem> 
     <TabItem Header="second"> 
     <Button>SECOND</Button> 
     </TabItem> 

    </TabControl> 

    <ContentPresenter Content="{Binding SelectedItem.Content, ElementName=uiTab}"/> 

    </Grid>