Jump to content

IE9 and '_IELinkClickByText()'


Recommended Posts

Hi everyone,

currently I am testing some of my scripts if they are compatible with Microsoft Internet Explorer 9.

One of them is a login/logout automation tool. It worked like a charm up to MS IE 8.

Now, with MS IE 9, I experience some problems.

One of the functions I have problems with is '_IELinkClickByText()'.

Here is a working example (up to MS IE8 and MS Windows 7):

#include <IE.au3>


Local $oIE_Object = _IEAttach("Posteingang")
If Not @error Then
    Local $oIE_Frame = _IEFrameGetObjByName($oIE_Object, "Desktop")
    If Not @error Then
        Local $sSL_LogoutButton = _ScriptObject($oIE_Frame)
        If Not @error Then ; <<< Up to here everything works fine!!!
            _IELinkClickByText($oIE_Frame, $sSL_LogoutButton, 0, 0)
            If Not @error Then
                Local $i = 0
                Do
                    Local $oIE_Forms = _IEFormGetCollection($oIE_Object, -1)
                    If Not @error Then
                        $i = @extended ; Form count.
                    EndIf
                    Sleep(1000)
                Until $i = 1
                _IEQuit($oIE_Object)
            EndIf
        EndIf
    EndIf
EndIf


Func _ScriptObject(ByRef $oIE_Frame)
    Local $oIE_Tags = _IETagNameGetCollection($oIE_Frame, "div", -1)
    If Not @error Then
        For $oIE_Tag In $oIE_Tags
            If StringStripWS($oIE_Tag.ID, 3) = "titleBarLogout" Then
                Return SetError(0, 0, StringStripWS($oIE_Tag.InnerText, 3))
            EndIf
        Next
        Return SetError(2, 0, "")
    EndIf
    Return SetError(1, 0, "")
EndFunc

Although the function '_IELinkClickByText()' returns @error = 0 nothing happens.

I have search the forum/web but I can't found neither a reason nor a solution to my problem yet...

Could anyone else give me a clue to solve it?

Greets,

-supersonic.

Edited by supersonic
Link to comment
Share on other sites

If the problem is unique to IE9, you'll need to update to the recent AutoIt beta to get a fix to the ObjName code that caused trouble with many of the IE.au3 functions.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Dale,

thank you for your reply.

I had this already on my mind... Still without luck. :huh2:

So, to make sure that I got it right: All the "trouble" could be blamed on the current version of 'IE.au3'?

Many of the functions in 'IE.au3' are just "wrappers". Is there a way to work around this with '$object.method'?

-supersonic.

Link to comment
Share on other sites

Dale,

thank you for your reply.

I had this already on my mind... Still without luck. :huh2:

So, to make sure that I got it right: All the "trouble" could be blamed on the current version of 'IE.au3'?

Many of the functions in 'IE.au3' are just "wrappers". Is there a way to work around this with '$object.method'?

-supersonic.

No, in fact it is not an issue with IE.au3. There was a change mabe with IE9 such that the way that AutoIt implemented ObjName function no longer worked. The AutoIt beta fixes this.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Dale,

I have tried the current beta version (3.3.7.10)

Still without luck. :huh2: But the behaviour has changed!

The code line:

Local $oIE_Frame = _IEFrameGetObjByName($oIE_Object, "Desktop")

... returns:

--> IE.au3 V2.4-0 Error from function _IETagNameGetCollection, $_IEStatus_InvalidObjectType

This works under MS IE 8; even with the current beta version.

I know by 100% that there is a frame called "Desktop".

But how to get its objects by name?

Maybe you have another idea?

-supersonic.

Edited by supersonic
Link to comment
Share on other sites

Please provide a minimal reproducer to make it easy to test, please.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Dale,

first I have to correct myself: :huh2:

The provided example above does not work with the current beta version and MS IE 8.

Here is an example script to reproduce the issue:

#include <IE.au3>


