Jump to content

Recommended Posts

Posted

Hi Guy's,

How to Click on Table Row (or) <tr> tag  based on ID attribute.................

Could you please Help me or Suggest me any Sites.

Thank You.

 

 

 

 

Regards,
Chaitanya K.
Posted

Welcome to AutoIt and the forum!
Which browser do you run?
AutoIt comes with an UDF (User Defined Functions library) for Internet Explorer. But there are other UDFs for Firefox and Chrome as well.
Does  clicking on a row mean you want to open an URL?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Please stick to a single thread. Posting questions multiple times is something our Mods don't like.
BTW: Did you have a look at the forum rules? If not, doing so seems to be a good idea :)

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Thank You Water ....

I am Using Internet Explorer 9.  

That's not an URL That was Table Which has Some Records so I want to Click on Each Record for Display or Showing Some content....

Thanks and Regards,

Chaitanya K.

 

Regards,
Chaitanya K.
Posted

Then please have a look at functions _IEGetObjById and _IEAction to click on the returned element.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)

Thank You So much Your Reply..........

I tried with _IEGetObjById  and _IEAction  but  They could not Working .

My Actual Sample Code is.

 

  For $oTr In $oTable        ; this is My Required  table
                   $RownodeId ="gvProgressNotes_ctl0" &$CountOfRowsIDInc      ;Row ID, Its Varient for Each Row
                                 If $oTr.id == $RownodeId Then               
                                  $oTr.click
                                 EndIf
                       $CountOfRowsIDInc = $CountOfRowsIDInc+1;
   Next

The above code is not working. Could you suggest me like that

Edited by ChaitanyaK
Regards,
Chaitanya K.
Posted

Glad to be of service :)

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)

@ChaitanyaK intresting question. Working on example.

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 10/15/2015 at 12:50 PM, ChaitanyaK said:

How to Click on Table Row (or) <tr> tag  based on ID attribute.................

Could you please Help me any one

You can not click entire Row.
You can only click on <td> element

Then JScript on the desired webpage should highlight entire Row.

eventually you can try to use:

selectAllChildren method
https://msdn.microsoft.com/en-us/library/ff975180(v=vs.85).aspx

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • Moderators
Posted

@ChaitanyaK I have merged your two threads. Please do not double post in the future. Stick with one post to make it easier for those trying to assist.

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted (edited)
  On 10/17/2015 at 11:31 PM, mLipok said:

selectAllChildren method
https://msdn.microsoft.com/en-us/library/ff975180(v=vs.85).aspx

If somebody want to use selectAllChildren so I made the following example:

#include <MsgBoxConstants.au3>
#include <ie.au3>
_IEErrorHandlerRegister(_My_ErrFunc)

Example1()
Example2()

Func Example1()
    Local $oIE = _IECreate()
    _IEDocWriteHTML($oIE, Example1_HTML())
    Local $oGetNode = $oIE.document.getElementById("elementID")
    $oSelection = $oIE.document.getSelection()
    $oSelection.selectAllChildren($oGetNode)
EndFunc   ;==>Example1

