Jump to content

WebDriver UDF - Help & Support

Recommended Posts

11 minutes ago, Danp2 said:

@BigDaddyO See prior discussion starting here --

I think My issue may be unique.  When inspecting the dropdown select box before selecting it, I see all the options.  but when I attempt to select one of those I get a message about not attached to the document.

I got around this by finding and clicking the dropdown select box, then doing the full find again and then clicking the option I want.

$eHIPPAtype = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//select[contains(@id,'callerTypeOptions') and not(contains(@id, 'callerTypeOptions1')) and contains(@class, 'callerTypeOptions')]")    ;Perform additional search for the field
_WD_ElementAction($sSession, $eHIPPAtype, "click")  ;Click the dropdown to get the list
$eHIPPAtypeMbr = _WD_FindElement($sSession,  $_WD_LOCATOR_ByXPath, "//select[contains(@id,'callerTypeOptions') and not(contains(@id, 'callerTypeOptions1')) and contains(@class, 'callerTypeOptions')]/option[contains(@value, 'Member')][1]")  ;find the first object that contains Member
_WD_ElementAction($sSession, $eHIPPAtypeMbr, "click") ;Click the item we want from the list


hmm... I guess I have to have a signature...

Share this post

Link to post
Share on other sites

Hi Danp2

I want before Navigate browser set my proxy ( ngocthang1.vpn.co:8899:ngocthang26:ngocthang26 ) and add ABP extension, I see you suggest 2 link for everyone
+ http://chromedriver.chromium.org/capabilities

+ http://chromedriver.chromium.org/extensions

But i don't know transfer to DesiredCapabilities, How do set proxy ? sorry i very bad code.

#include "wd_core.au3"
#include "wd_helper.au3"
Local $sDesiredCapabilities

$_WD_DEBUG = False

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}'

$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://www.google.com/")
_WD_Window($sSession, 'maximize','')
;~ $hwnd = WinWaitActive("Google")
;~ WinSetState($hwnd, "", @SW_MAXIMIZE)
_WD_Action($sSession, "refresh")

Func SetupChrome()
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path=' & @ScriptDir & '\chrome.log')

Thanks you

Share this post

Link to post
Share on other sites

Hi @ngocthang26

I haven't personally had the need to do either of these actions, so I can't tell you exactly how to do this. If I get a chance, I'll try to check this out and report back with any findings.

In the mean time, you'll need to do what I would do in this case, which is to research and then use "trial and error" until you find a working scenario. The proxy subject came up once before in the main development thread. You may want to check out the links posted by @mLipok here.


Share this post

Link to post
Share on other sites

Hi @Danp2 I try very many code but don't set success Proxy.

$sDesiredCapabilities = '{"capabilities":{"chromeOptions": {"w3c": "true","browserName": "chrome", "args": ["disable-web-security"], "proxy": {"proxyType":"manual","httpProxy":"","sslProxy":"","autodetect": "false"}}}}'

You can try help me, i try link you sent but don't know transfer code.



Share this post

Link to post
Share on other sites

@ngocthang26 Have you tried it like this? Note that the proxy definition is outside of chromeOptions.

$sDesiredCapabilities = '{"capabilities":{"chromeOptions": {"w3c": "true"},"browserName": "chrome", "args": ["disable-web-security"], "proxy": {"proxyType":"manual","httpProxy":"","sslProxy":"","autodetect": "false"}}}'

Also, is that your actual IP address for the proxy or just something you pulled off the internet?

Share this post

Link to post
Share on other sites

DemoActions() part ... i didnt try anything :c im just trying to learn how to send keystrokes :c can you give me a code that send keystrokes to the active  element also im using both google chrome and firefox


Edited by Shogi

Share this post

Link to post
Share on other sites

i found how to send keystrokes ;) 

