Page 1 of 1

Clicks on top left page

Posted: Wed Feb 27, 2019 1:41 pm
by rsudhak
Hi All,

I am having a issue with automating my desktop app. Here I am trying to click on a cell . steps are to first double click on the cell[Text] and then single click on the same cell[Text]. The problem I am facing is , the double click works fine , but for the single click the cursor moves to the top left and clicks.

Tried, turning off the cache, and waiting between the two clicks but didn't work.

Please note that the text box trying to access is not in the repo, the code looks like below:

Code: Select all

 public static void editId(int iWay, string sPhase,string sId, int iSubId) {
			IList<Unknown> items = ProDesign.Panel.Box.Children; // please note unknow here actually belongs to the element class
			
			for(int i = 0; i< items.Count;i++) {
				Element item = items[i];
				Text cell2= item.FindSingle("//element[@automationid='Cell_"+i+"_2']/text");
				Text cell3= item.FindSingle("//element[@automationid='Cell_"+i+"_3']/text");
				Text cell4=item.FindSingle("//element[@automationid='Cell_"+i+"_4']/text");
				if(iWay.ToString().Equals(cell2.TextValue) && sPhase.Equals(cell3.TextValue)) {
					cell4.DoubleClick();
					Delay.Milliseconds(1000);
					cell4.Click();
					break;
				}
			}	
			
					PopupHelper.editIdAndSubId(sId, iSubId);
		}

Re: Clicks on top left page

Posted: Wed Feb 27, 2019 1:51 pm
by manish
Hi,

The mouse pointer moves to the top left when it is unable to find the correct properties of the element. It could happen that when you double click on the cell, some other property of the cell changes. In this case it is different to the element originally found by Ranorex. You would need to search the cell again with the new/changed property than originally defined.
Please post the snapshot of the cell so that it can help further analysis.

Thanks
Manish

Re: Clicks on top left page

Posted: Fri Mar 01, 2019 11:31 am
by rsudhak
OK, I have modified a bit: and this works....BUT

public static void editCircuitId(int iWay, string sPhase,string sId, int iSubId) {
IList<Unknown> items = ProDesign.CircuitDetailsPanel.Box_Circuits.Children;
Text circuitId = null;
for(int i = 0; i< items.Count;i++) {
Element item = items;
Text way = item.FindSingle("//element[@automationid='Cell_"+i+"_2']/text");
Text phase = item.FindSingle("//element[@automationid='Cell_"+i+"_3']/text");
//item.FindSingle("//element[@automationid='Cell_"+i+"_4']/text");
if(iWay.ToString().Equals(way.TextValue) && sPhase.Equals(phase.TextValue)) {
circuitId = item.FindSingle("//element[@automationid='Cell_"+i+"_4']/text");
circuitId.DoubleClick();
Delay.Milliseconds(1000);
circuitId = item.FindSingle("//element[@automationid='Cell_"+i+"_4']/text");
circuitId.Click();
PopupHelper.editIdAndSubId(sId, iSubId);
phase = item.FindSingle("//element[@automationid='Cell_"+i+"_3']/text");
phase.Click();
break;
}
}
}

Attached the pic of the table:

steps are :
right click on a particular way , that will split the phase into L1, L2, L3 , similar to what I did in the screenshot for way 1.

My task is to double click on one row , which will load some values in the row clicked and then single click on Circuit id cell to get the pop up and make changes to it. The problem with the code is it too slow and doesnt work for the rows which are below, requires some scroll .

Re: Clicks on top left page

Posted: Fri Mar 01, 2019 1:25 pm
by ahoisl
rsudhak wrote:
Fri Mar 01, 2019 11:31 am
The problem with the code is it too slow
This is probably caused by the fact that you use absolute paths to search for the element, combined with the "//" operator this will search the whole desktop.
Precede the path with a dot like this: ".//element[@automationid..."

Regards,
Alex
Ranorex Team

Re: Clicks on top left page

Posted: Fri Mar 01, 2019 1:55 pm
by rsudhak
I get an error when tried giving a .dot
No element found for path './///element[@automationid='Cell_7_2']/text'
No element found for path './/element[@automationid='Cell_7_2']/text'

Re: Clicks on top left page

Posted: Fri Mar 01, 2019 1:58 pm
by rsudhak
This is another method which I am working on public static void clickSplitWay(int iWay) {
IList<Unknown> items = ProDesign.CircuitDetailsPanel.Box_Circuits.Children;
for(int i = 7; i< items.Count;i++) {
Element item = items;
Text itemText = item.FindSingle("//element[@automationid='Cell_"+i+"_2']/text");
if(iWay.ToString().Equals(itemText.TextValue)) {
while(!itemText.HasFocus){
ProDesign.ComponentEditorDialog.Scroll_CircuitDown.Click();
if(itemText.EnsureVisible()) {
itemText.Click (MouseButtons.Right);
ProDesign.CircuitDetailsContextMenu.SplitWay.Click();
}
}
break;
}
}

Get error wwhen added a . dot No element found for path './///element[@automationid='Cell_7_2']/text'
No element found for path './/element[@automationid='Cell_7_2']/text'

Re: Clicks on top left page

Posted: Fri Mar 01, 2019 2:06 pm
by ahoisl
If you get an error with a relative path, but not with the absolute, then the item you search for is apparently not a descendant of the item you search from.
Try to use Ranorex Spy to get the correct parent item to search from and the relative path to the descendant item.

Regards,
Alex
Ranorex Team

Re: Clicks on top left page

Posted: Fri Mar 01, 2019 3:28 pm
by rsudhak
I dont see Descendant option at all to use them, isint it redundant

Re: Clicks on top left page

Posted: Mon Mar 04, 2019 11:49 am
by RobinHood42
Hi,

It would be great if you could upload a Ranorex snapshot file of the mentioned elements: http://www.ranorex.com/support/how-to-c ... pshot.html

Cheers,
Robin