Local $oIE_Object = _IECreate()
If Not @error Then
    _IENavigate($oIE_Object, "http://www.w3.org/WAI/UA/TS/html401/cp0101/0101-FRAME-TEST.html", 1)
    If Not @error Then
        Local $oIE_Frame = _IEFrameGetObjByName($oIE_Object, "target1")
        If Not @error Then
            Local $sSL_LogoutButton = _ScriptObject($oIE_Frame)
            If Not @error Then
                _IELinkClickByText($oIE_Frame, $sSL_LogoutButton, 0, 0)
                If Not @error Then
                    Sleep(3000)
                    _IEQuit($oIE_Object)
                EndIf
            EndIf
        EndIf
    EndIf
EndIf


Func _ScriptObject(ByRef $oIE_Frame)
    Local $oIE_Tags = _IETagNameGetCollection($oIE_Frame, "a", -1)
    If Not @error Then
        For $oIE_Tag In $oIE_Tags
            If StringStripWS($oIE_Tag.ID, 3) = "0" Then
                Return SetError(0, 0, StringStripWS($oIE_Tag.InnerText, 3))
            EndIf
        Next
        Return SetError(2, 0, "")
    EndIf
    Return SetError(1, 0, "")
EndFunc

If I run this script on MS Windows 7 with IE 8 and AutoIt V3.3.6.1 this example script works very well.

If I switch to AutoIt V3.3.7.10 this example script does not work in the same environment.

With MS IE 9 and V3.3.6.1 the website will be opened and the link clicked - but the website will not be closed.

With MS IE 9 and V3.3.7.10 the website will be opened - but the link will not be clicked and the website will not be closed.

Maybe this could help you?

-supersonic.

Edited by supersonic
Link to comment
Share on other sites

It would seem you could strip this down to just a few lines of code so that we can focus on just one specific issue. Please try without all the conditionals and loops so that there is no confusion about the issue.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Dale,

here's a stripped down reproducer:

#include <IE.au3>

Local $oIE_Object = _IECreate()

_IENavigate($oIE_Object, "http://www.w3.org/WAI/UA/TS/html401/cp0101/0101-FRAME-TEST.html", 1)

Local $oIE_Frame = _IEFrameGetObjByName($oIE_Object, "target1")

_IELinkClickByText($oIE_Frame, "Test Link 1", 0, 0)

Sleep(3000)

_IEQuit($oIE_Object)

$oIE_Object = 0

-supersonic.

Edited by supersonic
Link to comment
Share on other sites

I have got similar problem but I get different behaviour/error

In my case after _IELinkClickByText() @error=7 (No Match) and @extended=0 and link is not clicked

Here is even more simple example.

#include <IE.au3>

$oIE = _IECreate("about:blank")
_IEBodyWriteHTML ($oIE, 'Text <a href="http://www.google.com">Link1</a>')
_IELinkClickByText($oIE, "Link1")
MsgBox(0,'_IELinkClickByText', '@error: ' & @error & @CRLF & '@extended: ' & @extended)

On WinXP IE 6.0 OK

On WIN7 IE9 @error=7 (No Match)

All tested with AutoIt  latest beta 3.3.7.10

EDIT: I discovered some details

There is first problem with trailing space in _IELinkClickByText() on line

$linktext = $link.outerText & ""

workaround:

$linktext = StringStripWS($link.outerText & "",3)

This problem occur with this link on WinXP IE6 and also on Win7 IE9

<a href="http://www.google.com">
                  Detail
                </a>

There are spaces and @CRLF before and after text "Detail" in HTML source and $link.outerText = "Detail " --> one trailing space at end

So my workaround with StringStripWS($link.outerText & "",3) works fine.

But there is another problem related to Win7/IE9 only in my project

but I can't identify where exactly it is because I have no direct access to Win7/IE9 computer (I did some quick tests on computer of my my colleague only)

I will post reproducing script later today.

Edited by Zedna
Link to comment
Share on other sites

Here is reproducing script with real web address:

#include <IE.au3>

