I need to be able to count number of Tab items.

Ask general questions here.
subrata1
Posts: 6
Joined: Sat Jun 02, 2018 3:12 am

I need to be able to count number of Tab items.

Post by subrata1 » Tue Jun 05, 2018 4:33 pm

Hi All,

I have number of Tabs on a JavaWindow.
I Need to get the total count of tab.
Go thru all the tabs and perform Click on a specific Tab.

Thanks
Subrata

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: I need to be able to count number of Tab items.

Post by odklizec » Tue Jun 05, 2018 4:46 pm

Hi,

Please post a Ranorex snapshot (NOT screenshot) of the tab container. Without, at very least, Ranorex snapshot, it’s impossible to provide a reasonable solution. The best I, or anyone else here, can do is to suggest a general code for creating list of adapters from repo element and click individual elements...
https://www.ranorex.com/help/latest/cod ... oryElement
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

subrata1
Posts: 6
Joined: Sat Jun 02, 2018 3:12 am

Re: I need to be able to count number of Tab items.

Post by subrata1 » Tue Jun 05, 2018 5:42 pm

I have attached the snapshot.
Thank u ....

subrata1
Posts: 6
Joined: Sat Jun 02, 2018 3:12 am

Re: I need to be able to count number of Tab items.

Post by subrata1 » Tue Jun 05, 2018 5:58 pm

I am unable to attach the snapshot as it is over 1 mb. I have attached the screen shot instead.
Thanks
Attachments
WindowTab.png
WindowTab.png (32.89 KiB) Viewed 175 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: I need to be able to count number of Tab items.

Post by odklizec » Tue Jun 05, 2018 6:17 pm

Hi,

You can always share it via OneDrive, DropBox or similar file sharing service and here post a link.

Basically, you must add an element to repository, which xpath will return all TabPage elements. The xpath should look like this...

Code: Select all

form[@title='GAR1']/container[@name='m_introPanel']//TabPage
Then you must pass the repo element to the code I posted in previous post. Of course, you need to adapt the code to TabPage elements (instead of buttons).
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mto
Posts: 25
Joined: Tue Jan 06, 2015 10:31 am

Re: I need to be able to count number of Tab items.

Post by mto » Wed Jun 06, 2018 3:53 pm

Hi Subrata,

I am using this to count the number of tabs in a browser (i think it is the same).
public static int GetTabCount()
{
     return (int)<yourrepoelement>.Element.GetAttributeValue("count");
}
MTO

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: I need to be able to count number of Tab items.

Post by odklizec » Thu Jun 07, 2018 11:57 am

Hi,

I would use something like this:

Code: Select all

		public void UserCodeMethod(RepoItemInfo repoElementInfo)
		{
			IList<Ranorex.TabPage> tabList = argument1.CreateAdapters<Ranorex.TabPage>();
			//tab count
			int tabCount = tabList.Count;
			//move to each tab, take a screenshot and then click tab
			foreach (Ranorex.TabPage tab in tabList)
			{
				tab.MoveTo();
				Report.Screenshot(tab);
				tab.Click();
			}
		}
Where "repoElementInfo" element, should point to repo element with xpath...

Code: Select all

form[@title='GAR1']/container[@name='m_introPanel']//TabPage
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration