Ask a Question

Getting error when checking for object not Exists or Visible

tvklovesu
Contributor

Getting error when checking for object not Exists or Visible

Hi friends,

I got stuck with this issue for last two days and really scratching my head. So, when the page was loaded only a few records from the total records will be displayed. user has to scroll all the way down the list to load next set of records, once the complete list loaded then user can't scroll down anymore. Here when the user scrolls down, a loading image with spinning icon is displayed and once the list loaded that image will not be displayed again when you scroll down to get next set of records then that loading image will display again. The element of that loading image will still be there in dom until all the list is loaded. 

in my script I tried waitproperty(visible, false, 5000), while loop with both exists and visible, but when the element is removed from the dom then I am getting the following error

"Unable to find the object "div[class*='MuiCircularProgress-determinate'][role='progressbar']". See Details for additional information. 13:49:32 Normal 11.37"

 

option1:

function waitUntil(element, PropValue, timeout){
var i=0
//var obj = Aliases.pageEmailAnalyticsGettingStarted.FindElement(element)
do
{
Delay(1000)
if (i==10){
break;
}
i++;
}while (Aliases.pageEmailAnalyticsGettingStarted.FindElement(element).Visible==false)
}

 

Option2.

while (Aliases.pageEmailAnalyticsGettingStarted.FindElement(element).Visible==true)

{

Delay(1000)

}

 

Option 3.

tvklovesu_0-1670612900808.png

 

Can someone please help me how to fix this and verify if the object not exists and/or visible

 

Thanks

14 REPLIES 14
rrobinson
New Contributor

I am brand new but have had a similar list/paging issue. I am still learning to find an object programmatically - however, I did get to the bottom of my list (see below) and verify it was loaded using a portion of my grid/list control that is always there - like the page navigation as an example to verify I was on page 1 - and using a list I know is not growing you could also verify the count or something as a text/context checkpoint.

 

To scroll off the page vertically (the page was approximately 2 full screens so the bottom was well off the visible page), I just pressed the END key to get to the very bottom. Then defined some text checkpoint that would not be there if something failed.

 

Hope that helps and yes this was a simple thing - but for me it worked!

rraghvani
Valued Contributor

The UI Object must exist in the Object Browser in order to use WaitProperty Method.

 

You can try using either WaitElement Method or WaitChild Method. 

Hello @rrobinson, Thanks for your response. As you might notice that I am already using End key to scroll down to the page to load the next set of records. I have figured out the issue that the Exists and Visible properties returns true until all the records are loaded even though the visible is hidden. I looked at the VisibleonScreen and the value for that property changed to False when the result loaded, and the image is hidden. So I am using that property to verify and its working fine with my wait statement. But the issue still exists where once all the records are loaded the VisibleOnScreen is also throwing error that the object not found.

How to verify the object is not Visibleonscreen in the If statement when it is completely removed from the DOM 

code I changed to 


function waitUntil(element, PropValue, timeout){
var i=0
do
{
if (!Aliases.pageEmailAnalyticsGettingStarted.FindElement(element).VisibleOnScreen){
break;
}
Delay(2000)
i++;
}while (i<=10)

}

 

html source. The highlighted element will not change until all the records are loaded and that element will be removed from the dom.

tvklovesu_0-1670867312684.png

tvklovesu_1-1670867442169.png

The loading image is what I am verifying.

 

rraghvani
Valued Contributor

Removed

rraghvani
Valued Contributor

Removed

rraghvani
Valued Contributor

See Waiting for an Object, Process or Window Activation

 

In your code, you need to check if the object returned is not null before getting the property value.

Even I tried FindElements.length!=0 and still got the same error that unable to find the object. But finally I was able to fix the issue by modifying my code as below

 

function waitUntil(element, PropValue, timeout){
var i=0
var obj = Aliases.pageEmailAnalyticsGettingStarted.FindElement(element)
do
{
Delay(2000)
if (obj.VisibleOnScreen==PropValue){
break;
}
i++;
}while (i<=10)
}

Nice! I like all the code examples I can find!  This is very helpful and happy that you sent this solution to me!!! Thanks a ton! Very nice solution here.

The script runs fine in local, but when I try headless then its throwing error as stale element that the object not found as the page refreshed or so. How do you handle stale element in TC. while working in selenium I usually call the element again, in TC I even did same where I was set var obj everytime the function is called. Is there any other different way to fix this error.

cancel
Showing results for 
Search instead for 
Did you mean: