Jump to content

Recommended Posts

  • 5 months later...
  • Replies 167
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Chrome support for AutoIT is here!  This UDF includes a Chrome Extension (http://developer.chrome.com/extensions/getstarted.html) and Native Messaging Host (http://developer.chrome.com/extensions/m

Hmmm, odd that something is uploading.  There certainly isn't anything in this solution that uploads or downloads. Here's a description of exactly what the 3 components to the UDF do (in case anyone

Yes, it might seem odd that the registry value is escaped, though it must be this way or the native messaging host won't start.  That's my experience. Here's more information to help in troubleshoot

Posted Images

  • 5 months later...

Hi

i am using Google Chrome Version 80.0.3987.162 (Official Build) (64-bit)

i loaded 

 

image.png.a42937731182ac6a61c6286d2fc8750a.png
AutoIT for Google Chrome
1.0
 
ID: leakmpklghcpopcfgkkjjfhmlkhocjlj
Inspect viewsbackground page
 
Enabled checkbox next to AutoIT for Google Chrome is checked Also make sure the Allow access to file URLs box is checked
and

DOWNLOAD :

Latest Version - v0.5 (29/09/13)

Chrome.au3

when i run example

chrome_example.au3 and chrome_example_2.au3

i work but no result on ConsoleWrite nothing at all.

Can any one help?

image.thumb.png.960a1f8eea34faa624004c978c1faab3.png

Link to post
Share on other sites
On 4/2/2020 at 9:54 AM, samibb said:

i am using Google Chrome Version 80.0.3987.162 (Official Build) (64-bit)

...

when i run example

chrome_example.au3 and chrome_example_2.au3

i work but no result on ConsoleWrite nothing at all.

Can any one help?

 

has the issue been resolved?

so scripts filled out all the input into chrome page okay but you see nothing in SciTE debugging window?

chrome_example.au3 - submission page is broken ( 505 Error ) therefore is no return 'Thank You' Page to retrieve info so you should see error output like these.

_ChromeObjGetHTMLByTagName("h1") = Cannot read property 'innerHTML' of undefined
_ChromeObjGetHTMLByTagName("p", 1) = Cannot read property 'innerHTML' of undefined
_ChromeObjGetHTMLByTagName("p", 2) = Cannot read property 'innerHTML' of undefined
_ChromeObjGetHTMLByTagName("p", 3) = Cannot read property 'innerHTML' of undefined
_ChromeObjGetHTMLByTagName("p", 4) = Cannot read property 'innerHTML' of undefined
_ChromeObjGetHTMLByTagName("p", 5) = Cannot read property 'innerHTML' of undefined
_ChromeObjGetHTMLByTagName("p", 6) = Cannot read property 'innerHTML' of undefined
_ChromeObjGetHTMLByTagName("p", 7) = Cannot read property 'innerHTML' of undefined
_ChromeObjGetHTMLByTagName("p", 8) = Cannot read property 'innerHTML' of undefined
_ChromeObjGetHTMLByTagName("p", 9) = Cannot read property 'innerHTML' of undefined

 

chrome_example_2.au3 - since this is offline page and it doesn't submit anything it tries to retreive the info that random generated like so.

_ChromeObjGetPropertyByName("ExampleForm", "method") = post
_ChromeObjGetValueByName("hiddenExample") = secret value
_ChromeObjSetValueByName("textExample", _RandomText(10)) = FZFMHWHAHN
_ChromeObjGetValueByName("textExample") = FZFMHWHAHN
_ChromeObjSetValueByName("passwordExample", _RandomText(10)) = YNHBZQBMIU
_ChromeObjGetValueByName("passwordExample") = YNHBZQBMIU
_ChromeObjGetPropertyByName("fileExample", "type") = file
_ChromeObjGetPropertyByName("imageExample", "src") = http://www.autoitscript.com/images/autoit_6_240x100.jpg
_ChromeObjGetHTMLById("messages") = Form Submitted!<br>
_ChromeObjSetValueByName("textareaExample", _RandomText(10)) = FFXBTBRTZU
_ChromeObjGetValueByName("textareaExample") = FFXBTBRTZU
_ChromeObjGetPropertyByName("checkboxG1Example", "checked") = true
_ChromeObjGetPropertyByName("checkboxG2Example", "checked") = false
_ChromeObjGetPropertyByName("radioExample", "checked", 0) = true
_ChromeObjGetPropertyByName("selectExample", "selectedIndex") = 1
_ChromeObjGetPropertyByName("multipleSelectExample", "selectedIndex") = 1
_ChromeObjGetHTMLById("messages") = Form Submitted!<br>Form Submitted!<br>

 

Link to post
Share on other sites

Just case someone is wondering whether I edited the output.

changes were made in Chrome.au3 functions. Because $response returns as '{"text":"some string"}', regex was used to return just 'some string'

;~ modified from
    return $response

;~ to
    return StringRegExpReplace($response, '\{\".+\":\"(.+)\"\}$', '$1')

 

As pointed out earlier, function _ChromeDocWaitForReadyStateCompleted() fails and exit on timeout, culprit is StringCompare() fails  at least on my end win8os/autoit 3.3.14.5

;~ fixed from
     Until @error > 0 Or StringLen($response) = 0 or StringCompare($response, "complete") = 0

;~to
    Until @error > 0 Or StringLen($response) = 0 or StringCompare($response, '{"text":"complete"}') = 0

 

Link to post
Share on other sites
Quote

...StringCompare() fails  at least on my end...

on the topic of Chrome.au3, i'm wondering what's this function returns back in 2013 but StringCompare() in 2020 returns exact string match with option of case-sensitivities .

Suggest to modify all StringCompare() to example showed above or switch to StringInStr() or StringRegExp() in place of it. (note: the check statement required attention as return for each suggested function is different)

Link to post
Share on other sites

thank you for previous notes, and it is working for normal pages

>>>> Window INFO <<<<
Title:    Chrome UDF - Page 7 - AutoIt Example Scripts - AutoIt Forums - Google Chrome
Class:    Chrome_WidgetWin_1
Position:    -8, -8
Size:    1936, 1056
Style:    0x17CF0000
ExStyle:    0x00000100
Handle:    0x00000000004D06EC

>>>> Control <<<<
Class:    Chrome_RenderWidgetHostHWND
Instance:    1
ClassnameNN:    Chrome_RenderWidgetHostHWND1
Name:    
Advanced (Class):    [CLASS:Chrome_RenderWidgetHostHWND; INSTANCE:1]
ID:    890826400
Text:    Chrome Legacy Window
Position:    0, 111
Size:    1920, 937
ControlClick Coords:    308, 318
Style:    0x56300000
ExStyle:    0x00000020
Handle:    0x0000000000150636

>>>> Mouse <<<<
Position:    316, 429
Cursor ID:    0
Color:    0xFAFAFA

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Chrome Legacy Window


>>>> Hidden Text <<<<
Chrome Legacy Window

but not working with this page 

PRD(PRODUCTION) - Google Chrome

 

 

Link to post
Share on other sites

 

Quote

...it is working for normal pages ... but not working with this page

Could you be more specific? What is a normal pages and what is this page? how is the window info you provided relevant?

So you get the examples provided working? are these the 'normal pages' you referring to?

 

Link to post
Share on other sites

1- dose autoit work with VPN web sit? 

2-this page come via VPN

3- by the way i used ID

4- all objects with no name only ID and chrome functions are by name is there more function using ID instead of names.

5- is there new update for AutoIt working with chrome because microsoft not supporteing  Explorer  any more.

please my brain will blow 

 

image.thumb.png.50380212a810bada1a3ec1dece9a22ab.png

image.thumb.png.f8449196dbf3dc5c0394039605974fca.pngimage.thumb.png.5664bbf166dd2f8c86876ae6161ec053.png

Edited by samibb
Link to post
Share on other sites
Quote

4- all objects with no name only ID and chrome functions are by name is there more function using ID instead of names.

All functions in  Chrome.au3 are just wrappers, you can create your own functions. It uses Javascript. Just open  up Chrome.au3 look through a few of existing functions then you will quickly realized that  _ChromeEval() is your friend. 

Here is quick example to get you started. 2 new functions created bellow to get and set value by id: _ChromeObjSetValueById('id', 'string') &  _ChromeObjGetValueById('id') you can copy and paste them to  Chrome.au3

#include <Chrome.au3>

; -----------------------
; test site: www.bing.com
; -----------------------

_ChromeStartup('http://bing.com')
_ChromeDocWaitForReadyStateCompleted()


Local $currTabTitle = 'Bing'
_ChromeDocWaitForExistenceByTitle($currTabTitle) 
Local $IsNotActive = @error
ConsoleWrite(($IsNotActive = 0) ? $IsNotActive &" - SUCCESS! Found: "& $currTabTitle&@CRLF : $IsNotActive &" - FAILED! NOT Found: "& $currTabTitle&@CRLF)

If $IsNotActive Then
    MsgBox(0, $IsNotActive&' | Title Status', 'Not Found: '&$currTabTitle)
Else

  $_IsPageReady = _ChromeDocWaitForReadyStateCompleted()
  If $_IsPageReady Then 
    MsgBox(0, $IsNotActive&' | Page Status: '&$_IsPageReady, 'success, ok to get html')

    $_SearchInput = _ChromeObjGetHTMLById('sb_form')
    MsgBox(0, 'id=sb_form', $_SearchInput)
    
    _ChromeObjSetValueById('sb_form_q', 'samibb string')
    $_SearchInput = _ChromeObjGetValueById('sb_form_q')
    MsgBox(0, 'id=sb_form_q', $_SearchInput)

  Else
    MsgBox(0, $IsNotActive&' | Page Status: '&$_IsPageReady, 'try again, failed to load page')
  EndIf
  
EndIf
Exit

; ========================================================================================
; ========================================================================================
Func _ChromeObjSetValueById($objId, $value, $timeout = 5)

    dim $response = ""

    if StringLen($value) < 1 Then $value = "Missing $value"

    $response = _ChromeEval("document.getElementById('" & $objId & "').value = '" & $value & "';", $timeout)

    SetError(@error)

    return StringRegExpReplace($response, '\{\".+\":\"(.+)\"\}$', '$1')
EndFunc

; ========================================================================================
; ========================================================================================
Func _ChromeObjGetValueById($objid, $timeout = 5)

    dim $response = ""

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

    return StringRegExpReplace($response, '\{\".+\":\"(.+)\"\}$', '$1')
EndFunc

 

Quote

5- is there new update for AutoIt working with chrome because microsoft not supporteing  Explorer  any more.

If you are referring to other UDFs then you might also want to look into UIAutomation and WebDriver. 

 

Link to post
Share on other sites
_ChromeObjGetHTMLById  this function working 

_ChromeObjSetValueById    Not working

_ChromeObjSetValueById('tbxTktNumberId', '065')  not working  .  

the obj is in table.

any ideas  please

 

image.png

Link to post
Share on other sites

as pointed out earlier. here is the javascript HTML DOM document that you can use to create your own functions if needs be. https://www.w3schools.com/js/js_htmldom_elements.asp

test and check what works for you

Local $objId = 'idName'
Local $index = 0                ;<--the order of id that it in, if multiple ids present
Local $value = 'new string'
Local $timeout = 5              ;<--in second


_ChromeDocWaitForReadyStateCompleted()
;try this
_ChromeEval("document.getElementsById('" & $objId & "')[" &$index& "].value = '" & $value & "';", $timeout)        ;<---multiple ids present
;if it doesn't work try this
_ChromeEval("document.getElementsById('" & $objId & "')[" &$index& "].innerHTML = '" & $value & "';", $timeout)    ;<---multiple ids present

;OR

_ChromeDocWaitForReadyStateCompleted()
;try this
_ChromeEval("document.getElementById('" & $objId & "').value = '" & $value & "';", $timeout)        ;<--only one unique id present
;if it doesn't work try this
_ChromeEval("document.getElementById('" & $objId & "').innerHTML = '" & $value & "';", $timeout)    ;<--only one unique id present


;if everything failed, then try other Javascript HTML DOM Methods from document above
Method Description
document.getElementById(id) Find an element by element id
document.getElementsByTagName(name) Find elements by tag name
document.getElementsByClassName(name) Find elements by class name

ect..

Link to post
Share on other sites

update: hope you can spot the different between .value and .innerHTML

#include <Chrome.au3>

; -----------------------
; test #1 site: www.bing.com
; -----------------------
;~ $testSite = 'bing'
;~ Local $currTabTitle = 'Bing'    ;bing.com
;~ _ChromeStartup('http://bing.com')


; -----------------------
; test #2 site: vpn.saudia.com
; -----------------------
$testSite = 'saudia'
Local $currTabTitle = 'Welcome to SSL VPN' ;vpn.saudia.com
_ChromeStartup('https://vpn.saudia.com/')



_ChromeDocWaitForReadyStateCompleted(30)
_ChromeDocWaitForExistenceByTitle($currTabTitle) 
Local $IsNotActive = @error
ConsoleWrite(($IsNotActive = 0) ? $IsNotActive &" - SUCCESS! Found: "& $currTabTitle&@CRLF : $IsNotActive &" - FAILED! NOT Found: "& $currTabTitle&@CRLF)

If $IsNotActive Then
    MsgBox(0, $IsNotActive&' | Title Status', 'Not Found: '&$currTabTitle)
Else

  $_IsPageReady = _ChromeDocWaitForReadyStateCompleted()
  If $_IsPageReady Then 
    MsgBox(0, $IsNotActive&' | Page Status: '&$_IsPageReady, 'success, ok to get/set html')


    
    ; -----------------------
    ; test #1 site: www.bing.com
    ; -----------------------
    If $testSite == 'bing' Then 
      $_innerHtml = _ChromeObjGetHTMLById('sb_form')              ;This works (innerHTML)
      MsgBox(0, 'innerHTML | id=sb_form', $_innerHtml)

      _ChromeObjSetValueById('sb_form_q', 'samibb string')
      Sleep(500)
      _ChromeDocWaitForReadyStateCompleted(30)
      
      $_value = _ChromeObjGetValueById('sb_form_q')               ;This works (value) <--see and compare vpn.saudia.com example bellow
      MsgBox(0, 'value | id=sb_form_q', $_value)
      
      $_innerHTML = _ChromeObjGetHTMLById('sb_form_q')            ;But this is NOT working (innerHTML)
      MsgBox(0, 'innerHTML | id=sb_form_q', $_innerHTML)
    EndIf

    ; -----------------------
    ; test #2 site: vpn.saudia.com
    ; -----------------------
    If $testSite == 'saudia' Then 
      _ChromeObjSetValueById('username', 'samibb')
      _ChromeObjSetValueById('credential', 'samibbpassword')
      _ChromeInputClickByName("login_button")
      ;_ChromeInputClickById("login_button") 
      ;_ChromeInputClickByType("button")
      Sleep(500)
      _ChromeDocWaitForReadyStateCompleted(30)
      
      $loginStatus_value = _ChromeObjGetValueById('err_val')           ;This is NOT working (value) 
      MsgBox(0, 'value | id=err_val', $loginStatus_value)
      
      $loginStatus_innerHTML = _ChromeObjGetHTMLById('err_val')        ;but this works (innerHTML) <---see and compare bing.com example above
      MsgBox(0, 'innerHTML | id=err_val', $loginStatus_innerHTML)
    EndIf
    
    
  Else
    MsgBox(0, $IsNotActive&' | Page Status: '&$_IsPageReady, 'try again, failed to load page')
  EndIf
  
EndIf
Exit

; ========================================================================================
; ========================================================================================
Func _ChromeObjSetValueById($objId, $value, $timeout = 5)

    dim $response = ""

    if StringLen($value) < 1 Then $value = "Missing $value"

    $response = _ChromeEval("document.getElementById('" & $objId & "').value = '" & $value & "';", $timeout)

    SetError(@error)

    return StringRegExpReplace($response, '\{\".+\":\"(.+)\"\}$', '$1')
EndFunc

; ========================================================================================
; ========================================================================================
Func _ChromeObjGetValueById($objid, $timeout = 5)

    dim $response = ""

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

    return StringRegExpReplace($response, '\{\".+\":\"(.+)\"\}$', '$1')
EndFunc

; ========================================================================================
; ========================================================================================
Func _ChromeInputClickById($objid, $index = 0, $timeout = 5)

    dim $response = ""

;~     $response = _ChromeEval("document.getElementsById('" & $objid & "')[" & $index & "].click();", $timeout)      ;if multiple input present
    $response = _ChromeEval("document.getElementById('" & $objid & "').click();", $timeout)                       ; if only 1 input present

    SetError(@error)

    return StringRegExpReplace($response, '\{\".+\":\"(.+)\"\}$', '$1')
EndFunc

 

Edited by zeenmakr
Link to post
Share on other sites
  • 1 month later...
  • 2 months later...
On 4/2/2019 at 11:05 PM, yeisson said:

Hi!

Currently I have Windows 10, version 1809,  I'm also running Chrome version 73.0.3683.86 and work correctly by only ensuring that after installing "autoit_chrome_native_messaging_host_install" and have the correct id of the Chrome extension to be used in the manifest file:

😄 \ Users \ <User> \ AppData \ Roaming \ AutoIt3 \ Chrome Native Messaging Host \ manifest.json

"allowed_origins": [

    "chrome-extension://leakmpklghcpopcfgkkjjfhmlkhocjlj/"

  ]

To know your extension id you must enable the developer mode and it immediately appears, after that you update the manifest and everything will work fine.

I hope it helps, greetings.

its work after do the change  my win 10 pro thx alot 

Link to post
Share on other sites
  • Developers
7 minutes ago, Iraj said:

Its not working for https based websites. Can someone help?

Care to share all information that would be required to help you with that?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By goku200
      I am trying to change the settings of the print option to Save as PDF and its not changing the settings and clicking on the Save button at the bottom. Here is my script that I have written and the format is correct below. Chrome browser I'm using is 97.0 My script was working fine using Chrome 95.0\ Not sure why its not working now
      It finds the print-preview-app element but not the others.
       
    • By goku200
      I am trying to hit the Return key without having to use the Send keys. I have the following code and its not hitting the Return key. Am I missing something?
      ; Press Return $sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE006"},' ; Pause $sAction &= '{"type": "pause", "duration": 500},' ; Release Return $sAction &= '{"type": "keyUp", "value": "\uE006"}]}]}' _WD_Action($sSession, "actions", $sAction)  
    • By goku200
      I'm having some issues with my script that's not grabbing the id from the cell and appending it to the url test that I have in my script.
      Here is my script:
      What I'm having issues is looping through the id column in the excel spreadsheet and adding 1 to the url address when its tabbed by using _WD_NewTab. When it goes to the browser I'm wanting it to display: https://127.0.0.1/test.html?id=1 press Enter and save the file as 1.html and so forth for the others. Not sure what I'm doing wrong here. 
       
    • By SkysLastChance
      How should I be attempting to click this link?

      <span id="x2m8_R-s" class="s_22 s-text">Walk&nbsp;In</span> If I double click the Walk$nbsp;In the text reads Walk In.

      How can I search for this text? 
      I have tried a several  different ways with no luck. Here are a few;
      $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//span[text()="Walk${nbsp}In"]') $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[translate(text(), '\u00a0', ' ') = 'Walk In']") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[contains(text(),'Walk In')]") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[contains(text(),'Walk&nbsp;In')]") Any help is appreciated as always. 
       
       
       
    • By mLipok
      wd_capabilities.au3 UDF was changed/modified/refactored .... and commited/merged (02-12-2021) to https://github.com/Danp2/WebDriver

      WARNING: Before you start using this UDF be sure you download the recent version from: https://github.com/Danp2/WebDriver
       
      ==================================================================================================

      Recently I start wd_capabilities.au3 project on my side.
      I think this is time to share to AutoIt community.
      Check attached UDF: wd_capabilities.au3

      Here is a scratch example showing how to use them:
      #include "wd_helper.au3" #include "wd_capabilities.au3" _Example() Func _Example() ........ ........ ........ _WD_Capabilities_Build_Arguments(Null) ; CLEANUP ARGS _WD_Capabilities_Build_Arguments('--headless') _WD_Capabilities_Build_Arguments('start-maximized') _WD_Capabilities_Build_Arguments('disable-infobars') _WD_Capabilities_Build_Arguments('user-data-dir', 'C:\Users\' & @UserName & '\AppData\Local\Google\Chrome\User Data\Default') Local $s_WD_Capabilities_Arguments = _WD_Capabilities_Build_Arguments(Default) ; GET ARGS _WD_Capabilities_Build_Preferences(Null) ; CLEANUP PREFS If $s_Download_dir Then _WD_Capabilities_Build_Preferences('download.default_directory', $s_Download_dir) Local $s_WD_Capabilities_Preferences = _WD_Capabilities_Build_Preferences(Default) ; GET PREFS Local $s_Desired_Capabilities = _WD_Capabilities_Build_JSON('chrome', $s_WD_Capabilities_Arguments, $s_WD_Capabilities_Preferences) Local $WD_SESSION = _WD_CreateSession($s_Desired_Capabilities) ........ ........ ........ EndFunc  
      I plan to publish the code on GitHub.
      In the indefinite future, when the project becomes more functional, if @Danp2 accepts it, I hope it may be included in the main WebDriver UDF.

      I am waiting for yours feedback and help in the further development of this project.

      REMARK 1:
      As so far this UDF only supports GoogleChrome.
      Adding support for other browsers shouldn't be difficult, I just didn't need to.

      REMARK 2:
      For now, this project is working but still as a early BETA, so please do not discuss, ask questions, or post examples or snippets of code that pertain to any function of this UDF in other part of this forum, until it is found acceptable. Simply: discusion and tests only here in this topic.


      Regards,
      @mLipok
       
×
×
  • Create New...