Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I get ListboxItem Children #854

Closed
fenchu opened this issue Sep 6, 2019 · 4 comments
Closed

How can I get ListboxItem Children #854

fenchu opened this issue Sep 6, 2019 · 4 comments

Comments

@fenchu
Copy link

fenchu commented Sep 6, 2019

What is winappdrivers equivalent to get_attribute('innerHTML')?,
I do not seem to get anything from indicating there are children or something inside the boxes.

I like to find all text items for each listboxitem, because there can be lots of them and anyone the have a text item in the 4th row indicated an error

winappdriver-error

def test03_listboxitems(self):
        els = self.driver.find_elements_by_class_name("ListBoxItem")
        for el in els:
            print(f"element:{el.__dict__}")
            print(f"name:{el.text}")

I do not see anything related to the children:

PS> python .\LRAClient-start.py T.test03_listboxitems
element:{'_parent': <appium.webdriver.webdriver.WebDriver (session="40E4C74E-8125-485A-99E6-50B26A170C40")>, '_id': '7.3200.28263486', '_w3c': False}
name:Model.Main.Startup.StartUpCheckStepViewModel
element:{'_parent': <appium.webdriver.webdriver.WebDriver (session="40E4C74E-8125-485A-99E6-50B26A170C40")>, '_id': '7.3200.3649016', '_w3c': False}
name:Model.Main.Startup.StartUpCheckStepViewModel
element:{'_parent': <appium.webdriver.webdriver.WebDriver (session="40E4C74E-8125-485A-99E6-50B26A170C40")>, '_id': '7.3200.27134857', '_w3c': False}
name:Model.Main.Startup.StartUpCheckStepViewModel
element:{'_parent': <appium.webdriver.webdriver.WebDriver (session="40E4C74E-8125-485A-99E6-50B26A170C40")>, '_id': '7.3200.50439840', '_w3c': False}
name:Model.Main.Startup.StartUpCheckStepViewModel
element:{'_parent': <appium.webdriver.webdriver.WebDriver (session="40E4C74E-8125-485A-99E6-50B26A170C40")>, '_id': '7.3200.59095202', '_w3c': False}
name:Model.Main.Startup.StartUpCheckStepViewModel
element:{'_parent': <appium.webdriver.webdriver.WebDriver (session="40E4C74E-8125-485A-99E6-50B26A170C40")>, '_id': '7.3200.21982073', '_w3c': False}
name:Model.Main.Startup.StartUpCheckStepViewModel
element:{'_parent': <appium.webdriver.webdriver.WebDriver (session="40E4C74E-8125-485A-99E6-50B26A170C40")>, '_id': '7.3200.35717517', '_w3c': False}
name:Model.Main.Startup.StartUpCheckStepViewModel
element:{'_parent': <appium.webdriver.webdriver.WebDriver (session="40E4C74E-8125-485A-99E6-50B26A170C40")>, '_id': '7.3200.7437765', '_w3c': False}
name:Model.Main.Startup.StartUpCheckStepViewModel
.
----------------------------------------------------------------------
Ran 1 test in 5.097s

OK
@hicks86
Copy link

hicks86 commented Sep 9, 2019

So just to confirm you would like to loop through the children of a specific control?

I am working with C# and .NET version of Appium library, but I assume something similar would also work for you in Python:

var listElement = driver.FindElementByClassName("ListView") 

var children = listElement.FindElementsByXPath("//ListItem")

foreach(var child in children)
{
    Console.WriteLine(child.Text);
}

Hope this helps, any queries please ask.

@fenchu
Copy link
Author

fenchu commented Sep 10, 2019

Thanks for the reply, using xpath produces the exact same result. (The child.text is Model.Main.Startup.StartUpCheckStepViewModel) I can find the text if I do a

el = self.driver.find_element_by_name("<exact error text to search>")

But this requires explicit knowledge of all errors and what screens they appear on.

