Could not get a valid element rectangle

Ask general questions here.
Posts: 8
Joined: Wed Oct 18, 2017 8:51 am

Could not get a valid element rectangle

Post by kissKurisu » Fri Sep 07, 2018 7:53 am


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

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

Re: Could not get a valid element rectangle

Post by odklizec » Fri Sep 07, 2018 8:04 am


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?
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