Clicks on top left page

Ask general questions here.
rsudhak
Posts: 32
Joined: Fri Jan 04, 2019 1:38 pm

Clicks on top left page

Post by rsudhak » Wed Feb 27, 2019 1:41 pm

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);
		}

manish
Posts: 21
Joined: Fri Aug 10, 2018 12:46 pm

Re: Clicks on top left page

Post by manish » Wed Feb 27, 2019 1:51 pm

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

rsudhak
Posts: 32
Joined: Fri Jan 04, 2019 1:38 pm

Re: Clicks on top left page

Post by rsudhak » Fri Mar 01, 2019 11:31 am

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 .
Attachments
tablesnap.rxsnp
(174.42 KiB) Not downloaded yet
table.png
table.png (15.38 KiB) Viewed 70 times

ahoisl
Certified Professional
Certified Professional
Posts: 167
Joined: Fri Sep 07, 2007 8:16 am

Re: Clicks on top left page

Post by ahoisl » Fri Mar 01, 2019 1:25 pm

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

rsudhak
Posts: 32
Joined: Fri Jan 04, 2019 1:38 pm

Re: Clicks on top left page

Post by rsudhak » Fri Mar 01, 2019 1:55 pm

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'

rsudhak
Posts: 32
Joined: Fri Jan 04, 2019 1:38 pm

Re: Clicks on top left page

Post by rsudhak » Fri Mar 01, 2019 1:58 pm

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'

ahoisl
Certified Professional
Certified Professional
Posts: 167
Joined: Fri Sep 07, 2007 8:16 am

Re: Clicks on top left page

Post by ahoisl » Fri Mar 01, 2019 2:06 pm

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

rsudhak
Posts: 32
Joined: Fri Jan 04, 2019 1:38 pm

Re: Clicks on top left page

Post by rsudhak » Fri Mar 01, 2019 3:28 pm

I dont see Descendant option at all to use them, isint it redundant

User avatar
RobinHood42
Posts: 277
Joined: Fri Jan 09, 2015 3:24 pm

Re: Clicks on top left page

Post by RobinHood42 » Mon Mar 04, 2019 11:49 am

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