Hi i asked before how to get an Xpath just via click. Now i have another problem related to it.
Almost everything seem to work fine but i cant seem to find a way how to get cells of a DataGrid(individual cells). I always only get the data grid with [language=]Host.Local.Element.FindFromPoint(Ranorex.Mouse.Position, out yourPath); [/language] .
I tried to reiterate through all childrens and some other stuff but i can seem to find rows/cells or anything.
Your help would be realy appriciated.
KeySam
FindFromPoint Problem
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: FindFromPoint Problem
Hi,
are you able to get these rows/cells with Ranorex Spy?
If you get the items with Ranorex Spy maybe your path is wrong or you do something wrong in your code.
Which technologie is used for the DataGrid?
Regards,
Peter
Ranorex Support Team
are you able to get these rows/cells with Ranorex Spy?
If you get the items with Ranorex Spy maybe your path is wrong or you do something wrong in your code.
Which technologie is used for the DataGrid?
Regards,
Peter
Ranorex Support Team
Re: FindFromPoint Problem
Yes i am able to get the Cells and Rows with Ranorex Spy.
The data Grid is a .net dataGrid i dont know more details i am afraid.
To the Xpath, i get the xpath by getting the element where my mouse is over at the moment, but isntead of getting the cell i get the complete dataGrid. When i try to go deeper into the grid i onlz find 2 children and nothing else. Maybe i need to convert the element first to datagrid?
MfG KeySam
The data Grid is a .net dataGrid i dont know more details i am afraid.
To the Xpath, i get the xpath by getting the element where my mouse is over at the moment, but isntead of getting the cell i get the complete dataGrid. When i try to go deeper into the grid i onlz find 2 children and nothing else. Maybe i need to convert the element first to datagrid?
MfG KeySam
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: FindFromPoint Problem
Ranorex Spy uses the same method to get an element from a screen position. Consequently, if the FindFromPoint method works in Spy, but does not in your code, your seems to be something wrong or missing in your Ranorex code.
My guess is that MSAA elements are not working, most likely because you call Ranorex code from a thread that does not use an Single Threaded Apartment (STA) threading model. If that's true, there should be a message in your Ranorex log file (rxlog) stating that the current thread is not set to use STA. Please, make sure that your Main method has the STAThread attribute applied to it (see Ranorex samples or newly created Ranorex project) or, if you're creating a separate thread, that the ApartmentState property of the thread is correctly set to STA.
Regards,
Alex
Ranorex Support Team
My guess is that MSAA elements are not working, most likely because you call Ranorex code from a thread that does not use an Single Threaded Apartment (STA) threading model. If that's true, there should be a message in your Ranorex log file (rxlog) stating that the current thread is not set to use STA. Please, make sure that your Main method has the STAThread attribute applied to it (see Ranorex samples or newly created Ranorex project) or, if you're creating a separate thread, that the ApartmentState property of the thread is correctly set to STA.
Regards,
Alex
Ranorex Support Team
Re: FindFromPoint Problem
Thanks for the answer though i use a Single Thread Apartment. At least i know theres something else wrong i will look into it. If you guys have any other ideas tell me.
Heres the code i am using:
KeySam
Heres the code i am using:
Code: Select all
public static Ranorex.Core.RxPath GetXpath()
{
Ranorex.Core.RxPath myPath;
Host.Local.Element.FindFromPoint(Ranorex.Mouse.Position, out myPath);
MessageBox.Show(myPath.ToString());
return myPath;
}
Re: FindFromPoint Problem
I am still stuck, i cant find anything that helps. Maybe its because i use a Keyboard Hook to read up shortcuts(that will then call the method to track?) seems unlickely but maybe thats it? If hope you guys can help me.
KeySam
KeySam
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: FindFromPoint Problem
Other things that could be a problem:
Alex
Ranorex Support Team
- Security: the application you try to get the element from is started with administrative rights, but the process you're calling FindFromPoint from does not have these rights
- Threading: you call FindFromPoint from the same application that you want to get an element from, but use the main window thread (e.g. when invoked by an event handler of the Form/Control). If you try to automate/get information from the application the Ranorex code is running in, always use a separate thread to run the Ranorex code!
Alex
Ranorex Support Team
Re: FindFromPoint Problem
I started both applications with the same rights and its not the same process(not even application), but thanks.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: FindFromPoint Problem
Sorry, I don't have any ideas left I can just tell you that we use exactly that method internally in Ranorex Spy to retrieve an element from a screen location. I really don't know why that method should not be working in your application...
Did you check if the path you get from FindFromPoint is identical to the path you get when tracking the data grid with Ranorex Spy?
Regards,
Alex
Ranorex Support Team
Did you check if the path you get from FindFromPoint is identical to the path you get when tracking the data grid with Ranorex Spy?
Regards,
Alex
Ranorex Support Team
Re: FindFromPoint Problem
Do you reitterate through the element afterwards or does it just give you the right thing? And also yes the Data Grid is the same element(almost 100% the same path just some extra indexes).
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: FindFromPoint Problem
No, Ranorex Spy does not reiterate through any elements, it displays the element returned by FindFromPoint. So, if Ranorex Spy tracks the cells in the data grid immediately, the FindFromPoint method should be able to do that in your code, too.KeySam wrote:Do you reitterate through the element afterwards or does it just give you the right thing?
Regards,
Alex
Ranorex Support Team