SteveStrop

_IEAttach fails to work without first switching to other window

5 posts in this topic

Hi I'm trying to write a simple script to

(i) open a web page - stored in an object variable called $oIE 

(ii) enter some logon credentials 

(iii) click a submit button

(iv) wait for the new page to open then attach it to the original $oIE object (effectively replacing the original $oIE object with a reference to the newly loaded page)

(v) click a link that appears on the new page

 

Now steps (i) to (iii) work a treat - no problem. But I can't get the next part working without adding a work around.

 

Specifically this never exits the loop and an inspection of $oIE shows it contains the original page with the submit button on it.

_IEAction($oSubmitButton, "click")
    _IELoadWait($oSubmitButton)
    _IELoadWait($oIE)


    ;while "QA" not in body text of page loop until it is

$count=0
    while NOT (StringInStr(_IEBodyReadText($oIE),"QA"))
        $count=$count+1
sleep(500)

        $oIE = _IEAttach("KeyAGENT","windowtitle")

    WEnd

 

But if I add a message box like so

_IEAction($oSubmitButton, "click")
    _IELoadWait($oSubmitButton)
    _IELoadWait($oIE)


    ;while "QA" not in body text of page loop until it is

$count=0
    while NOT (StringInStr(_IEBodyReadText($oIE),"QA"))
        $count=$count+1
sleep(500)
Msgbox(0,"","works fine now")
        $oIE = _IEAttach("KeyAGENT","windowtitle")

    WEnd

it works as expected ($count=2 on exit)

 

I can swap the Msgbox lines for something like

$iPID = Run("Notepad")
Send("why??")
ProcessClose ($iPID)

 

I've tried embedded, url, title, instance variations of the _IEattach function but all have the same issue.

What is going on and whats the best way to get this _IEAttach call to work? i.e to replace the original page stored in $oIE with the newly loaded page

 

Thanks in advance - I'm pulling my hair out over this one.

 

Share this post


Link to post
Share on other sites



Can you explain why the _IEAttach is required when you already have a reference to the IE tab in $oIE? Does this "new" page load into the existing tab or a new one?

Share this post


Link to post
Share on other sites

I use _IECreate to open the original webpage in IE11

Global $oIE = _IECreate("http://www.keyagent-portal.co.uk/Index.aspx")

It loads into the existing IE tab yes but  If I don't do the _IEAttach command then the $oIE object doesn't get updated to reflect the new page content. Prehaps I'm really asking how to update the $oIE object when a "new" page loads into the existing tab.

Thanks for your super quick response

Steve

Share this post


Link to post
Share on other sites

You shouldn't need to update the $oIE object in this situation. Can you provide a test login for this site or a reproducer script using something like Google as the site?

Share this post


Link to post
Share on other sites

I'll have to knock up a reproducer script as I don't have a test login we can use.

Share this post


Link to post
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