Jump to content

Clicking on a id button in Chrome- help


coolooc
 Share

Recommended Posts

Hi, I need some help :bye:

I am trying to using:  #Include <Chrome.au3> in order to clicking on button from HTML page by id (id="open-job-dialog-button") in Chrome browser.

In Internet explorer its work with the code:

$oBtn = _IEGetObjById($oIE,$IdButton)
 _IEAction($oBtn, "click")

 

The code I write is:

#Include <Chrome.au3>

local $oBtn2 =_ChromeObjGetHTMLById("open-job-dialog-button")

    If @error then
     msgbox(0,"error to get the object by html id",$obtn2)
    Else
     msgbox(0,"sucess to get the object by html id",$oBtn2)
    EndIf

I am getting a message with: {"text";"error"} that mean the variable $obtn2 include error value replace to getting some object.

In addition I search some function to clcik on the object I suppose to click on Chrome.

Please if someone know or worked with this and can help :(
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#Include <Chrome.au3> include this relavant code:

Func _ChromeObjGetHTMLById($objid, $timeout = 5)

    dim $response = ""

    $response = _ChromeEval("document.getElementById('" & $objid & "').innerHTML;", $timeout)

    return $response
EndFunc

Func _ChromeEval($javascript_expression, $timeout = 5)

    Dim $response = ""

    if WinExists("[REGEXPTITLE:.*- Google Chrome]") Then

        FileDelete($chrome_native_messaging_host_dir & "input.txt")
        FileWrite($chrome_native_messaging_host_dir & "input.txt", $javascript_expression)

        $begin = TimerInit()

        While TimerDiff($begin) < ($timeout * 1000)

             If FileExists($chrome_native_messaging_host_dir & "output.txt") then ExitLoop
             sleep(100)
        WEnd

        If FileExists($chrome_native_messaging_host_dir & "output.txt") then

            $response = FileRead($chrome_native_messaging_host_dir & "output.txt")
            FileDelete($chrome_native_messaging_host_dir & "output.txt")
        Else

            SetError(2)
        EndIf
    Else

        SetError(1)
    EndIf

    Return $response

EndFunc

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