DivTag Calendar Interaction

Class library usage, coding and language questions.
mcs
Posts: 35
Joined: Mon Aug 11, 2014 5:00 pm
Location: Portsmouth, NH

DivTag Calendar Interaction

Post by mcs » Wed Jun 01, 2016 2:45 pm

Hi,
I am attempting to automate user interaction with a jquery calendar which happens to be a divTag.
There are two parts that I am successfully getting now from each day in the calendar which are the InnerText (day) and the Title (description).

I am encountering some minor obstacles (which are surely related to my coding knowledge) that I'm hoping I can get some help with.

Here is my function:
public void iterateOverAllCalRows()
		{
			var allTableRowsInfo = repo.CharterAPrivatePlaneWithCobaltAir.Calendar.SelfInfo;
			
			var allRowsList = allTableRowsInfo.CreateAdapters<DivTag>();

			int i = 1;
			
			//Loop through each row
			foreach(DivTag row in allRowsList)
			{

				//Initialize rowInfo
				string rowInfo = "";
				
				
				// Get all cells from row
				rowInfo += "Row " + i +":  ";
				i++;
				
				//Loop through each cell
				foreach (DivTag cell in row.Find(".//div[@tagname='div']"))
				{
					
					//Add the data (text) of cell to rowinfo
					rowInfo += cell.InnerText + ", " + cell.Title + "; ";

					Report.Info(cell.InnerText + ", " + cell.Title + "; ");
					
					// Move to next cell element
					cell.MoveTo();
					
				}
				
			}
My output begins like the following since there's a Month and Year at the top of the calendar and day abbreviations at the top of each column; I would like to be able to skip these and get right to the "meat" of the calendar but treating this calendar as a table (in order to skip rows) has gotten me nowhere since everything is reported as being in Row 1 if I just do a Report.Info(rowInfo):

00:10.283 Info User , ;
00:10.813 Info User , ;
00:11.188 Info User , ;
00:11.563 Info User , ;
00:11.984 Info User S, ;
00:12.358 Info User M, ;
00:12.811 Info User T, ;
00:13.201 Info User W, ;
00:13.591 Info User T, ;
00:13.966 Info User F, ;
00:14.340 Info User S, ;

The report also ends with

00:31.349 Info User , ;

The calendar divTag displays days from the previous month's last few days if the calendar month doesn't start on a Sunday. Is there an easy way to select only the cells belonging to the particular month that I want to look at? I thought of a > and < statement but that might include the last days from the past month...

I would appreciate, as always, any help that anyone can provide... thanks!

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

Re: DivTag Calendar Interaction

Post by odklizec » Wed Jun 01, 2016 2:56 pm

Hi,

Could you please upload a Ranorex snapshot (not screenshot) of the calendar in question? You see, it's pretty hard to suggest something reliable without seeing the problematic element or at least its snapshot.
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

mcs
Posts: 35
Joined: Mon Aug 11, 2014 5:00 pm
Location: Portsmouth, NH

Re: DivTag Calendar Interaction

Post by mcs » Wed Jun 01, 2016 4:44 pm

Hi Pavel,

I would love to post a snapshot but, whenever I attempt to create one (even with making my divTag calendar the root element), I see over 500 items being saved including company-sensitive information.
Is there a way to omit the sensitive items of which I'm not aware?

Thanks,
Mike

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

Re: DivTag Calendar Interaction

Post by odklizec » Wed Jun 01, 2016 5:20 pm

Hi Mike,

I'm afraid, there is no way to (automatically) omit sensitive data from snapshot. Probably the only way is to edit the snapshot file (uncompressed one) in an editor amd remove all sensitive data manually. Eventually, you can try to uncheck "complete ancestor tree" option in general settings (as described here). This should help with reducing amount of saved data.
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

mcs
Posts: 35
Joined: Mon Aug 11, 2014 5:00 pm
Location: Portsmouth, NH

Re: DivTag Calendar Interaction

Post by mcs » Wed Jun 01, 2016 10:13 pm

Hi Pavel,
Ah... I didn't know that the snapshot file could be unzipped and edited...

Hopefully, I've done it correctly and am posting it now.

I am on Ranorex version 6.0
The Calendar divTag is gldp-flatwhite

Please let me know if you need further information.
Thanks again,
Mike
You do not have the required permissions to view the files attached to this post.

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

Re: DivTag Calendar Interaction

Post by odklizec » Thu Jun 02, 2016 7:52 am

Hi Mike,

Unfortunately, there seems to be no screenshots in your snapshot, so it's somewhat uncomfortable to work with such snapshot. Anyway, I think I've figure it out ;)

The problem of your calendar is that it's quite automation unfriendly. There seems to be no unique IDs, or table/rows to work with. It's just a bunch of DIV. So it's somewhat hard to loop through rows in calendar without rows ;)

Luckily, each calendar day contains InnerText attribute, with calendar day number. So if you just want to loop though calendar days, all you have to do is to create an xpath with regex returning all div containing a number (InnerText) in range 1-31. For example something like this:

Code: Select all

/dom[@domain='10.1.0.50:90']//div[#'AddLeg_DatePicker']/div[@innertext~'^([1-9]|[12]\d|3[0-1])$']
So you just have to create a new repo item, with above xpath. Then use that repoitem (as RepoItemInfo type) in code to cycle through calendar days. I would suggest something like this:
public void GetListOfDivs(Ranorex.Core.Repository.RepoItemInfo repoItemInfo)
		{
			// Create a list of div adapters using the "Info" object
			IList<Ranorex.DivTag> divList =
				repoItemInfo.CreateAdapters<Ranorex.DivTag>();
			
			string divCount = divList.Count.ToString();
			Report.Log(ReportLevel.Info,"div count", "Div count: " + divCount);
			string divText = "";
			// do whatever you want with each div
			foreach (Ranorex.DivTag div in divList)
			{
				divText = div.Element.GetAttributeValueText("InnerText");
				Report.Log(ReportLevel.Info,"div text ", "Div Text: " + divText);
				divText = "";
			}
		}
If you would like to go through calendar days of a particular month (and skip displayed days from previous/next month) you will have to modify the regex and/or do it inside the div loop. Hope this helps?
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

mcs
Posts: 35
Joined: Mon Aug 11, 2014 5:00 pm
Location: Portsmouth, NH

Re: DivTag Calendar Interaction

Post by mcs » Thu Jun 02, 2016 1:42 pm

Thanks, Pavel,

Yes, that helps quite a bit; sorry about the lack of screenshots in the snapshot... every one of them had our company information in the background. I should have added a separate calendar-specific screenshot. I will do so now, even though I think you've already given me enough information to run with.

Thanks again,
Mike
You do not have the required permissions to view the files attached to this post.