I see I can get self.driver.page_source xml and see the list there. In each listitem there are 4 elements, it is the 4th element I'm interested in, but no text is being captrured, maybe it is there later on in the process. I'll check further:

            <List AcceleratorKey="" AccessKey="" AutomationId="lb1" ClassName="ListBox" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="list view" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.62792710" x="52" y="185" width="570" height="285" Selection="" HorizontallyScrollable="False" VerticallyScrollable="False" HorizontalScrollPercent="-1" VerticalScrollPercent="-1" HorizontalViewSize="100" VerticalViewSize="100" IsAvailable="True">
                <ListItem AcceleratorKey="" AccessKey="" AutomationId="" ClassName="ListBoxItem" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="list item" Name="Model.Main.Startup.StartUpCheckStepViewModel" Orientation="None" ProcessId="19432" RuntimeId="7.19432.1660480" x="53" y="186" width="568" height="35" IsSelected="False" SelectionContainer="{, ListBox, 7.19432.62792710}" IsAvailable="True">
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="Operator card reader" Orientation="None" ProcessId="19432" RuntimeId="7.19432.42887128" x="58" y="188" width="190" height="31" />
                    <Image AcceleratorKey="" AccessKey="" AutomationId="" ClassName="Image" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="image" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.50439840" x="248" y="199" width="10" height="10" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.51305376" x="287" y="188" width="300" height="31" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.59095202" x="287" y="188" width="300" height="31" />
                </ListItem>
                <ListItem AcceleratorKey="" AccessKey="" AutomationId="" ClassName="ListBoxItem" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="list item" Name="Model.Main.Startup.StartUpCheckStepViewModel" Orientation="None" ProcessId="19432" RuntimeId="7.19432.14944322" x="53" y="221" width="568" height="36" IsSelected="False" SelectionContainer="{, ListBox, 7.19432.62792710}" IsAvailable="True">
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="Usercard reader" Orientation="None" ProcessId="19432" RuntimeId="7.19432.62094776" x="58" y="223" width="190" height="32" />
                    <Image AcceleratorKey="" AccessKey="" AutomationId="" ClassName="Image" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="image" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.21982073" x="248" y="234" width="10" height="10" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.63620936" x="287" y="223" width="300" height="32" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.35717517" x="287" y="223" width="300" height="32" />
                </ListItem>
                <ListItem AcceleratorKey="" AccessKey="" AutomationId="" ClassName="ListBoxItem" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="list item" Name="Model.Main.Startup.StartUpCheckStepViewModel" Orientation="None" ProcessId="19432" RuntimeId="7.19432.281173" x="53" y="257" width="568" height="35" IsSelected="False" SelectionContainer="{, ListBox, 7.19432.62792710}" IsAvailable="True">
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="Scanner" Orientation="None" ProcessId="19432" RuntimeId="7.19432.53022201" x="58" y="259" width="190" height="31" />
                    <Image AcceleratorKey="" AccessKey="" AutomationId="" ClassName="Image" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="image" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.7437765" x="248" y="269" width="10" height="10" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.66939890" x="287" y="259" width="300" height="31" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.65588106" x="287" y="259" width="300" height="31" />
                </ListItem>
                <ListItem AcceleratorKey="" AccessKey="" AutomationId="" ClassName="ListBoxItem" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="list item" Name="Model.Main.Startup.StartUpCheckStepViewModel" Orientation="None" ProcessId="19432" RuntimeId="7.19432.2530563" x="53" y="292" width="568" height="35" IsSelected="False" SelectionContainer="{, ListBox, 7.19432.62792710}" IsAvailable="True">
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="SignPad" Orientation="None" ProcessId="19432" RuntimeId="7.19432.53422044" x="58" y="294" width="190" height="31" />
                    <Image AcceleratorKey="" AccessKey="" AutomationId="" ClassName="Image" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="image" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.11036355" x="248" y="305" width="10" height="10" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.32218335" x="287" y="294" width="300" height="31" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.21529561" x="287" y="294" width="300" height="31" />
                </ListItem>
                <ListItem AcceleratorKey="" AccessKey="" AutomationId="" ClassName="ListBoxItem" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="list item" Name="Model.Main.Startup.StartUpCheckStepViewModel" Orientation="None" ProcessId="19432" RuntimeId="7.19432.22775067" x="53" y="327" width="568" height="36" IsSelected="False" SelectionContainer="{, ListBox, 7.19432.62792710}" IsAvailable="True">
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="Document registry" Orientation="None" ProcessId="19432" RuntimeId="7.19432.59548322" x="58" y="329" width="190" height="32" />
                    <Image AcceleratorKey="" AccessKey="" AutomationId="" ClassName="Image" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="image" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.66172851" x="248" y="340" width="10" height="10" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.58684749" x="287" y="329" width="300" height="32" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.58400697" x="287" y="329" width="300" height="32" />
                </ListItem>
                <ListItem AcceleratorKey="" AccessKey="" AutomationId="" ClassName="ListBoxItem" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="list item" Name="Model.Main.Startup.StartUpCheckStepViewModel" Orientation="None" ProcessId="19432" RuntimeId="7.19432.3649016" x="53" y="363" width="568" height="35" IsSelected="False" SelectionContainer="{, ListBox, 7.19432.62792710}" IsAvailable="True">
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="Report registry" Orientation="None" ProcessId="19432" RuntimeId="7.19432.55844233" x="58" y="365" width="190" height="31" />
                    <Image AcceleratorKey="" AccessKey="" AutomationId="" ClassName="Image" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="image" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.32836053" x="248" y="376" width="10" height="10" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.27089021" x="287" y="365" width="300" height="31" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.42474604" x="287" y="365" width="300" height="31" />
                </ListItem>
                <ListItem AcceleratorKey="" AccessKey="" AutomationId="" ClassName="ListBoxItem" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="list item" Name="Model.Main.Startup.StartUpCheckStepViewModel" Orientation="None" ProcessId="19432" RuntimeId="7.19432.32841145" x="53" y="398" width="568" height="36" IsSelected="False" SelectionContainer="{, ListBox, 7.19432.62792710}" IsAvailable="True">
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="Buypass" Orientation="None" ProcessId="19432" RuntimeId="7.19432.46727122" x="58" y="400" width="190" height="32" />
                    <Image AcceleratorKey="" AccessKey="" AutomationId="" ClassName="Image" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="image" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.17890920" x="248" y="411" width="10" height="10" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.26800560" x="287" y="400" width="300" height="32" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.39878449" x="287" y="400" width="300" height="32" />
                </ListItem>
                <ListItem AcceleratorKey="" AccessKey="" AutomationId="" ClassName="ListBoxItem" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="list item" Name="Model.Main.Startup.StartUpCheckStepViewModel" Orientation="None" ProcessId="19432" RuntimeId="7.19432.27134857" x="53" y="434" width="568" height="35" IsSelected="False" SelectionContainer="{, ListBox, 7.19432.62792710}" IsAvailable="True">
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="Operator credentials" Orientation="None" ProcessId="19432" RuntimeId="7.19432.23361726" x="58" y="436" width="190" height="31" />
                    <Image AcceleratorKey="" AccessKey="" AutomationId="" ClassName="Image" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="image" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.8928942" x="248" y="446" width="10" height="10" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.13251620" x="287" y="436" width="300" height="31" />
                    <Text AcceleratorKey="" AccessKey="" AutomationId="" ClassName="TextBlock" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="False" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="text" Name="" Orientation="None" ProcessId="19432" RuntimeId="7.19432.52155720" x="287" y="436" width="300" height="31" />
                </ListItem>
            </List>

