0

I'm automating my desktop application but I got stucked in this part. I need to avaliate itens in that application clicking on "Sim" e "Não" (Yes and No) buttons. Thoose buttons are pictureboxes. Here is the xml from this part.

<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>

I need to click on AutomationId="picBoxSim" from AutomationId="Txo"(Txo is one of the avaliable itens, there is a lot more. The same XML only changing the AutomationId="Txo" to AutomationId="something"; I've tried a few codes but nothing seems to work.

Like this one:

Driver.Session.FindElementByXPath("//Pane[@AutomationId='Txo']").FindElementByXPath("//Pane[@AutomationId='picBoxSim']").Click();
  • 1
    Can you update your ticket with correct source code sample position - it's almost invisible... – Andersson Jan 31 '18 at 14:56
  • Donne. Is it better now? (sorry, first time posting something here) – Yuri Costa de Oliveira Jan 31 '18 at 15:08
  • try `Driver.Session.FindElementByXPath("//Pane[@AutomationId='Tixotrópica']").FindElementByXPath(".//Pane[@AutomationId='pixBoxSim']").Click();`. Note that your second XPath should starts with `.` as `.//Pane...` – Andersson Jan 31 '18 at 15:13
  • Thanks! It worked! But may you explain me this sintax? Why it doesn't work without the ".". Another doubt, is it normal that the test be really slow with xpath? This code takes 14 sec to click on the "Yes" button – Yuri Costa de Oliveira Feb 01 '18 at 12:03
  • `.` Points on context - in your case `.//Pane` is a descendant of already found `//Pane` while `//Pane` - is just first `Pane` in DOM. You can try to use single XPath `//Pane[@AutomationId='Tixotrópica']//Pane[@AutomationId='picBoxSim']` for little acceleration – Andersson Feb 01 '18 at 12:08
  • Got it! Thanks for explaining this to me. I've used the single XPath but it still taking too long to click. Is it a normal issue using XPath? – Yuri Costa de Oliveira Feb 01 '18 at 12:24
  • It depends on the size of document which should be parsed or on tool that you uses – Andersson Feb 01 '18 at 12:38

0 Answers0