Jump to content

How to click an IE element by class


Recommended Posts

Hi friends,

I'm trying to click on an IE element with text "Turbo". Please see the information of control by  F12 - Tool.

Image of IE element

<nav class="left"><a class="nav-item active" href="#">Turbo</a><a class="nav-item " href="#">Intraday</a><a class="nav-item " href="#">Long term</a><a></a></nav>

 

I have tried all the methods described on this topic: 

But the element that I want to click is not a link and the page has no forms Can anyone please help :-)

 

 

 

Link to comment
Share on other sites

1 hour ago, PoojaKrishna said:

I'm trying to click on an IE element with text "Turbo".

<nav class="left"><a class="nav-item active" href="#">Turbo</a><a class="nav-item " href="#">Intraday</a><a class="nav-item " href="#">Long term</a><a></a></nav>

But the element that I want to click is not a link and the page has no forms Can anyone please help :-)

Actually, that item is a link. Show your code if you want additional help / feedback.

Link to comment
Share on other sites

Func _SelectTurbo()
    Local $oLinks = _IELinkGetCollection($oIE)
    Local $iNumLinks = @extended
    Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF
    For $oLink In $oLinks
        $sTxt &= $oLink.text & @CRLF
    Next
    MsgBox($MB_SYSTEMMODAL, "Text:", $sTxt)

EndFunc ;=> _SelectTurbo

Thank you so much for your reply. 46 links found, but none of them has text "Turbo".

---------------------------
Link Info
---------------------------
46 links found

Trading
Account funding
Withdrawals
Enter Promo Code
Transactions history
Trading history
Personal Data
Security settings
Support
Exit

+1-829-9548077

                     Русский
               

                     Español
               

                     ไทย
               

                     Français
               
Exit
Account funding






Trader contest
Trading
Account funding
Account funding
Withdrawals
Enter Promo Code
Statements
Transactions history
Trading history
Settings
Personal Data
Security settings
Support
+100 USD
+250 USD
+500 USD
+1000 USD
Get more info
Privacy policy

 

---------------------------
OK   
---------------------------
 

Link to comment
Share on other sites

Func _SelectTurbo()
    $nFound = 0
    Local $oLinks = _IETagNameGetCollection($oIE, "a")
    For $oLink In $oLinks
        If $oLink.ClassName = "nav-item" Or $oLink.InnerText = "Turbo" Then
            $nFound = 1
            MsgBox(4096, "href attribute", $oLink.GetAttribute("href").value)
        EndIf
    Next
    If $nFound = 0 Then
        Msgbox(0,"Not Found", "Not Found")
    EndIf
EndFunc ;=> _SelectTurbo

Thank you for your reply Subz but sorry resulted in nothing. No links found with the class name and inner text.

Link to comment
Share on other sites

Actually should have tested first the code should be:

#include <IE.au3>

Local $oIE = _IECreate("www.domain.com", 1)
_IELoadWait($oIE)
Local $oLinks = _IETagNameGetCollection($oIE, "a")
For $oLink In $oLinks
    If $oLink.ClassName = "nav-item active" And $oLink.InnerText = "Turbo" Then
        MsgBox(4096, "href attribute", $oLink.GetAttribute("href"))
    EndIf
Next

 

Link to comment
Share on other sites

26 minutes ago, Subz said:

Actually should have tested first the code should be:

#include <IE.au3>

Local $oIE = _IECreate("www.domain.com", 1)
_IELoadWait($oIE)
Local $oLinks = _IETagNameGetCollection($oIE, "a")
For $oLink In $oLinks
    If $oLink.ClassName = "nav-item active" And $oLink.InnerText = "Turbo" Then
        MsgBox(4096, "href attribute", $oLink.GetAttribute("href"))
    EndIf
Next

 

Displays nothing.

Link to comment
Share on other sites

5 minutes ago, mikell said:

?

#include <IE.au3>

Local $oIE = _IECreate("www.domain.com", 1)
_IELoadWait($oIE)
Local $oNavs = _IETagNameGetCollection($oIE, "nav")
For $oNav In $oNavs
   $oLinks = _IETagNameGetCollection($oNav, "a")
   For $oLink In $oLinks
       If $oLink.InnerText = "Turbo" Then MsgBox(0, "" "found it")
   Next
Next

 

Nothing displayed.

Link to comment
Share on other sites

Weird because it returns "#" for me based upon your html above, you could try ditching the ClassName and just have If $oLink.InnerText = "Turbo" that worked for me as well.

Can you post console information when you run the code?

Edited by Subz
Link to comment
Share on other sites

48 minutes ago, Subz said:

Weird because it returns "#" for me based upon your html above, you could try ditching the ClassName and just have If $oLink.InnerText = "Turbo" that worked for me as well.

Can you post console information when you run the code?

No console information.

Link to comment
Share on other sites

www.binarymate.com

<html lang="en"><head>
        <meta charset="UTF-8">
        <title>Binarymate</title>
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

        <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700italic,600,300,300italic&amp;subset=latin,cyrillic" rel="stylesheet" type="text/css">

        <link href="/assets/bm/css/site.css" rel="stylesheet">
        <link href="/assets/bm/css/dropdown.css" rel="stylesheet">
        <link href="/assets/bm/css/semantic.css" rel="stylesheet">
        <link href="/assets/bm/css/transition.min.css" rel="stylesheet">
        <link href="/assets/bm/css/modal.css" rel="stylesheet">
        <link href="/assets/bm/css/perfect-scrollbar.css" rel="stylesheet">
        <link href="/assets/bm/css/pickmeup.css" rel="stylesheet">
        <link href="/assets/bm/css/font-awesome.css" rel="stylesheet">
        <link href="/assets/bm/css/platform.css" rel="stylesheet">
        <link href="/assets/bm/css/pickmeup.css" rel="stylesheet">
        <link href="/assets/bm/css/fx-chart.css" rel="stylesheet">

    <style id="erd_scroll_detection_scrollbar_style">/* Created by the element-resize-detector library. */
.erd_scroll_detection_container > div::-webkit-scrollbar { display: none; }

.erd_scroll_detection_container_animation_active { -webkit-animation-duration: 0.1s; animation-duration: 0.1s; -webkit-animation-name: erd_scroll_detection_container_animation; animation-name: erd_scroll_detection_container_animation; }
@-webkit-keyframes erd_scroll_detection_container_animation { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }
@keyframes erd_scroll_detection_container_animation { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }</style></head>
    <body class="gray-bg">
        <div id="root"><div class="platform-container" data-reactroot=""><div class="theme-wrap dark-theme-wrap"><div class="top-nav-t clearfix"><div class="ui top-nav-mobile not-select dropdown" style="z-index: 200;"><input name="gender" type="hidden" value=""><div class="burger"><i></i></div><div class="menu"><a class="item" href="#">Turbo</a><a class="item" href="#">Intraday</a><a class="item" href="#">Long term</a><a></a></div></div><nav class="left"><a class="nav-item active" href="#">Turbo</a><a class="nav-item " href="#">Intraday</a><a class="nav-item " href="#">Long term</a><a></a></nav><div class="right"><div class="cent-block"><span class="cent-help ">You trade in cents</span><div class="switcher-wrap"><div class="switcher"><div class="sw-item ">$</div><div class="sw-item ">¢</div></div></div></div><div class="amount">0.00 </div></div></div><div class="main-content clearfix"><div class="row-3-t"><div class="category  ui dropdown selection"><input type="hidden" value=""><i class="dropdown icon"></i><div class="default text">Currencies</div><div class="menu"></div></div><div class="custom-scroll"></div></div><div class="row-7-t"><div class="canvas-graph" style="overflow: hidden;"><div class="graph-dropdowns"><div class="category  ui dropdown selection"><input type="hidden" value=""><i class="dropdown icon"></i><div class="default text"></div><div class="menu"></div></div><div class="just-time"><span class="clock-icon"></span><div class="default text">19:53:37</div></div></div><div class="chart-container"><svg xmlns="http://www.w3.org/2000/svg" class="svg-chart"><defs><linearGradient id="FxBgGradient" x1="0" y1="0" x2="0" y2="1"><stop class="st1" offset="0%" /><stop class="st2" offset="90%" /></linearGradient><radialGradient id="pointGradient"><stop class="st1" offset="12%" /><stop class="st2" offset="12%" /><stop class="st3" offset="90%" /></radialGradient></defs><text class="load" x="50%" y="50%">Loading...</text></svg><a class="btn-back btn-chart"></a><a class="btn-front btn-chart"></a><a class="btn-skip btn-chart"></a><a class="btn-zoom-in btn-chart"></a><a class="btn-zoom-out btn-chart"></a><a class="btn-target btn-chart"></a><div></div><div class="erd_scroll_detection_container erd_scroll_detection_container_animation_active" style="margin: 0px; padding: 0px; width: 0px; height: 0px; overflow: hidden; display: inline; visibility: hidden; z-index: -1;"><div class="erd_scroll_detection_container" style="left: 0px; top: 0px; width: 100%; height: 100%; overflow: hidden; visibility: hidden; position: absolute; z-index: -1;" dir="ltr"><div class="erd_scroll_detection_container" style="left: -18px; top: -18px; right: -17px; bottom: -17px; overflow: hidden; visibility: hidden; position: absolute; z-index: -1;"><div style="width: 100%; height: 100%; overflow: scroll; visibility: hidden; position: absolute; z-index: -1;"><div style="left: 0px; top: 0px; width: 1098px; height: 575px; position: absolute;"></div></div><div style="width: 100%; height: 100%; overflow: scroll; visibility: hidden; position: absolute; z-index: -1;"><div style="width: 200%; height: 200%; position: absolute;"></div></div></div></div></div></div></div></div><div class="row-2-t"><div class="row-2-t-half"><div class="line"><label><!-- react-text: 67 -->Time<!-- /react-text --><span title="'Time' represents duration of the option. In case of Fixed time mode, option 'Time' is the difference between the time when you enter to the market purchase the option, and option expiration time. If fixed time is switched off, 'Time' represents the difference between the time when option becomes available to purchase it on the market and option expiration time." class="ask">?</span><time style="float: right;">16:49:38</time></label><div class="category ui time-select selection dropdown"><input type="hidden" value=""><i class="dropdown icon"></i><div class="default text"></div><div class="menu"></div></div></div><div class="line"><label><!-- react-text: 77 -->Fixed time<!-- /react-text --><span title="'Time' represents duration of the option. In case of Fixed time mode, option 'Time' is the difference between the time when you enter to the market purchase the option, and option expiration time. If fixed time is switched off, 'Time' represents the difference between the time when option becomes available to purchase it on the market and option expiration time." class="ask">?</span><div class="theme-switcher"><input id="theme-switcher" type="checkbox" value="on"><label for="theme-switcher"><i></i></label></div></label><div class="line"><label><!-- react-text: 85 -->Amount<!-- /react-text --><span title="Trade amount in base currency of the trading account." class="ask">?</span></label><div class="input-number-box"><input class="input-number amount-input" type="text" value="10"><div class="input-number-more"></div><div class="input-number-less"></div></div></div><div class="line"><label><!-- react-text: 93 -->Profit<!-- /react-text --><span title="Profitability of the chosen option" class="ask">?</span></label><div class="profit-sum"><!-- react-text: 96 -->0<!-- /react-text --><span class="profit-cur"></span></div></div></div></div><div class="row-2-t-half"><div class="line"><a class="btn btn-success has-spinner active"><span class="spinner"><i class="icon-spin icon-refresh"></i></span></a><button class="ui button green"><!-- react-text: 104 -->Call<!-- /react-text --><i class="arrow-up"></i></button><div class="current-value">0.00000</div><button class="ui button red"><!-- react-text: 108 -->Put<!-- /react-text --><i class="arrow-down"></i></button></div></div></div><div class="bottom-filter"><div class="filter-wrap"><div class="t-cell"><label>Status</label><div class="ui selection dropdown"><input type="hidden" value=""><i class="dropdown icon"></i><div class="default text">Open</div><div class="menu"><div class="item">Open</div><div class="item">Closed</div></div></div></div><div class="t-cell"><label>Asset</label><div class="ui selection dropdown"><input type="hidden" value=""><i class="dropdown icon"></i><div class="default text">All</div><div class="menu"><div class="item">All</div></div></div></div><div class="t-cell"><label>Choose date from:</label><div class="calendar-wrap"><i class="calendar-icon"></i><input class="date" type="text" value="10-06-2017"></div></div><div class="t-cell"><label>To:</label><div class="calendar-wrap"><i class="calendar-icon"></i><input class="date" type="text" value="10-06-2017"></div></div><div class="t-cell right"><ul class="pagination ng-isolate-scope ng-valid"><a class="ng-binding disabled">&lt;&lt;</a><a class="ng-binding disabled">&lt;</a><i></i><i></i><a class="ng-binding">1</a><i></i><i></i><a class="ng-binding disabled">&gt;</a><a class="ng-binding disabled">&gt;&gt;</a><div></div></ul></div></div></div><div class="table-nav-wrap"><table class="table-nav"><thead><tr><th>Id</th><th>Asset</th><th>Strike rate</th><th>Close price</th><th>Call/Put</th><th>Start time</th><th>Expiry time</th><th>Investment</th><th>Payout</th></tr></thead><tbody></tbody></table></div><div class="ui small no-money modal no-balance"><i class="close icon"></i><div class="content"><h3>Insufficient to make the trade</h3><div class="line center clearfix">Available balance: 0 </div><div class="line center clearfix"><a class="ui button">Increase the balance</a></div></div></div><div class="ui small no-money modal no-active"><i class="close icon"></i><div class="content"><div class="line center clearfix">Please fund your account to activate trading.</div><div class="line center clearfix"><a class="ui button">Account activation</a></div></div></div><div class="ui small no-money modal order-reject"><i class="close icon"></i><div class="content"><div class="line center clearfix"></div><div class="line center clearfix"><a class="ui button">Try again!</a></div></div></div></div></div></div></div>
        <script>
             window.scaling = 'normal'
             window.amountList = '{&quot;LTC&quot;:0.01,&quot;BTC&quot;:1.0E-4,&quot;USD&quot;:1,&quot;RUB&quot;:50,&quot;EUR&quot;:1}'
             window.cfdtest = 'disable'
        </script>
        <script src="/assets/i18n/en.js">
        </script>
        




  

<script src="/assets/platform-js-jsdeps.min.js" type="text/javascript"></script>






  

<script src="/assets/platform-js-opt.js" type="text/javascript"></script>






  



    
</body></html>

 

Link to comment
Share on other sites

2 hours ago, Subz said:

As long as the webpage is open in IE it returns # for me, I'm assuming you are removing the actual hyperlinks from href?  Can you confirm that when Turbo is "active/selected" that it has a value under href?

Turbo is active and "#" is under href.

<nav class="left"><a class="nav-item active" href="#">Turbo</a><a class="nav-item " href="#">Intraday</a><a class="nav-item " href="#">Long term</a><a></a></nav>

Link to comment
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
 Share

  • Recently Browsing   0 members

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