edit: it worked with geckodriver but didnt work with chromedriver :( chromedriver is so broken and full of bugs :c 


Edited by Shogi

Share this post

Link to post
Share on other sites

I'm going to be running an automation as a Citrix Published app but I'm having all sorts of problems since each user is technically launching the same chromedriver.exe from a single box.

It seems to lock the .log files, so I switched that so it creates @UserName & ".log" but I also seem to be having a problem where each instance needs to use it's own port# but chromedriver doesn't seem to launch on anything but the 9515.

if I try any other port, the black window shows up but the website doesn't appear.  Again, I'm using my simple script for testing.

any ideas?

#include "wd_core.au3"
#include "wd_helper.au3"
;~ "explicitly-allowed-ports":9510,9511,9512.9513  ;comma seperated list of port number, port seems to be specified prior to the _WD_CreateSession so this isnt used.

FileInstall("Chromedriver.exe", @ScriptDir & "\Chromedriver.exe")
For $i = 1 to 30
    If FileExists(@ScriptDir & "\Chromedriver.exe") Then ExitLoop

$sWebSite = "https://www.autoitscript.com/site/autoit/downloads/"
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "useAutomationExtension": false, "args":["start-maximized", "disable-infobars"] }}}}' ;Required to prevent Unpacked Extension error on servers


$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Timeouts($sSession, '{"type":"page load","ms":120000}')     ;Increase the default timeout.

_WD_Navigate($sSession, $sWebSite)

If _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//div/table[1]/tbody/tr/td[2]", 1000, 20000, True) <> 1 Then
    ConsoleWrite("Error, Item not found" & @CRLF)

$eDate = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div/table[1]/tbody/tr/td[2]")
$sDate = _WD_ElementAction($sSession, $eDate, "text")

MsgBox(0, "Date", "Date = " & $sDate & ".  Click OK to Exit")

_WD_DeleteSession($sSession)                        ;Close the chrome window
_WD_Shutdown()                                          ;Close the chromedriver.exe command window

Func _SetupChrome()

    If _WD_Option('Driver', 'chromedriver.exe') = 0 Then Return SetError(1)

;~  $iPort = _StartScan()
;~  If @error Then
;~      MsgBox(0, "Error", "Unable to find an open port")
;~      Exit
;~  EndIf
;~  If _WD_Option('Port', $iPort) = 0 Then Return SetError(1)   ;only 9515 is working, but this scanner doesnt see it as available!

    If _WD_Option('Port', 9510) = 0 Then Return SetError(1) ;only 9515 is working!

    If _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\' & @UserName & '.log"') = 0 Then Return SetError(1)

EndFunc   ;==>_SetupChrome

;Find Open Port, not sure if this will work for the port chromedriver wants
Func _StartScan($sIPScan = "", $sPortStart = 9100, $sPortEnd = 65353)
    Opt('TCPTimeout', 50)       ;Set the timeout for the Port connection
    Local $sSoketID
    Local $sTimeStart = TimerInit()
    For $p = $sPortStart To $sPortEnd
        ConsoleWrite("Scanning Port: " & $p  & @CRLF)
        $sSoketID = TCPConnect($sIPScan, $p)
        If $sSoketID > 0 Then
            ConsoleWrite("Found an open port ( " & $p & " )" & @CRLF)

    If $p >= $sPortEnd Then
        Return SetError(1)
        Return $sPortStart

EndFunc   ;==>_StartScan




hmm... I guess I have to have a signature...

Share this post

Link to post
Share on other sites
6 minutes ago, Shogi said:

how to enable adobe flash in firefox ?! 

I seriously doubt that anyone here knows how to do that without doing further research. You can't expect to come here and have someone spoon feed the answers to you.

What have you tried? What research have you done?

Share this post

Link to post
Share on other sites

thank you :) also why i cant send keyboard and pointer actions to google chrome using chromedriver?! i used this script to test 

#include <wd_core.au3>
#include <wd_helper.au3>
#include <Misc.au3>

$hDLL = DllOpen("user32.dll")

_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}'

