Page 1 of 1 1
Topic Options
#116516 - 2004-03-22 07:29 PM Clicking an Image on a webpage
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
In the past I have automated the entry of data and clicks into Internet Explorer using the createobject("InternetExplorer.Application") object and to get each field by its name or id I used the getelementbyID method. However, now the webpage I have been using has changed and requires a click on an image file that has no name or id. When the correct image is clicked it fires onClick="GetAction(1)" which is a function elsewhere in the source.
Code:
  
<table border="0" width="650">
<tr>
<td bgcolor="lightgrey" align="right">&nbsp;</td>
</tr>
</table>
<table border="0" width="650">
<tr><td align="center" width="350" valign="top">
<form name="SelectAction" action="SelectAction.asp">
<table border="0" height="100" width="350">
<tr>
<td align="center" colspan="2">
<font color="lightGrey" size="3"><b>
Please select your action
</b></font>
</td>
</tr>
<tr>
<td align="center"><img SRC="images/picNEW.gif" alt="New - New employee or Existing employee
New employee - Select to request access for a new employee who does not have a Universal ID (34ID),
Network Logon ID, or email Account.
Existing employee (New SAF User) - Select if you would like to request access for an employee who is
an existing employee of XYZ and already has a Universal ID, a Network Logon ID but has never used SAF.
" onClick="GetAction(1)" WIDTH="104" HEIGHT="58"></td>
<td align="center"><img SRC="images/picEDIT.gif" alt="Edit - Please click on Edit if you are requesting
access for a person who has already used this application before. " onClick="GetAction(2)" WIDTH="104"
HEIGHT="58"></td>
<!--<td align="center"><img SRC="images/picDELETE.gif" onClick="GetAction(3)" WIDTH="104" HEIGHT="58">
</td>-->
</tr>
</table>



Is there another way to identify the image that will allow me to "Click()" it?

Top
#116517 - 2004-03-22 07:57 PM Re: Clicking an Image on a webpage
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
What is GetAction(1) doing? Calling another URL?
_________________________
There are two types of vessels, submarines and targets.

Top
#116518 - 2004-03-22 08:04 PM Re: Clicking an Image on a webpage
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Below is the GetAction Fuction. I tried simply adding:

$IE.document.SelectAction.Button1.Value = "New Selected"
$IE.document.SelectAction.Button1.click()

and

$IE.document.Button1.Value = "New Selected"
$IE.document.Button1.click()


to my code, but nothing happens. Not really sure it works that way.

Code:
 
function GetAction(intSelect)
if intSelect=1 then
document.SelectAction.Button1.Value = "New Selected"
document.SelectAction.Button1.click()
elseif intSelect=2 then
document.SelectAction.Button1.Value = "Edit Selected"
document.SelectAction.Button1.click()
elseif intSelect=3 then
document.SelectAction.Button1.Value = "Delete Selected"
document.SelectAction.Button1.click()
elseif intSelect=4 then
document.SelectAction.Button1.Value = "Domain Selected"
document.SelectAction.Button1.click()
elseif intSelect=5 then
document.SelectAction.Button1.Value = "COID Selected"
document.SelectAction.Button1.click()
elseif intSelect=6 then
document.SelectAction.Button1.Value = "UserID Selected"
document.SelectAction.Button1.click()
elseif intSelect=7 then
document.SelectAction.Button1.Value = "Self Edit Selected"
document.SelectAction.Button1.click()
elseif intSelect=8 then
document.SelectAction.Button1.Value = "User Type Selected"
document.SelectAction.Button1.click()
else
end if
end function




Top
#116519 - 2004-03-23 03:09 AM Re: Clicking an Image on a webpage
Stevie Offline
Starting to like KiXtart
*****

Registered: 2002-01-09
Posts: 199
I'm assuming that you don't have access to the HTML to modify it with an appropriate ID tag. The only other way to access the images programmatically would be to use:

$IE.document.images[x]

where x is the index of the image you're looking for. If the page isn't changing and you can rely on the image index staying the same, then that would be a way you could go about it.
_________________________
Stevie

Top
#116520 - 2004-03-23 03:15 AM Re: Clicking an Image on a webpage
Stevie Offline
Starting to like KiXtart
*****

Registered: 2002-01-09
Posts: 199
I don't suppose I actually finished my thought. Quite a common thing, really.

$IE.document.images[x].click() should get you where you want to go if I understand the problem correctly.
_________________________
Stevie

Top
#116521 - 2004-03-23 04:54 AM Re: Clicking an Image on a webpage
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Sweet. I'll give it a go and see what happens. Thanks.
Top
#116522 - 2004-03-23 10:03 AM Re: Clicking an Image on a webpage
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You are on the right track. There are a number of different ways of retrieving the objects using DOM - there is a short introduction page with some links here: http://www.yourhtmlsource.com/javascript/objectsproperties.html
Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1574 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.069 seconds in which 0.035 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org