Find only element of default tab

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Stas_Tserk
Posts: 19
Joined: Tue Jan 27, 2015 4:09 pm

Find only element of default tab

Post by Stas_Tserk » Tue Jan 27, 2015 4:18 pm

Hello!
I use version 5.2.2.21596.
I have an issue. I have WPF controls on 3 tabs.
Tab which default selected at start application has no problems with inspect the object.
However, other tabs with controls can't be identify.
I tried to change default checked tab and it works -> i can inspect all controls in this tab, but can't in others.
I try to add automationId, but it didn't help.

Any idea how to help me? I want to use your tool for my current project.


Update: add snapshot.
Attachments
IssueWithTabs.rxsnp
(77.8 KiB) Downloaded 76 times

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Find only element of default tab

Post by krstcs » Tue Jan 27, 2015 5:06 pm

First, please provide more information. You didn't give us the XPath to the element(s) in question, that would be helpful.

Second, for most tab-pages you need to click the tab before Ranorex will be able to identify and take action against elements on the corresponding tab-page. Try adding a Click action on the desired tab before trying to find or take actions on the elements.
Shortcuts usually aren't...

Stas_Tserk
Posts: 19
Joined: Tue Jan 27, 2015 4:09 pm

Re: Find only element of default tab

Post by Stas_Tserk » Tue Jan 27, 2015 5:33 pm

Select tab:

Code: Select all

TabPage tabInsert = form.FindSingle<Ranorex.TabPage>(".//tabpage[@automationid='InsertId']");
tabInsert.Click();
Click button

Code: Select all

Button LoopBtn = form.FindSingle<Ranorex.Button>(".//button[@automationid='ValueId']");
                LoopBtn.Click();
Its for example. All tabPages have automationId. Sure, i click on it before i want to click element.
When the for is default i don't have any problems with click element.

When i try to track non default tab Ranorex spy highlights all of the parent element, not the current tab.

If you need i can provide more info. Any questions. Thank you for your help!

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Find only element of default tab

Post by krstcs » Tue Jan 27, 2015 5:48 pm

I'm not sure I understand the issue.

Are you getting an error when you attempt to click on the element after clicking the tab?

As I said, Ranorex generally has problems identifying child elements of tab-pages that aren't visible because Windows does not draw them until the tab is clicked.

Try this in your test:
Click the tab.
Validate that the element in question is visible.
Then try to click the element in question.
Shortcuts usually aren't...

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Find only element of default tab

Post by Ciege » Tue Jan 27, 2015 5:56 pm

It *could* also be that the element with the same AutomationID lives on multiple tabs (the XPath is different because of where it lives, but the element AutomationID is identical). Therefore when the AUT is first started and the first Tab is displayed the element exists on that tab. When the new tab is opened, the element for that tab exists (but the original element on the initial tab still exists, and is marked as not visible). If this is the case, then running a FindSingle from the root form is finding the original element and not the element that was drawn second on the second tab.

If this is the issue, you can solve by either rooting your FindSingle at the Tab level or add a visible check to your FindSingle so that it only finds the element that is visible at this moment in time.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

Stas_Tserk
Posts: 19
Joined: Tue Jan 27, 2015 4:09 pm

Re: Find only element of default tab

Post by Stas_Tserk » Wed Jan 28, 2015 9:48 am

Thank you for your posts!

Ciege, I try to find same automationId, but didn't find. I think i don't have same ids.
I'm not sure I understand the issue.
There are screenshots in attach. I hope it helps you to understand.
1_homeTab. It isn't select by default. Spy can't get access to any element here. (cursor is on the "B" ).
2_insertTab. It is select by default. Spy can get any element.

If i switch default tab to "home" (in source), i can get any element in this tab, but can't in "Insert" tab.

When i try to click to button on not default tab, ranorex can't find element on this tab. Sure, i switch to this tab before i am trying to click.
Click the tab.
Validate that the element in question is visible.

Code: Select all

TabPage tabInsert = form.FindSingle<Ranorex.TabPage>(".//tabpage[@automationid='InsertId']");
                tabInsert.Select();
Button LoopBtn = form.FindSingle<Ranorex.Button>(".//button[@automationid='ValueId']");
                Console.WriteLine(LoopBtn.Visible);
                LoopBtn.Click();
Visible = false.
Error after click on button.