Func Example1_HTML()
    Local $sHTML = ''
    $sHTML &= '<!DOCTYPE html>' & @CR
    $sHTML &= '<html>' & @CR
    $sHTML &= '<head>' & @CR
    $sHTML &= '<meta content="text/html; charset=utf-8" http-equiv="content-type">' & @CR
    $sHTML &= '<title>_IE_Example("table")</title>' & @CR
    $sHTML &= '<style>body {font-family: Arial}</style>' & @CR
    $sHTML &= '</head>' & @CR
    $sHTML &= '<body>' & @CR
    $sHTML &= '$oTableOne = _IETableGetObjByName($oIE, "tableOne")<br>' & @CR
    $sHTML &= '&lt;table border=1 id="tableOne"&gt;<br>' & @CR
    $sHTML &= '<div id="elementID">' & @CR
    $sHTML &= '<table border=1 id="tableOne">' & @CR
    $sHTML &= ' <tr>' & @CR
    $sHTML &= '     <td>AutoIt</td>' & @CR
    $sHTML &= '     <td>is</td>' & @CR
    $sHTML &= '     <td>really</td>' & @CR
    $sHTML &= '     <td>great</td>' & @CR
    $sHTML &= '     <td>with</td>' & @CR
    $sHTML &= '     <td>IE.au3</td>' & @CR
    $sHTML &= ' </tr>' & @CR
    $sHTML &= ' <tr>' & @CR
    $sHTML &= '     <td>1</td>' & @CR
    $sHTML &= '     <td>2</td>' & @CR
    $sHTML &= '     <td>3</td>' & @CR
    $sHTML &= '     <td>4</td>' & @CR
    $sHTML &= '     <td>5</td>' & @CR
    $sHTML &= '     <td>6</td>' & @CR
    $sHTML &= ' </tr>' & @CR
    $sHTML &= ' <tr>' & @CR
    $sHTML &= '     <td>the</td>' & @CR
    $sHTML &= '     <td>quick</td>' & @CR
    $sHTML &= '     <td>red</td>' & @CR
    $sHTML &= '     <td>fox</td>' & @CR
    $sHTML &= '     <td>jumped</td>' & @CR
    $sHTML &= '     <td>over</td>' & @CR
    $sHTML &= ' </tr>' & @CR
    $sHTML &= ' <tr>' & @CR
    $sHTML &= '     <td>the</td>' & @CR
    $sHTML &= '     <td>lazy</td>' & @CR
    $sHTML &= '     <td>brown</td>' & @CR
    $sHTML &= '     <td>dog</td>' & @CR
    $sHTML &= '     <td>the</td>' & @CR
    $sHTML &= '     <td>time</td>' & @CR
    $sHTML &= ' </tr>' & @CR
    $sHTML &= ' <tr>' & @CR
    $sHTML &= '     <td>has</td>' & @CR
    $sHTML &= '     <td>come</td>' & @CR
    $sHTML &= '     <td>for</td>' & @CR
    $sHTML &= '     <td>all</td>' & @CR
    $sHTML &= '     <td>good</td>' & @CR
    $sHTML &= '     <td>men</td>' & @CR
    $sHTML &= ' </tr>' & @CR
    $sHTML &= ' <tr>' & @CR
    $sHTML &= '     <td>to</td>' & @CR
    $sHTML &= '     <td>come</td>' & @CR
    $sHTML &= '     <td>to</td>' & @CR
    $sHTML &= '     <td>the</td>' & @CR
    $sHTML &= '     <td>aid</td>' & @CR
    $sHTML &= '     <td>of</td>' & @CR
    $sHTML &= ' </tr>' & @CR
    $sHTML &= '</table>' & @CR
    $sHTML &= '</div>' & @CR
    $sHTML &= '<br>' & @CR
    $sHTML &= '$oTableTwo = _IETableGetObjByName($oIE, "tableTwo")<br>' & @CR
    $sHTML &= '&lt;table border="1" id="tableTwo"&gt;<br>' & @CR
    $sHTML &= '<table border=1 id="tableTwo">' & @CR
    $sHTML &= ' <tr>' & @CR
    $sHTML &= '     <td colspan="4">Table Top</td>' & @CR
    $sHTML &= ' </tr>' & @CR
    $sHTML &= ' <tr>' & @CR
    $sHTML &= '     <td>One</td>' & @CR
    $sHTML &= '     <td colspan="3">Two</td>' & @CR
    $sHTML &= ' </tr>' & @CR
    $sHTML &= ' <tr>' & @CR
    $sHTML &= '     <td>Three</td>' & @CR
    $sHTML &= '     <td>Four</td>' & @CR
    $sHTML &= '     <td colspan="2">Five</td>' & @CR
    $sHTML &= ' </tr>' & @CR
    $sHTML &= ' <tr>' & @CR
    $sHTML &= '     <td>Six</td>' & @CR
    $sHTML &= '     <td colspan="3">Seven</td>' & @CR
    $sHTML &= ' </tr>' & @CR
    $sHTML &= ' <tr>' & @CR
    $sHTML &= '     <td>Eight</td>' & @CR
    $sHTML &= '     <td>Nine</td>' & @CR
    $sHTML &= '     <td>Ten</td>' & @CR
    $sHTML &= '     <td>Eleven</td>' & @CR
    $sHTML &= ' </tr>' & @CR
    $sHTML &= '</table>' & @CR
    $sHTML &= '</body>' & @CR
    $sHTML &= '</html>'
    Return $sHTML
EndFunc   ;==>Example2

Func Example2()
    Local $oIE = _IE_Example("table")
;~ Local $oTable = _IETableGetCollection($oIE, 0)
    Local $oTable = $oIE.document.getElementById("tableOne")
    Local $oTrs = $oTable.rows

    Local $oSelection = Null

    For $oTr In $oTrs
        If StringInStr($oTr.innerhtml, 'jumped') Then
            MsgBox(0, '$oTr', ObjName($oTr))
            $oSelection = $oIE.document.getSelection()
            If @error Then
                MsgBox($MB_ICONERROR, 'Selection', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
            Else
                MsgBox(0, '', ObjName($oSelection))
                $oSelection.selectAllChildren($oTr)
                MsgBox($MB_ICONERROR, 'selectAllChildren', '@error = ' & @error & @CRLF & '@extended = ' & @extended)
            EndIf

        EndIf
    Next

EndFunc   ;==>Example2

; User's COM error function. Will be called if COM error occurs
Func _My_ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptFullPath & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>_My_ErrFunc

How you can see there is no way to select single row, but entire table is not a problem.

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Please show us how you solve this problem.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Hi @mLipok,

I get my Required table based on Columns.(with If Condition)

after that

 Local $oTableTRtags = _IETagNameGetCollection($oTable, "tr")

 $RownodeId ="rowid" &$dl  ; Row id Increases
 $otablerowClick = _IEGetObjById($oIE,$RownodeId)
_IEAction($otablerowClick, "click")

 

the above code is under the Loop.

 

Regards,
Chaitanya K.
Posted

oh....
so this is possible to click in row ;)

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
  • Recently Browsing   0 members

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