$oIE = _IECreate('https://isir.justice.cz/isir/common/index.do')
$oFormPodminky = _IEFormGetObjByName($oIE, "podminky_lustrace_form")
$oICO = _IEFormElementGetObjByName($oFormPodminky, "ic")
_IEFormElementSetValue($oICO, '60184396')
_IEFormSubmit ($oFormPodminky)

_IELinkClickByText($oIE, 'Detail') ; <--- problem here
MsgBox(0,'_IELinkClickByText', '@error: ' & @error & @CRLF & '@extended: ' & @extended)

As I said in my previous post this script doesn't click on "Detail" link doue to (No Match error (error 7 extended 0)

This doesn't work on  WinXP IE6 and also doesn't work on Win7 (64bit) IE9

Source of  problem is trailing space in $link.outerText in function _IELinkClickByText()

workaround:

;~         $linktext = $link.outerText & "" ; Append empty string to prevent problem with no outerText (image) links
     $linktext = StringStripWS($link.outerText & "",3) ; Append empty string to prevent problem with no outerText (image) links

With this workaround it works fine on WinXP IE6 but on Win7(64bit) IE9 it still doesn't work but behaviour is different.

There is @error=0 @extended=0 I checked it goes through all branches of "If EndIf" sections inside _IELinkClickByText() function

but it doesn't click on link "Detail". There is probably problem with $link.click which doesn't do anything

Func _IELinkClickByText(ByRef $o_object, $s_linkText, $i_index = 0, $f_wait = 1)
 If Not IsObj($o_object) Then
     __IEErrorNotify("Error", "_IELinkClickByText", "$_IEStatus_InvalidDataType")
     SetError($_IEStatus_InvalidDataType, 1)
     Return 0
 EndIf
 
 Local $found = 0, $link, $linktext, $links = $o_object.document.links
 $i_index = Number($i_index)
 For $link In $links
;~         $linktext = $link.outerText & "" ; Append empty string to prevent problem with no outerText (image) links
     $linktext = StringStripWS($link.outerText & "",3) ; Append empty string to prevent problem with no outerText (image) links
     If $linktext = $s_linkText Then
         If ($found = $i_index) Then
             $link.click
             If $f_wait Then
                 _IELoadWait($o_object)
                 SetError(@error)
                 Return -1
             EndIf
             SetError($_IEStatus_Success)
             Return -1
         EndIf
         $found = $found + 1
     EndIf
 Next
 __IEErrorNotify("Warning", "_IELinkClickByText", "$_IEStatus_NoMatch")
 SetError($_IEStatus_NoMatch) ; Could be caused by parameter 2, 3 or both
 Return 0
EndFunc   ;==>_IELinkClickByText

EDIT:

I checked return value of $link.click and it always return empty string (I expected zero on XP IE6 and error on Win7 IE9)

$ret = $link.click()
             _Log('click: ' & $ret)
Edited by Zedna
Link to comment
Share on other sites

Dale,

here's a stripped down reproducer:

#include <IE.au3>

$oIE_Object = _IECreate()
_IENavigate($oIE_Object, "http://www.w3.org/WAI/UA/TS/html401/cp0101/0101-FRAME-TEST.html", 1)
$oIE_Frame = _IEFrameGetObjByName($oIE_Object, "target1")
_IELinkClickByText($oIE_Frame, "Test Link 1", 0, 0)
Sleep(3000)
_IEQuit($oIE_Object)

-supersonic.

I have no problem with this code on IE7 (Windows XP) or IE9 (Win 7 32-bit) with the released version of AutoIt (3.3.6.1) - it opens the page and clicks the link as expected. Not sure why you are having trouble. Perhaps others can test your code as well.

I have found a problem with the beta (3.3.7.10) while testing this however and will create a Trac case (trying to get a reference to the document object in the frame triggers COM error -2147352570).

Dale

@Zedna - your issues are different

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

@Zedna - it would be better to move your discussion to a new topic because it is not clear that it is related to the original post.

First, the .click method does not have a return value, see MSDN

Second, the issue with the links with embedded spaces is not a bug because it is working as expected -- the string must be an exact match for what is in the .innertext string for the anchor. It is a resonable enhancement request, but it is not a bug.