$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "http://google.com")

while 1
    if _IsPressed("73", $hDLL) then 
    _WD_Action($sSession, "actions", '{"actions": [{"type": "key","id": "keyboard","actions": [{"type": "KeyDown", "value": "a"},{"type": "sleep", "duration": 5},{"type": "Keyup", "value": "a"}]}]}')


__WD_Post: StatusCode=404; ResponseText={"value":{"error":"unknown command","message":"(Session infochrome=69.0.3497.100)","stacktrace":"Backtrace:\n\tOrdinal0 [0x009EAA90+830096]\n\tOrdinal0 [0x0099581D+481309]\n\tOrdinal0 [0x0096A9F1+305649]\n\tOrdinal0 [0x009500D0+196816]\n\tOrdinal0 [0x0094AA77+174711]\n\tOrdinal0 [0x00932D54+77140]\n\tOrdinal0 [0x0093430C+82700]\n\tOrdinal0 [0x00934260+82528]\n\tOrdinal0 [0x009F5302+873218]\n\tOrdinal0 [0x009A0553+525651]\n\tOrdinal0 [0x009A0783+526211]\n\tOrdinal0 [0x009A086C+526444]\n\tOrdinal0 [0x009F83A7+885671]\n\tOrdinal0 [0x009A03BF+525247]\n\tOrdinal0 [0x009AA60E+566798]\n\tOrdinal0 [0x009B5DDB+613851]\n\tOrdinal0 [0x009B5F45+614213]\n\tOrdinal0 [0x009B5175+610677]\n\tBaseThreadInitThunk [0x76318484+36]\n\tRtlValidSecurityDescriptor [0x77AD305A+282]\n\tRtlValidSecurityDescriptor [0x77AD302A+234]\n"}}
_WD_Action: {"value":{"error":"unknown command","message":"(Session infochrome=69.0.3497.100)","stacktrace":"Backtrace:\n\tOrdinal0 [0x009EAA90+830096]\n\tOrdinal0 [0x0099581D+481309]\n\tOrdinal0 [0x0096A9F1+305649]\n\tOrdinal0 [0x009500D0+196816]\n\tOrdinal0 [0x0094AA77+174711]\n\tOrdinal0 [0x00932D54+77140]\n\tOrdinal0 [0x0093430C+82700]\n\tOrdinal0 [0x00934260+82528]\n\tOrdinal0 [0x009F5302+873218]\n\tOrdinal0 [0x009A0553+525651]\n\tOrdinal0 [0x009A0783+526211]\n\tOrdinal0 [0x009A086C+526444]\n\tOrdinal0 [0x009F83A7+885671]\n\tOrdinal0 [0x009A03BF+525247]\n\tOrdinal0 [0x009AA60E+566798]\n\tOrdinal0 [0x009B5DDB+613851]\n\tOrdinal0 [0x009B5F45+614213]\n\tOrdinal0 [0x009B5175+610677]\n\tBaseThreadInitThunk [0x76318484+36]\n\tRtlValidSecurityDescriptor [0x77AD305A+282]\n\tRtlValidSecurityDescriptor [0x77AD302A+234]\n"}}
Edited by Shogi

Share this post