And if this tab will default, this code will work, visible = try.
Attachments
1_hometab.png
1_hometab.png (56.45 KiB) Viewed 1749 times
2_insertTab.png
2_insertTab.png (58.1 KiB) Viewed 1749 times

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Find only element of default tab

Post by Ciege » Wed Jan 28, 2015 4:23 pm

So you are showing us a screenshot of Word. Is the XSL function group your own Add In?
Can you please make a RanorexSpy snapshot of the AUT with the Home tab selected, then one with the Insert tab selected? (Since you don't show in your screenshots which button has the AutomationID of ValueId.
Can you post the EXACT error message you receive when Ranorex cannot find the button?
Try changing the following code from a .Select to a .Click:

Code: Select all

tabInsert.Select();
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

Stas_Tserk
Posts: 19
Joined: Tue Jan 27, 2015 4:09 pm

Re: Find only element of default tab

Post by Stas_Tserk » Thu Jan 29, 2015 10:55 am

So you are showing us a screenshot of Word
This application isn't Word. It only looks like Word. And i don't have this problem when i try to identify objects in Word.

I add 2 snapshots.
Element 'Visual Designer' -> Container 'Editor' -> TabPageList 'RadRichTextBoxRibbonUIID'
Here tabPages 'HomeId', 'InsertId' and some others.
AutomationID of ValueId
Button Value has automationId = "ValueId".
All my buttons have similar names.
Try changing the following code from a .Select to a .Click:
I did, it doesn't help :(
Can you post the EXACT error message you receive when Ranorex cannot find the button?
Sure.
Ranorex.ElementNotFoundException: No element found for path './/button[@automationid='ValueId']'.
at Ranorex.Core.Element.FindSingle(RxPath path)
at Ranorex.Adapter.FindSingle[T](RxPath path)
at Try1.InsertValue.SecondTest() in <path>\insertValue.cs:line 41


PS helpdesk of Ranorex wrote me. They said that they try to fix this issue.
"The release of this new Ranorex Version will be in the next week"
I hope they can fix it!
Attachments
insert_defaultSelected.rxsnp
(76.59 KiB) Downloaded 72 times
home_defaultSelected.rxsnp
(89.4 KiB) Downloaded 66 times

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Find only element of default tab

Post by Ciege » Mon Feb 02, 2015 6:55 pm

PS helpdesk of Ranorex wrote me. They said that they try to fix this issue.
"The release of this new Ranorex Version will be in the next week"
I hope they can fix it!
They are pretty good about these things, so I too hope they get it for you...

Regardless, I had a look at your snapshot with the Insert tab selected, and sure enough I can find the .//button[@automationid='ValueId'] element in RanorexSpy (which means Ranorex should be able to find it as well). Some things to check / try before Ranorex help desk gets back to you:
*) Add a delay after selecting the Insert Tab, just in case it takes some time for the tab to load or positively verify the tab has loaded before you begin your find
*) Root your search from 'tabInsert' instead of 'form' since you already have that element and so that Ranorex has less of a tree to look through

Code: Select all

Button LoopBtn = tabInsert.FindSingle<Ranorex.Button>(".//button[@automationid='ValueId']");
*) Although the error message does not state a timeout time, check that your timeout is set high enough so that Ranorex has enough time to search for the button (should be better on time if you root your search further down the tree as suggested above)
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

Stas_Tserk
Posts: 19
Joined: Tue Jan 27, 2015 4:09 pm

Re: Find only element of default tab

Post by Stas_Tserk » Tue Feb 03, 2015 9:17 am

Hello!
Thank you for your reply!
I had a look at your snapshot with the Insert tab selected, and sure enough I can find the .//button[@automationid='ValueId'] element in RanorexSpy
I think you found it in " insert_defaultSelected.rxsnp"
I wrote about it: in this snapshot you can find any elements in insert tab, but can't find any in other tabs.
Default selected tab is "Home". In this snapshot i can't find elements in insert tab.

I tried to do timers before Ranorex start search element but it doesn't help.
After i have error application doesn't close. In this time i try to use ranorex spy, but it can't find element.

I hope Ranorex 5.3 is coming soon.

Stas_Tserk
Posts: 19
Joined: Tue Jan 27, 2015 4:09 pm

Re: Find only element of default tab

Post by Stas_Tserk » Fri Feb 27, 2015 9:26 am

hello there
Ranorex 5.3 fix my problem.
Thank you all!