Jump to content
Sign in to follow this  

Clicking on a id button in Chrome- help

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)
     msgbox(0,"sucess to get the object by html id",$oBtn2)

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

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

        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")



    Return $response


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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.