Sign in to follow this  
Followers 0
LAGuy

Web Page - can't find Image to click

6 posts in this topic

Friends,

I have a Asp.Net Web Page where I'm trying to Click on the Edit Icon ( hyperlink with embedded image tag )

I can't seem to get the Form Click working.

<form id="Form" style="height: 100%;" enctype="multipart/form-data" action="/website/Admin/UserAccounts/tabid/42/Default.aspx?runningDefault=2" method="post" name="Form">

... many nested tables down in the html ...

<a href="http://localhost/website/Admin/UserAccounts/tabid/42/ctl/Edit/mid/359/UserId/28/filter/None/currentpage/1/Default.aspx" title="Edit">

<img style="border-width: 0px;" src="/website/images/edit.gif" title="Edit"/>

</a>

I've tried all these with no success

$oIE = _IECreate ("http://website/testpage.aspx")

...

$oForm = _IEFormGetObjByName ($oIE, "Form")

$rc = _IEFormImageClick ($oForm , "edit.gif", "src")

If @error Then

MsgBox(4096,"","edit.gif Image Not Found " & @error & " " & @extended )

EndIf

_IELinkClickByText ($oForm, "Edit")

If @error Then

MsgBox(4096,"","Edit Link Not Found 0" )

EndIf

$rc = _IEFormImageClick ($oForm, "/DNN462/images/edit.gif", "src")

If @error Then

MsgBox(4096,"","Image Not Found 1" )

EndIf

_IEFormImageClick ($oForm, "Edit", "alt")

If @error Then

MsgBox(4096,"","Edit Image Not Found 1" )

EndIf

$rc = _IEFormImageClick ($oIE , "/DNN462/images/edit.gif", "src")

If @error Then

MsgBox(4096,"","Image Not Found 2" )

EndIf

_IEFormImageClick ($oIE , "Edit", "alt")

If @error Then

MsgBox(4096,"","Edit Image Not Found 2" )

EndIf

Thanks, LA Guy

Share this post


Link to post
Share on other sites



_IEFormImageClick is for <input type=image> elements... you don't have one of those. _IELinkClickByText uses the plain text of a sypical hyperlink... you don't have that either.

From what you've posted you need to get an element collection and loop through it to find what you want and then use _IEAction "click" (unless of course this does the trick: _IENavigate($oIE, "http://localhost/website/Admin/UserAccounts/tabid/42/ctl/Edit/mid/359/UserId/28/filter/None/currentpage/1/Default.aspx") )

You can get an element collection in several ways... _IELinkGetCollection, _IEImgGetCollection, _IETagnameGetCollection for example.

Here's one way:

$oImgs  = _IEImgGetCollection($oIE)
For $oImg in $oImgs
    If String($oImg.title) = "Edit" Then
        _IEAction($oImg, "click")
        ExitLoop
    EndIf
Next

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I believe the _IEImgClick() function will work for you

_IEImgClick ($oIE , "", "src")

you might want to look at the source of the page you are looking at after it has loaded to make sure the correct SRC or ALT property is being used

I use IEdeveloperToolbar

http://www.microsoft.com/downloadS/details...;displaylang=en

or as DaleHohm has just pointed out to me

DebugBar is meant to be good..

see Dale's sig above for the link to Debugbar!!

Edited by Arikirangi44

Share this post


Link to post
Share on other sites

Hi Dale,

Thank you so much for relieving my frustrutation :)

$oImgs = _IEImgGetCollection($oIE)

For $oImg in $oImgs

If String($oImg.title) = "Edit" Then

_IEAction($oImg, "click")

ExitLoop

EndIf

Next

I didn't notice that $oImg.title property !!!

Cool and Thanks , LA Guy

_IEFormImageClick is for <input type=image> elements... you don't have one of those. _IELinkClickByText uses the plain text of a sypical hyperlink... you don't have that either.

From what you've posted you need to get an element collection and loop through it to find what you want and then use _IEAction "click" (unless of course this does the trick: _IENavigate($oIE, "http://localhost/website/Admin/UserAccounts/tabid/42/ctl/Edit/mid/359/UserId/28/filter/None/currentpage/1/Default.aspx") )

You can get an element collection in several ways... _IELinkGetCollection, _IEImgGetCollection, _IETagnameGetCollection for example.

Here's one way:

$oImgs  = _IEImgGetCollection($oIE)
For $oImg in $oImgs
    If String($oImg.title) = "Edit" Then
        _IEAction($oImg, "click")
        ExitLoop
    EndIf
Next

Dale

Share this post


Link to post
Share on other sites

Hi Ari,

You're solution also worked for me ! Double Happiness !

_IEImgClick ($oIE , "edit.gif", "src")

I do use Firebug in Firefox to view all the html.

I don't know DebugBar ... is it better than Firebug ?

Anyway, thanks for the quick response and relief of my agony.

Regards, LA Guy

I believe the _IEImgClick() function will work for you

_IEImgClick ($oIE , "", "src")

you might want to look at the source of the page you are looking at after it has loaded to make sure the correct SRC or ALT property is being used

I use IEdeveloperToolbar

http://www.microsoft.com/downloadS/details...;displaylang=en

or as DaleHohm has just pointed out to me

DebugBar is meant to be good..

see Dale's sig above for the link to Debugbar!!

Share this post


Link to post
Share on other sites

Firebug is great... wouldn't discourage anyone from using it... DebugBar works with IE directly, however.

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

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
Sign in to follow this  
Followers 0