Regarding IE9 - there is certainly something going on with IE9 as it relates to the click method. This is not the first report of trouble and I find that if the page is put into compatabilty mode in IE9 it will work as expected. I have done some searching and I have not found anything that describes any differences...

Again, Zedna, it would be better if you would move your discussion to another thread.

Dale

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

@ALL

Hi,

in the meantime I was not able to solve my problem...

Please, could somebody of the forum users be so kind to run this script and post the results?

#include <IE.au3>

Local $oIE_Object = _IECreate()

_IENavigate($oIE_Object, "http://www.w3.org/WAI/UA/TS/html401/cp0101/0101-FRAME-TEST.html", 1)

Local $oIE_Frame = _IEFrameGetObjByName($oIE_Object, "target1")

_IELinkClickByText($oIE_Frame, "Test Link 1", 0, 0)

Sleep(3000)

_IEQuit($oIE_Object)

$oIE_Object = 0

Please, tell us about your environment (e. g. MS IE8 o. IE 9, Patch Level, etc.).

I can't image to be to only one with this problem unter MS Windows 7 and IE 9!? :huh2:

Greets,

-supersonic.

Edited by supersonic
Link to comment
Share on other sites

  • 3 weeks later...

Hi everyone,

I have exactly the same problem with AutoIt 3.3.6.1 and the last beta 3.3.7.13.

Example : the script "\AutoIt3\Examples\Helpfile\_IEFormGetObjByName.au3" doesn't work on my "Windows 7 SP1 x64 & IE9" (french version).

Does not work :

_IEFormSubmit($oForm)

Or

_IEAction ($oSubmit, "click")

FernandG

Link to comment
Share on other sites

@ALL

Hi,

in the meantime I was not able to solve my problem...

Please, could somebody of the forum users be so kind to run this script and post the results?

#include <IE.au3>

Local $oIE_Object = _IECreate()

_IENavigate($oIE_Object, "http://www.w3.org/WAI/UA/TS/html401/cp0101/0101-FRAME-TEST.html", 1)

Local $oIE_Frame = _IEFrameGetObjByName($oIE_Object, "target1")

_IELinkClickByText($oIE_Frame, "Test Link 1", 0, 0)

Sleep(3000)

_IEQuit($oIE_Object)

$oIE_Object = 0

Please, tell us about your environment (e. g. MS IE8 o. IE 9, Patch Level, etc.).

I can't image to be to only one with this problem unter MS Windows 7 and IE 9!? :)

Greets,

-supersonic.

Works for me great on VIsta 32 bit IE 7.0.6002 and AutoIT 3.3.6.1
Link to comment
Share on other sites

@Supersonic

I have exactly the same problem as your first post. I perform a _IELinkClickByText that has been working fine but now I'm on IE9 it does nothing. It comes out of the routine with no errors but it has not clicked the link. I have loaded the latest Beta version 3.3.7.14 but it does not fix my problem.

Here is my minimal reproducer:

#include <IE.au3>

$oIE = _IECreate ("https://www.bdmhistoricalrecords.dia.govt.nz/Search/Search.aspx?Path=%2FqueryEntry.m%3Ftype%3DBirths")
SendKeepActive("Birth Search")
Send("Christensen" & "{tab}")
Send("Mary Ann" & "{tab}" & "{tab}")
Send("1/1/1901" & "{tab}")
Send("31/12/1901" & "{enter}")
_IELoadWait($oIE)
_IELinkClickByText($oIE, "Printer Friendly Page (all)")
If @Error Then MsgBox(16, "Error", "Internal error clicking printer friendly page button.")
MsgBox(16, "Check", "If it gets here then it should have opened the printer friendly page.")

However if I try the AutoIt sample it works.

#include <IE.au3>
$oIE = _IE_Example ("basic")
_IELinkClickByText ($oIE, "user forum")

Can you try my code and see if it works for you?

Kind regards

Edited by destin
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
 Share

  • Recently Browsing   0 members

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