Jump to content

Equivalent of IE "busy" property while using Edge and WebDriver

Recommended Posts

Hi all,

First post so I have to say this a great community and these forums have gotten me through 95% of my task to convert an IE script to Edge. Thanks for being awesome.

Besides a few weird things with getting the window handle and moving the window (sometimes it works, sometimes it doesn't) my script is mostly working as intended now.

The very last thing preventing the script from running like it used to is a check for the "busy" property of IE. Previously this was handled with:

While _IEPropertyGet($oIE,"busy") = True

Can anyone please point me to some sort of reference that shows how to achieve something similar using Edge and WebDriver?

Essentially it just lets the script keep moving as soon as the website loading spinner disappears so I could probably work around this with a bigger sleep timer after the click but this script iterates many times so this could cause the end result to be significantly slower.

Any help you can provide would be greatly appreciated!


Link to comment
Share on other sites

Thanks Danp2, that's exactly what I was looking for.

Unfortunately, it's not playing nice with the site I'm trying to integrate with. This function seems to be returning "success" while the loading icon is still displayed.

I'm no HTML expert but I think I've located the DIV that the loading icon appears in. Is there maybe some way to check if a certain DIV is visible or not?

Link to comment
Share on other sites

Thanks again for your help, Danp2. You're the true MVP.

I did some experimenting with the _WD_WaitElement function as suggested but I'm hitting some roadblocks (likely caused by my poor HTML knowledge).

I was mostly getting timeout returns from the WaitElement function except for using $iOption 8 (not found) and after getting a No Match error in _WD_FindElement I figured my error must be in how I'm addressing the actual element. I'm trying to address the element using XPATH.

I found this post explaining that my problem was because the element I'm selecting is inside a frame: AutoIt Forum - XPath can't be found. This all makes perfect sense to me but the part that's breaking my brain is that the answer that fixed it was selecting the frame on the line AFTER attempting to find the element via XPATH. My understanding is that the first line selecting the element will not find the element because the script has not yet called the _WD_FrameEnter function.

So, my question is what is the "best practice" for this situation?

My guess would be something like the following:

Local $sTargetFrame = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//frame[@name='nameOfFrame']")
_WD_FrameEnter($sSession, $sTargetFrame)
Local $sTargetElement = _WD_FindElement($SessionID, $_WD_LOCATOR_ByXPath, '//div[@id="idOfDivThatIWant"]')

However, this seems to contradict what I saw in the above linked post where the solution seemed to be using _WD_FrameEnter AFTER attempting to select the DIV that's inside the frame. Hopefully this all makes sense. I'm no stranger to coding but HTML and I have never gotten along.

UPDATE: I've attempted to use my guess as above and the _WD_FindElement targeting the frame is also saying element not found. I'm wondering if this is because the frame is nested. The frame I am targeting exists in a frameset that is nested in another frameset that is nested in an iframe. The iframe is nested in a div that is nested in a div in the body. Do I need to repeat lines as above starting from the top layer and basically keep targeting the frame of the next level down until I get to the element I need?

Edited by Auto_It_Hurts
Link to comment
Share on other sites

OK good news, after digging into the mess of frames I was able to select the DIV containing the loading image. I was then able to have the script pause successfully using the _WD_WaitElement. Thanks again Danp2!

One thing I have noticed is the behaviour of this function can be a little bit erratic. For the most part it works as intended but occasionally it will seemingly pass this function despite the loading icon still being visible or get stuck waiting for the loading icon to disappear when it's already disappeared. I've played with the timeout option for _WD_WaitElement so it doesn't really matter if it gets stuck waiting because it will eventually pass but if it allows the script to continue while the loading icon is visible it causes a snowball effect that will stop the script entirely.

So my last question (hopefully :P) is can I manually check the visibility of this element now that I have been able to locate it? I'm hoping I can supplement the existing function with some additional checks to guarantee the loading has finished before the script proceeds.

I've created a variable to hold the DIV that only appears when loading and set it using _WD_FindElement but I'm having trouble figuring out correct usage of _WD_ElementAction to check if the display attribute is "none" or "block".

Link to comment
Share on other sites

The following line comes directly from the existing _WD_WaitElement code --

$bIsVisible = _WD_ElementAction($sSession, $sElement, 'displayed')

so you should be able to do the same in your script using the result from _WD_WaitElement or _WD_FindElement.

P.S. It would be great if you could replicate the issue you described above using a website that we can all access.

Link to comment
Share on other sites

Unfortunately, I can't share the webpage I am working on sorry. I will have a play on the weekend to see if I can find a public website to try and replicate this behaviour.

Does anybody have a suggestion for a frame heavy website that uses a hidden element that appears while loading content after clicking a link? I think to replicate it will need to be something that doesn't navigate away from the page but loads different content in a frame after interacting.

On the other hand, the above snippet might help me dig into the actual cause and, if so, I will report back here.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...