@hicks86
Copy link

hicks86 commented Sep 10, 2019

Ok just a quick spot in the code that you have printed try (elements with an s):

el = self.driver.find_elements_by_name("<exact error text to search>")

Although if that is the PageSource dump that you have attached your right, the above code will not make a difference as the Text property (Name property in the PageSource) is blank. Just some thoughts on this:

  • Could you be capturing this before the control list items are fully loaded? Try and put a delay between the load of these and when you try to run find_elements_by_name().
  • Do you know if this is a custom control with custom list items?
  • Are you using WinAppDriver via the Appium Server or are you using WinAppDriver directly?

@fenchu
Copy link
Author

fenchu commented Sep 10, 2019

@hicks86 Thanks, I realized that the button 'Try again' that appears at the end if there are errors and I test for, was in the xml, but it was not clickable before it appears . so waiting for it to become clickable fixed it. (I cant click it because the it just reread config). I use the winappdriver directly with the appium-python-client:

    def test03_listboxitems(self):
        t0 = time.time()
        el = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.NAME, "Try again")))
        print(f"button found: {time.time()-t0:.2f}sec")
        #print(f"page source:\n{self.driver.page_source}")

        items = self.driver.find_elements_by_xpath("//ListItem/Text[2][@Name!='']")
        for el in items:
            print(f"el: {el.text}") 
python.exe .\LRAClient-start.py T.test03_listboxitems
button found: 5.27sec
el: Scanner not found
el: Operator card required
.
----------------------------------------------------------------------
Ran 1 test in 10.503s

Thanks,

@fenchu fenchu closed this as completed Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants