需要通过XPath点击桌面应用程序上的各种图片框

时间:2018-01-31 14:54:16

标签: c# selenium xpath winappdriver

我正在自动化我的桌面应用程序,但我被困在这一部分。我需要在该应用程序中点击“Sim”和“Não”(是和否)按钮。 Thoose按钮是图片框。这是这部分的xml。

<Pane AcceleratorKey="" AccessKey="" AutomationId="597776" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="Requi" Orientation="None" ProcessId="7700" RuntimeId="42.597776" x="1526" y="264" width="355" height="125">
    <Pane AcceleratorKey="" AccessKey="" AutomationId="Txo" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="Requi" Orientation="None" ProcessId="7700" RuntimeId="42.597938" x="1526" y="264" width="355" height="125">
        <Pane AcceleratorKey="" AccessKey="" AutomationId="tlpMain" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="" Orientation="None" ProcessId="7700" RuntimeId="42.532546" x="1526" y="264" width="355" height="125">
            <Pane AcceleratorKey="" AccessKey="" AutomationId="pnlTitle" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="" Orientation="None" ProcessId="7700" RuntimeId="42.535706" x="1541" y="264" width="325" height="25">
                <Text AcceleratorKey="" AccessKey="" AutomationId="lblTitleItem" ClassName="WindowsForms10.STATIC.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="Txo" Orientation="None" ProcessId="7700" RuntimeId="42.469970" x="1541" y="264" width="95" height="20" />
            </Pane>
            <Pane AcceleratorKey="" AccessKey="" AutomationId="pnlComentario" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="selecionado" Orientation="None" ProcessId="7700" RuntimeId="42.1314788" x="1544" y="380" width="319" height="1" />
            <Pane AcceleratorKey="" AccessKey="" AutomationId="tlpFluxoBtns" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="Txo" Orientation="None" ProcessId="7700" RuntimeId="42.531754" x="1541" y="289" width="325" height="88">
                <Pane AcceleratorKey="" AccessKey="" AutomationId="pnlSeparator4" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="" Orientation="None" ProcessId="7700" RuntimeId="42.532058" x="1784" y="328" width="8" height="1" />
                <Pane AcceleratorKey="" AccessKey="" AutomationId="pnlSeparator3" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="" Orientation="None" ProcessId="7700" RuntimeId="42.793038" x="1733" y="328" width="8" height="1" />
                <Pane AcceleratorKey="" AccessKey="" AutomationId="pnlSeparator2" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="" Orientation="None" ProcessId="7700" RuntimeId="42.990874" x="1662" y="328" width="27" height="1" />
                <Pane AcceleratorKey="" AccessKey="" AutomationId="picBoxAutomatico" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="Txo" Orientation="None" ProcessId="7700" RuntimeId="42.663288" x="1563" y="307" width="45" height="44" />
                <Pane AcceleratorKey="" AccessKey="" AutomationId="picBoxNP" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="" Orientation="None" ProcessId="7700" RuntimeId="42.532350" x="1792" y="307" width="43" height="44" />
                <Pane AcceleratorKey="" AccessKey="" AutomationId="picBoxNao" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="" Orientation="None" ProcessId="7700" RuntimeId="42.598804" x="1741" y="307" width="43" height="44" />
                <Pane AcceleratorKey="" AccessKey="" AutomationId="picBoxSim" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="" Orientation="None" ProcessId="7700" RuntimeId="42.663220" x="1689" y="307" width="44" height="44" />
                <Pane AcceleratorKey="" AccessKey="" AutomationId="picBoxSeta" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="" Orientation="None" ProcessId="7700" RuntimeId="42.598552" x="1635" y="307" width="27" height="44" />
                <Pane AcceleratorKey="" AccessKey="" AutomationId="pnlSeparator1" ClassName="WindowsForms10.Window.8.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="painel" Name="" Orientation="None" ProcessId="7700" RuntimeId="42.599048" x="1608" y="328" width="27" height="1" />
                <Text AcceleratorKey="" AccessKey="" AutomationId="lblSelecionado" ClassName="WindowsForms10.STATIC.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="selecionado" Orientation="None" ProcessId="7700" RuntimeId="42.664166" x="1689" y="290" width="147" height="15" />
                <CheckBox AcceleratorKey="" AccessKey="" AutomationId="chkBoxAdicionarComentario" ClassName="WindowsForms10.BUTTON.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="caixa de seleção" Name="Adicionar Comentário" Orientation="None" ProcessId="7700" RuntimeId="42.600486" x="1692" y="354" width="171" height="20" ToggleState="Off" IsAvailable="True" />
                <Text AcceleratorKey="" AccessKey="" AutomationId="lblAutomatico" ClassName="WindowsForms10.STATIC.app.0.83dd9_r9_ad1" FrameworkId="WinForm" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="automático" Orientation="None" ProcessId="7700" RuntimeId="42.598118" x="1541" y="290" width="94" height="15" />
            </Pane>
        </Pane>
    </Pane>
</Pane>

我需要点击来自AutomationId =“Txo”的AutomationId =“picBoxSim”(Txo是可用的itens之一,还有很多。相同的XML只将AutomationId =“Txo”改为AutomationId =“ “; 我尝试过几个代码,但似乎没什么用。

喜欢这个:

Driver.Session.FindElementByXPath("//Pane[@AutomationId='Txo']").FindElementByXPath("//Pane[@AutomationId='picBoxSim']").Click();

0 个答案:

没有答案