Jump to content
Mercy

how can i click the tab in a web page using auto it

Recommended Posts

Mercy

I inspect that Security tab in the webpage .I get the html element below:

<td tabindex="-1" align="center" class="infaTabsetSimpleTabSetTop" nowrap="true" valign="middle" onfocus="app_details_browse.$47()">Security</td>

If iam using the class name and trying to click the element. Iam getting "found" but cannot click as all the tab contains same class.

If iam using the onfocus attribute which is different for every tab and trying to click the element, the element cannot be found.

Local $oFound = ""
Local $oBtns = _IETagNameGetCollection($oIE, "td")

For $oBtn In $oBtns
    ;If String($oBtn.onfocus) ="app_details_browse.$47()" Then
    If String($oBtn.classname) = "infaTabsetSimpleTabSetTop" Then
     $oFound = $oBtn
   EndIf
Next

If IsObj($oFound) Then
    _IEAction ($oFound, "focus")
    _IEAction ($oFound, "click")
    MsgBox(16, "Success", "found")
Else
    MsgBox(16, "Failed", "Not found.")
EndIf

infaauto.png

Share this post


Link to post
Share on other sites
Mercy
Posted (edited)

Added the _IEPropertyGet and got the innertext as "Security" in the message box. So im pointing the right object but it is not clicking the tab.

Local $iScreenX = _IEPropertyGet($oFound, "innertext")
 MsgBox(0,"",$iScreenX)
If IsObj($oFound) Then
    _IEAction ($oFound, "click")
    MsgBox(16, "Success", "found")

Trying with the below code .. it is going into the if statement and displaying the msgbox as clicked but it is not clicking.

If String($oFound.innertext) = "Security" Then
_IEAction ($oFound, "click")
MsgBox(16, "Success", "Clicked")
EndIF
Edited by Mercy

Share this post


Link to post
Share on other sites
Danp2
6 hours ago, Mercy said:

Trying with the below code .. it is going into the if statement and displaying the msgbox as clicked but it is not clicking.

It's difficult to give additional suggestions when the only thing you've shown us is a screen shot. Have you logged into the site prior to running your code?

 

Share this post


Link to post
Share on other sites
Subz

Can you try the following looking at the actions of the td it only has an OnFocus action, nothing for OnClick, unless they have some other code which is being fired based upon the OnFocus and the Class Name.  Hope that makes sense.

If $oFound.innertext = "Security" Then
    _IEAction ($oFound, "focus")
    MsgBox(16, "Success", "Clicked")
EndIF

 

Share this post


Link to post
Share on other sites
Mercy
8 hours ago, Subz said:

Can you try the following looking at the actions of the td it only has an OnFocus action, nothing for OnClick, unless they have some other code which is being fired based upon the OnFocus and the Class Name.  Hope that makes sense.

If $oFound.innertext = "Security" Then
    _IEAction ($oFound, "focus")
    MsgBox(16, "Success", "Clicked")
EndIF

 

Yes, tried with this also. the web page is not loading to the page which security tab has to load.

And when we do manually, we need to click that tab and not to focus.

Share this post


Link to post
Share on other sites
Danp2

Have you tried bringing up the Developer Tools using F12 and examining the events attached to the tab? That's generally the first thing I do when I encounter a situation where the standard _IE* commands aren't working for me.

Share this post


Link to post
Share on other sites
Juvigy

Maybe it needs to receive the Onfocus event before clicking. Try:

$oFound.FireEvent("OnFocus")

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

  • Similar Content

    • simonc8
      By simonc8
      I have a script which executes sleep for a couple of hours then carries out instructions. Does the running AutoIt script prevent the computer from entering sleep mode during this time? If not, is there something I can add to the AutoIt script to keep the computer awake?
      Grateful for advice.
    • gahhon
      By gahhon
      Hi,
      I have a program that is read data from the .txt file, since the .txt file is only readable, viewable and editable for the admin user.
      But how could I lock it with password, or some other technique that can helps to achieve this?
      Thanks for the advanced information.
    • gahhon
      By gahhon
      Hi,
      How can I the trigger the another button functions without waiting the previous function to finish execute?
      Any advise?
      I couldn't find any relevant topics via google.
      Thanks a lot.
    • SharpDressedMan
      By SharpDressedMan
      Hi all,
      I need to use ControlMove() on some controls of a hidden GUI window.
      This works properly on a GUI window created with default style, but does not work on a GUI window created with style $WS_OVERLAPPEDWINDOW
      func GUItest($bOverlapped) $m = GUICreate("test", 200, 100, -1, -1, $bOverlapped ? $WS_OVERLAPPEDWINDOW : -1) $g = GUICtrlCreateButton("test", 0, 0) ControlMove($m, "", $g, 30, 30) GUISetState() endfunc GuiTest(false) ; button 'test' properly moved to (30,30) GuiTest(true) ; button 'test' not moved and still sitting at (0,0) Any reason for this unexpected behavior ?
      Any workaround to fix this ?
      Thanks for any help
    • 2Toes
      By 2Toes
      Hi all..
      I'm having slight issue that has be a bit puzzled.
      I have an Input control.. After a certain function runs, it Disables that Input control, and sets it to ReadOnly.
      When running another certain function, it re-Enables that Input control, and sets the style back to Default.
      Which does work, however, when typing into the Input control after re-Enabling it, the text appears as a light gray color, rather than its original black color.
      I'm sure there's a simple solution here.. But what that is, appears to be beyond me.
      Here is a simplified example code:
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 245, 215, 192, 124) Global $disableBTN = GUICtrlCreateButton("Disable", 32, 64, 75, 25) Global $enableBTN = GUICtrlCreateButton("Enable", 128, 64, 75, 25) Global $Input1 = GUICtrlCreateInput("", 32, 120, 169, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $disableBTN disable() Case $enableBTN enable() EndSwitch WEnd Func disable() GUICtrlSetState($Input1, $GUI_DISABLE) GUICtrlSetStyle($Input1, $ES_READONLY) EndFunc Func enable() GUICtrlSetState($Input1, $GUI_ENABLE) GUICtrlSetStyle($Input1, $GUI_SS_DEFAULT_INPUT) EndFunc  
      Any help would be greatly appreciated
      Thank you in advance!
×