Mike-Smith

Click on img tag without any id,name and etc.

12 posts in this topic

I want to click on a few img tag but there is no id or every unique things that i can select one thing which i need and the second problem is in my HTML source has a lot of img tags with same src so it's a big problem but i find a piece of text in on click parameter of img tag which is make a difference, so my case is like as below:

This is a right img tag that i want to click but src and class are the same with other img tags, so I can't find a difference, but the piece of code on below is make difference.

my scenario: I want click on each img tag which has a below string into it

String: ViewSIPTrunkRequest.shtm

IMG Tag:

<img class="imgColor" onmouseover="this.style.cursor='hand'" onclick="window.open('/pasna/systems/services/html/ViewSIPTrunkRequest.shtm?VIEW_SIP_TRUNK_REQUEST_PK_ID=347', '', 'toolbar=no,status=yes,menubar=yes,scrollbars=yes,resizable=no,directories=no,location=no, width=1000,height=700,left=10,top=0');" src="/pasna/images/view.png" border="0">

 

Please help me to solve this problem.

Thanks a million.

Share this post


Link to post
Share on other sites



Have you tryd _IENavigate? Just complete URL: " '/pasna/systems/services/html/ViewSIPTrunkRequest.shtm?VIEW_SIP_TRUNK_REQUEST_PK_ID=347 " (the beginning part)

Share this post


Link to post
Share on other sites
10 hours ago, AutoBert said:

Have you tryd _IENavigate? Just complete URL: " '/pasna/systems/services/html/ViewSIPTrunkRequest.shtm?VIEW_SIP_TRUNK_REQUEST_PK_ID=347 " (the beginning part)

Auto Bert thanks for your reply but i don't know _IENavigate how may help me, please write me sample or if you want to more information feel free to tell.

Share this post


Link to post
Share on other sites

give me URL and i complete this one liner!

Share this post


Link to post
Share on other sites
1 minute ago, AutoBert said:

give me URL and i complete this one liner!

http://192.168.9.200/pasna/systems/services/html/ViewSIPTrunkRequest.shtm?VIEW_SIP_TRUNK_REQUEST_PK_ID=347

Share this post


Link to post
Share on other sites

Auto Bert I'm waiting for your reply and i hope it'll be solve a problem.

Share this post


Link to post
Share on other sites

Auto Bert I'm waiting for your reply and i hope it'll be solve a problem.

Share this post


Link to post
Share on other sites

If I understand the problem, you could use a stopgap like the following to compensate the missing ID

#include <IE.au3>

Local $oIE = _IECreate() ; Create an empty browser
Local $sHTML = ""
; since your intanet web server is not accessible from the outside world
; I will create a sample page by script to be embedded in the browser
$sHTML &= "<HTML>" & @CRLF
$sHTML &= "<HEAD>" & @CRLF
$sHTML &= "<TITLE>Hello</TITLE>" & @CRLF
$sHTML &= "</HEAD>" & @CRLF
; following image has no ID
$sHTML &= '<img src="http://www.w3schools.com/tags/smiley.gif" OnClick="this.src=' & "'http://www.w3schools.com/jsref/smiley.gif'"">" & @CRLF
$sHTML &= "</HTML>"
_IEDocWriteHTML($oIE, $sHTML) ; write above html in the browser
_IEAction($oIE, "refresh")

; You could use something like following way in your script
; ---------------------------------------------------------
Local $sTargetString = "school" ; <-- string to search within the image OnClick attribute
Local $oImgs
Do
    $oImgs = _IEImgGetCollection($oIE) ; get images collection
    Sleep(100)
Until IsObj($oImgs) ; wait till collection is ready

For $oImg In $oImgs ; scan all images

    $attributes = $oImg.attributes ; attribute collection for each image
    For $Attribute In $attributes ; scan all attributes
        ; now chech if the searched string is in this image OnClick attribute
        If $Attribute.nodeName = "onclick" And StringInStr($Attribute.nodeValue, $sTargetString) Then
            $oImg.Click ; got our target image, click on it
            ExitLoop 2
        EndIf
    Next
Next
; ---------------------------------------------------------
MsgBox(0, "Pause", "Pause")
_IEQuit($oIE)

 


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Thanks Chimp but $oImg.click is not work in my case what's your suggestion?

 

Share this post


Link to post
Share on other sites
On 2.9.2016 at 1:30 PM, Mike-Smith said:

Auto Bert I'm waiting for your reply and i hope it'll be solve a problem.

i thought solving like this:

_IENavigate($oIE,'http://192.168.9.200/pasna/systems/services/html/ViewSIPTrunkRequest.shtm?VIEW_SIP_TRUNK_REQUEST_PK_ID=347')

 

Share this post


Link to post
Share on other sites

Thanks this step is passed but after that I have a HTML table which it has some data and I want to fetch them, after that I have to click on hyper link then PDF file open and I want to extract PDF file data, then insert them to MySQL or SQLite.

Please help me to done this project, so my needs are following as below:

1- Get data from HTML table and insert it to sqlite

2- Click on hyper link on HTML table

3- Extract data from PDF file and insert it to SQLite

 

thanks a million

Share this post


Link to post
Share on other sites
3 hours ago, Mike-Smith said:

then PDF file open and I want to extract PDF file data

What exactly you want when you say extract PDF file data ?

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

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