Page 1 of 1

Could not get a valid element rectangle

Posted: Fri Sep 07, 2018 7:53 am
by kissKurisu
Hello,

Code: Select all

//code open a form
Button btn=repo.Form1.BtnCancel;
btn.Click();  //do noting and click cancel button to close the form

//code open the same form again
btn.Click();  //click the same cancel button again
When executing btn.Click() the second time,I got warning "Could not get a valid element rectangle from '{Button:}', since the element is no longer valid. ".It happens whether "use cache" is true or not.
Is that I must add "btn=repo.Form1.BtnCancel;" before the second clicking?

os: win10 x64
ranorex 7.2.1

Re: Could not get a valid element rectangle

Posted: Fri Sep 07, 2018 8:04 am
by odklizec
Hi,

At first, Ranorex 7.x is long time outdated and no longer supported. Please upgrade Ranorex with most recent version 8.2.1 and check if the problem still exists.

At next, could you please upload a Ranorex snapshot of the problematic button (ideally both before and after closing the form) and its xpath, as used in repository? It's hard to suggest something sensible without these details.

From the code you posted it seems, that after first click, the form with cancel button closes and the second attempt to click cancel is just too fast, and it probably tries to click the cancel button, which is already closed? I would suggest to add a small delay before the next click. Have you tried to simulate the steps with recording?