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

    • TrashBoat
      By TrashBoat
      So Im trying to make a simple 2d game and make some sort of collision detection so why not to make a 2 dimensional array but i have no clue how  to write it in multiple lines
      Global $map[5,5] = [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0] something like this but it doesn't work
    • Zein
      By Zein
      #include "..\Include\Array.au3" #include "..\Include\File.au3" #include "..\Include\AutoItConstants.au3" Local $aRetArray Local $sFilePath = "n.csv" _FileReadToArray($sFilePath, $aRetArray, ",") ; _FileReadToArray($sFilePath, $aRetArray, $FRTA_COUNT, ",") _ArrayDisplay($aRetArray, "Original", Default, 8) The above code shows two versions of _FileReadToArray and both don't work as expected.
      The first one doesn't use the comma as a delimiter. (so I get a single column array)  I tried adding "Default" between $aRetArray and "," then it told me it had an incorrect number of parameters. 

      I looked again at the documentation:
       
      #include <File.au3> _FileReadToArray ( $sFilePath, ByRef $vReturn [, $iFlags = $FRTA_COUNT [, $sDelimiter = ""]] )
      And I with or without the flags params I should be getting a 2D array due to my file being a csv. 
      I then tried a regular flag, $FRTA_COUNT, and it tells me that I'm using a variable $FRTA_COUNT while it's not declared. Tried putting in 1 instead and it told me again, incorrect number of params. 

       
    • nooneclose
      By nooneclose
      I need to perform a subtotal in excel and I would like to automate this process using Autoit if possible like always any and all help will be greatly appreciated. 
      I can not find a good example but the two from Microsoft. Here is one of the two from msdn.microsoft.com/en-us/vba/excel-vba/articles/range-subtotal-method-excel
      I do not really understand how to translate this into AutoIt, but I gave it a try and here is what I have.
      $OpenRange      = "A1:E200" $xlSum          = -4157 $Added_Array[2] = [2, 3] $OpenRange.Subtotal("B1", $xlSum, $Added_Array, True, False, True) I just need to perform a subtotal on a range based on a header called department, and then perform a sum on the results.
    • nooneclose
      By nooneclose
      How to use _Excel_RangeSort to sort my excel file by three different headers Column A1, B1, and C1 have headers on which I want to sort by. The headers on which I want to sort are department, employee type, and name.
      I still really new to AutoIt so I do not actually know how to properly start this line or lines of code, to be honest. The example code is the best I can do.
      _Excel_RangeSort($OpenWorkbook, Default, "A1:C1", "1:1", $xlDescending, Default, $xlYes, Default, $xlSortRows) I just need to sort by those three headers in that order of department, employee type, and name, plus in descending order.
       
      any and all help would be greatly appreciated.  Thank you!
    • Eminence
      By Eminence
      Hello,
      Using SQLite, I was trying to select a specific column with having duplicate entries removed by using the DISTINCT function. 
      Local $sQuery = "SELECT DISTINCT supervisor, COUNT(DISTINCT employee_name) FROM data_db What the above snippet does is just list only one supervisor but with the total count of unique employee names in the whole database when it should be listing out all supervisor entries from the database and list the total count of employees per each supervisors. If I remove the COUNT function, it does list out all unique entries of supervisor names from the list. Attached is a screenshot of an example database as well. 
      Any help will be much appreciated. Thank you!

×