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

White unable to extract DataItems (ListViewRow) #241

Open
ashokkn opened this issue May 29, 2014 · 12 comments
Open

White unable to extract DataItems (ListViewRow) #241

ashokkn opened this issue May 29, 2014 · 12 comments

Comments

@ashokkn
Copy link

ashokkn commented May 29, 2014

Hello

I have got a Panel in my application which contains lots of DataItem (ListViewRow) elements. Through white I am unable to extract the DataItem and perform any operation.

Screen shot 1: Shows the element DataItem through the Inspect utility, but I am unable to extract these elements through White

image

Screenshot 2 : Shows the error message when i try to extract the dataItem
The error message sounds to be more an issue with White itself rather I am doing anything wrong here. Kindly assist.

image

@ashokkn
Copy link
Author

ashokkn commented May 29, 2014

Some additional information: Through the below code, I was able to extract the DataItem elements from the target window in the app

PropertyCondition diCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.DataItem);
AutomationElementCollection dataItems = tlWindow.FindAll(TreeScope.Descendants, diCondition);

@ilya-murzinov
Copy link
Contributor

I confirm it.
This is a bug, I'll try to fix it.

@ashokkn
Copy link
Author

ashokkn commented May 29, 2014

Wonderful and it would be very helpful. Thanks bro..!!

@ilya-murzinov
Copy link
Contributor

Ok, the problem is that there is no proper constructor in ListViewRow. The only one takes additional argument so the instance of this class can't be created by DictionaryMappedFactory.

        public ListViewRow(AutomationElement automationElement,
                                       ActionListener actionListener,
                                       ListViewHeader header)
            : base(automationElement, actionListener)
        {
            this.header = header;
            finder = new AutomationElementFinder(automationElement);
        }

For a quick fix, I can add new constructor with 2 parameters and just assign this.header = null:

        public ListViewRow(AutomationElement automationElement,
                                       ActionListener actionListener)
            : base(automationElement, actionListener)
        {
            header = null;
            finder = new AutomationElementFinder(automationElement);
        }

@ashokkn, @JakeGinnivan would it be sufficient or we need to have the header of any ListViewRow?

@JakeGinnivan
Copy link
Member

Can the ListViewHeader be looked up? How does it get passed through currently.

I am not going to have a chance to look into this for a few days, and don't know the answer to your question at the moment @ilya-murzinov. Sorry

@ilya-murzinov
Copy link
Contributor

@JakeGinnivan,
Actually, looking up ListViewHeader is quite complicated issue. Currently it gets passed when the ListViewRow is created via ListViewFactory when looking up for all rows in ListView.
I believe, it's ok that we can create an instance of ListViewRow without ListViewHeader.

I'll send a PR later tonight.

@ashokkn
Copy link
Author

ashokkn commented Jun 12, 2014

Previously the below line of code used to throw a constructor error which was originally fixed by Ilya.
In release 13.0, this error is gone but the code does not find DataItems even though there ListViewRow elements available in that window.

TestStack.White.UIItems.ListViewRow dtItems = transactionListWindow.Get<TestStack.White.UIItems.ListViewRow>(SearchCriteria.ByControlType(ControlType.DataItem));

@ashokkn
Copy link
Author

ashokkn commented Jun 17, 2014

any luck on this issue ?

@ilya-murzinov
Copy link
Contributor

Sorry, I won't have any time to look into this for a next week or so.

@JakeGinnivan
Copy link
Member

Same, I have other things on my plate. If you can submit a pull request I will happily merge and do a release for you though.

Cheers,
Jake

@ilya-murzinov
Copy link
Contributor

@ashokkn, ok, I'm looking into this issue.

@ilya-murzinov
Copy link
Contributor

@ashokkn, your code snippet

TestStack.White.UIItems.ListViewRow dtItems = 
transactionListWindow.Get(SearchCriteria.ByControlType(ControlType.DataItem));

not working.

Cannot implicitly convert type 'TestStack.White.UIItems.IUIItem' to
'TestStack.White.UIItems.ListViewRow'. An explicit conversion exists
(are you missing a cast?)

Also, I don't see any problem when trying to get DataItems in our WpfTestApplication with similar snippet

IUIItem c = Desktop.Instance.Windows().Find(x => x.Title.Equals("MainWindow"))
                .Get(SearchCriteria.ByControlType(ControlType.DataItem));

Can you please tell if there is any difference between you application and our WpfTestApplication?
WpfTestApplcation located here: https://github.com/TestStack/White/tree/master/src/TestApplications/WpfTestApplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants