Jump to content

IE div class innerText to variable


Recommended Posts

Hi,

I can't figure out how to assign a div class innertext to variable correctly, could you please have a look at it? MsgBox doesn't show the variable's value.

What I'd like to achieve is to display the current balance from a broker's site. Authentication works okay.

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("https://www.24option.com/24option/#Trade", 0, 1, 1, 0)
CheckifLoginBroker()
Sleep(5000)
Local $sCurrentBalance

$tags = $oIE.document.GetElementsByTagName("div")
    For $tag In $tags
        $class_value = $tag.GetAttribute("class")
        If $class_value = "gwt-HTML" Then
            $tag.innerText = $sCurrentBalance
            ExitLoop
        EndIf
    Next

MsgBox(0, "Balance", $sCurrentBalance)

Func CheckifLoginBroker() ;Look for login form on broker's site (active status)
    $tags = $oIE.document.GetElementsByTagName("input")
    $found = False
    For $tag In $tags
        $class_value = $tag.GetAttribute("class")
        If $class_value = "gwt-TextBox navigation_menu_username_field" Then
            $tag.click()
            $found = True
            ExitLoop
        EndIf
    Next
    If $found Then ;Login if login form is visible (inactive status)
        $tags = $oIE.document.GetElementsByTagName("input")
        $found = False
        For $tag In $tags
            $class_value = $tag.GetAttribute("class")
            If $class_value = "gwt-TextBox navigation_menu_username_field" Then
                _IEFormElementSetValue($tag, "user")
            EndIf
            If $class_value = "gwt-TextBox navigation_menu_password_field" Then
                _IEFormElementSetValue($tag, "password")
            EndIf
        Next
        $tags = $oIE.document.GetElementsByTagName("div")
        $found = False
        For $tag In $tags
            $class_value = $tag.GetAttribute("class")
            If $class_value = "navigation_menu_login_button" Then
                $tag.click()
                ExitLoop
            EndIf
        Next
        Sleep(2000)
        _IELoadWait($oIE)
    EndIf
EndFunc   ;==>CheckifLoginBroker

 

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...