Link to post
Share on other sites
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Danp2
      This UDF will allow you to interact with any browser that supports the W3C WebDriver specifications. Supporting multiple browsers via the same code base is now possible with just a few configuration settings.
      JSON UDF https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn
      WinHTTP UDF https://www.autoitscript.com/forum/topic/84133-winhttp-functions/
      HtmlTable2Array UDF (optional) https://www.autoitscript.com/forum/topic/167679-read-data-from-html-tables-from-raw-html-source/
      WebDriver for desired browser
      Chrome WebDriver https://sites.google.com/a/chromium.org/chromedriver/downloads FireFox WebDriver https://github.com/mozilla/geckodriver/releases Edge WebDriver https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ Source Code
      You will always be able to find the latest version in the GitHub Repo 
      Help / Support
      See the wiki for details on the UDF --
      Please post any questions, suggestions or errors in the GH&S thread.
    • By Jgladden
      Dan - thanks for all that you do - this stuff is great. 
      Hoping you can assist with an issue we are having now that we have moved to Windows 10/Server 2016. The Chrome interactions were working flawlessly until moving over. Now my code fails when attempting to create the session. As you can see, our Chrome install is not in a standard location but I have validated the path to the binary. I have attached some detail below including system info, console output and the chrome log detail. I have tried several recommendations that have seen in various forums but none have made a difference
      Any assistance you can give would be greatly appreciated. 
      Thanks in advance, 
    • By Langmeister
      I am once again asking for your experienced assistance. If I open a website that uses notifications I am asked to allow or block them for that website after a few seconds. This notification pops up every time the page gets navigated to, even tho you have clicked on allow for several times. I am explicitly not searching for smth to get rid of "Chrome is being controlled by automated test sw". Instead I am searching for a line of script to disable all notifications by default: like here chrome://settings/content/notifications. 
      This is code should give you an example of what notifications I am talking about:
      #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession, $sID _WD_Option("Driver", "C:\Program Files (x86)\AutoIt3\chromedriver.exe") _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://webradio.planetradio.de/") _WD_LoadWait($sSession)  
    • By Langmeister
      Hi, I'm sure that this is a simple question regarding webdriver udf but my search on the forum did not result in the exact same scenario that I need. I will adapt it to my corporate needs but at first I want it to work with an example everybody can reproduce if needed.
      I navigate to https://www.daysoftheyear.com/ and want to find out what special day today is. Using the following Code returns the wanted text that today is 'shark awareness day' in the console but it is not pasted in notepad as it is not copied as it probably should be.
      #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession, $sID _WD_Option("Driver", "C:\Program Files (x86)\AutoIt3\chromedriver.exe") _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.daysoftheyear.com/?timezone_offset=nan") _WD_LoadWait($sSession) Sleep(3000) Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div[2]/header/div/div[1]/div/div[2]/h3/a") _WD_ElementAction($sSession, $sElement, 'text') ClipGet() Run("notepad.exe") Sleep(500) Send("^v") Scite returns this, therefore the text has been found but the last mile to paste it to notepad or excel does not work for me.
      __WD_Get: URL=HTTP:// __WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"Shark Awareness Day"}... _WD_ElementAction: {"value":"Shark Awareness Day"}... Thanks in advance! 
    • By Langmeister
      Hi, I need help performing actions in Salesforce using IE. I used to complete tasks via MouseMove/MouseClick etc. on the Chrome application of SF, but unfortunately this only works for me and not my colleagues due to different positions of things etc. Being unable to get Webdriver UDF or Chromedriver running to interact with the code directly, I chose to look into the IE UDF. ATM I'm trying to tick a specific checkbox in SF which simply allows me to "select all checkboxes" at the same time. Applying the following code on a random website with checkboxes works just fine for me: (in this case selecting cheese checkbox)
      #include <IE.au3> Local $oIE = _IECreate("http://www.echoecho.com/htmlforms09.htm") Local $oSubmit = _IEGetObjByName($oIE, "option3") _IEAction($oSubmit, "click") _IELoadWait($oIE) But applying it to the Salesforce website it does exactly nothing and responds with these warnings/errors:
      The script is exactly the same, except for website and the input name tag of the desired checkbox being different.
      #include <IE.au3> Local $oIE = _IECreate("Corporate Salesforce URL") Local $oSubmit = _IEGetObjByName($oIE, "myPage:myForm:oliListBlock:oliListTable:j_id36") _IEAction($oSubmit, "click") _IELoadWait($oIE) As its working with random websites my guess is that there has to be something done to get it work with SF.
      Hope the more experienced SF+AutoIt pros can help me out here. Thanks in advance!
  • Create New...