Jump to content
Danp2

WebDriver UDF - Help & Support

Recommended Posts

What's with this thread:

 

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

@NguyenLe, this is a continuation of our discussion from the other thread.

 

If you examine the code for _WD_WaitElement, you will see that it just calls _WD_FindElement in a loop. Can you provide a simple example where _WD_FindElement doesn't find an element that is present on the page? Be sure to utilize a website that is accessible to everyone.

Also, it would be interesting to get your perspective on whether this issue could be related to the character encoding.

Share this post


Link to post
Share on other sites

Hi for all!

Sorry for my English)

My task is use this legendary UDF from Danp2 for Opera browser.

Webdriver for Opera: https://github.com/operasoftware/operachromiumdriver/releases

I get code for Chrome. He work beautiful:
 

Spoiler

 


#include "wd_helper.au3"
#include "wd_core.au3"

Local $sDesiredCapabilities

$_WD_DEBUG = True

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

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

$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://www.earnstations.com/")
_WD_WaitElement($sSession,$_WD_LOCATOR_ByXPath,"//a[@class='btn']")
$sElement = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//a[@class='btn']")
_WD_ElementAction($sSession, $sElement, 'click')


 

Then I modify for Opera:
 

Spoiler

 


#include "wd_helper.au3"
#include "wd_core.au3"

Local $sDesiredCapabilities

$_WD_DEBUG = True

_WD_Option('Driver', 'operadriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path=' & @ScriptDir & '\opera.log')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"operaOptions": {"w3c": true }}}}'
_WD_Startup()

$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://www.earnstations.com/")
_WD_WaitElement($sSession,$_WD_LOCATOR_ByXPath,"//a[@class='btn']")
$sElement = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//a[@class='btn']")
_WD_ElementAction($sSession, $sElement, 'click')

 

 

 


 

Error is "session not created exception: Missing or invalid capabilities":
 

Spoiler

 


_WDStartup: OS: WIN_10 WIN32_NT 16299 
_WDStartup: AutoIt: 3.3.14.2
_WDStartup: WD.au3: 0.1.0.9
_WDStartup: Driver: operadriver.exe
_WDStartup: Params: --log-path=E:\AutoIT\WebDriver\opera.log
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"operaOptions": {"w3c": true }}}}
__WD_Post: StatusCode=200; ResponseText={"sessionId":"c913c1a4e33cad552b8a4a4fc0b53794","status":33,"value":{"message":"session not created exception: Missing or invalid capabilities\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
_WD_CreateSession: {"sessionId":"c913c1a4e33cad552b8a4a4fc0b53794","status":33,"value":{"message":"session not created exception: Missing or invalid capabilities\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
_WD_CreateSession ==> Webdriver Exception: session not created exception: Missing or invalid capabilities
  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; $sData={"url":"https://www.earnstations.com/"}
__WD_Post: StatusCode=200; ResponseText={"sessionId":"","status":6,"value":{"message":"no such session\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
_WD_Navigate: {"sessionId":"","status":6,"value":{"message":"no such session\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session//element; $sData={"using":"xpath","value":"//a[@class='btn']"}
__WD_Post: StatusCode=200; ResponseText={"sessionId":"","status":6,"value":{"message":"no such session\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
_WD_FindElement: {"sessionId":"","status":6,"value":{"message":"no such session\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
_WD_WaitElement ==> Success
__WD_Post: URL=HTTP://127.0.0.1:9515/session//element; $sData={"using":"xpath","value":"//a[@class='btn']"}
__WD_Post: StatusCode=200; ResponseText={"sessionId":"","status":6,"value":{"message":"no such session\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
_WD_FindElement: {"sessionId":"","status":6,"value":{"message":"no such session\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session//element/no such session
  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)/click; $sData={"id":"no such session
  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}
"E:\AutoIT\WebDriver\wd_core.au3" (1197) : ==> Subscript used on non-accessible variable.:
Local $hConnect = _WinHttpConnect($hOpen, $aURL[2], $_WD_PORT)
Local $hConnect = _WinHttpConnect($hOpen, $aURL^ ERROR

 

Opera don't launch.

Help please!

 

Share this post


Link to post
Share on other sites

@mrPuh What about the Opera webdriver console? Can you post the output from there?

P.S. Add some error checking to your code. For example --

$sSession = _WD_CreateSession($sDesiredCapabilities)

If @error = $_WD_ERROR_Success Then
    _WD_Navigate($sSession, "https://www.earnstations.com/")
    _WD_WaitElement($sSession,$_WD_LOCATOR_ByXPath,"//a[@class='btn']")
    $sElement = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//a[@class='btn']")
    _WD_ElementAction($sSession, $sElement, 'click')
EndIf

 

Share this post


Link to post
Share on other sites
55 minutes ago, Danp2 said:

@mrPuh What about the Opera webdriver console? Can you post the output from there?

When I launch Chrome webdriver in console this message.

When I launch Opera webdriver in console this message and Opera don't launch.

When I set $sDesiredCapabilities = '{"capabilities": { } }' in AutoIT console this:

 

Spoiler

 

_WDStartup: OS: WIN_10 WIN32_NT 16299 
_WDStartup: AutoIt: 3.3.14.2
_WDStartup: WD.au3: 0.1.0.9
_WDStartup: Driver: operadriver.exe
_WDStartup: Params: --log-path=E:\AutoIT\WebDriver\opera.log
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": { } }
__WD_Post: StatusCode=200; ResponseText={"sessionId":"ec33cd4275f46e9933b25d862d7cd862","status":33,"value":{"message":"session not created exception: Missing or invalid capabilities\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
_WD_CreateSession: {"sessionId":"ec33cd4275f46e9933b25d862d7cd862","status":33,"value":{"message":"session not created exception: Missing or invalid capabilities\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
_WD_CreateSession ==> Webdriver Exception: session not created exception: Missing or invalid capabilities
  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; $sData={"url":"https://www.earnstations.com/"}
__WD_Post: StatusCode=200; ResponseText={"sessionId":"","status":6,"value":{"message":"no such session\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
_WD_Navigate: {"sessionId":"","status":6,"value":{"message":"no such session\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session//element; $sData={"using":"xpath","value":"//a[@class='btn']"}
__WD_Post: StatusCode=200; ResponseText={"sessionId":"","status":6,"value":{"message":"no such session\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
_WD_FindElement: {"sessionId":"","status":6,"value":{"message":"no such session\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
_WD_WaitElement ==> Success
__WD_Post: URL=HTTP://127.0.0.1:9515/session//element; $sData={"using":"xpath","value":"//a[@class='btn']"}
__WD_Post: StatusCode=200; ResponseText={"sessionId":"","status":6,"value":{"message":"no such session\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
_WD_FindElement: {"sessionId":"","status":6,"value":{"message":"no such session\n  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session//element/no such session
  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)/click; $sData={"id":"no such session
  (Driver info: OperaDriver=2.33 (3c26e9df3b0e313077a02a7d6ecab2264700bf10),platform=Windows NT 10.0.16299 x86_64)"}
"E:\AutoIT\WebDriver\wd_core.au3" (1197) : ==> Subscript used on non-accessible variable.:
Local $hConnect = _WinHttpConnect($hOpen, $aURL[2], $_WD_PORT)
Local $hConnect = _WinHttpConnect($hOpen, $aURL^ ERROR

 

 

 

Share this post


Link to post
Share on other sites

This is opera.log:

[0.430][INFO]: COMMAND InitSession {
   "capabilities": {

   }
}
[0.451][INFO]: RESPONSE InitSession session not created exception: Missing or invalid capabilities

Danp2 thanks for you participation to solve my problem.

Share this post


Link to post
Share on other sites
15 minutes ago, mrPuh said:

[0.451][INFO]: RESPONSE InitSession session not created exception: Missing or invalid capabilities

It looks like you will need to keep trying different options until you find a working example.

You may want to review the following links f you haven't already done so --

https://github.com/operasoftware/operachromiumdriver/blob/master/docs/desktop.md

https://sites.google.com/a/chromium.org/chromedriver/capabilities#TOC-List-of-recognized-capabilities

Share this post


Link to post
Share on other sites

I try many variants to set capabilities, but can't find working example.

Who can help solve this problem?

Edited by mrPuh

Share this post


Link to post
Share on other sites

I've downloaded all the necessary files to the necessary directories (I think)

I'm trying to get this to work and think I've got part way there (firefox isn't my default browser)

I'm a little confused about using  _WD_ or _WD  as for example in _WD_Navigate or _WDNavigate  this one seems to work _WDNavigate

I see in wd_core.au3  there is a parameter Global $_WD_DRIVER = "" ; Path to web driver executable 

 

#include "wd_helper.au3"
#include "wd_core.au3"
Global $_WD_DRIVER
Local $sDesiredCapabilities
Local $iIndex
$sCommand ="C:\Program Files (x86)\Mozilla Firefox\"
$_WD_DRIVER = $sCommand & "firefox.exe"

SetupGecko()
_WDStartup()
$sSession = _WDCreateSession($sDesiredCapabilities)
_WDNavigate($sSession, 'http://google.com')
$sElement = _WDFindElement($sSession,$_WD_LOCATOR_ByXPath,"//a[@class='gsfi']")

If @error = $_WD_ERROR_Success Then
    _WDElementAction($sSession, $sElement, 'value','Hello')
EndIf

Func SetupGecko()
_WDOption('Driver', 'C:\Users\PC1\Documents\AutoIt_code\geckodriver.exe')
_WDOption('DriverParams', '--log trace')
_WDOption('Port', 4444)

$sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}'
EndFunc

I'm a little confused about using  _WD_ or _WD  as for example in _WD_Navigate or _WDNavigate  this one seems to work _WDNavigate

The Console gives me:

_WDStartup: OS: WIN_10 WIN32_NT 16299
_WDStartup: AutoIt: 3.3.14.3
_WDStartup: WD.au3: 0.1.0.3
_WDStartup: Driver: C:\Users\PC1\Documents\AutoIt_code\geckodriver.exe
_WDStartup: Params: --log trace
_WDStartup: Port: 4444
__WD_Post: URL=
HTTP://127.0.0.1:4444/session; $sData={"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}
__WD_Post: StatusCode=500; ResponseText={"value":{"error":"session not created","message":"Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line","stacktrace":""}}
__WD_Post ==> Webdriver Exception: {"value":{"error":"session not created","message":"Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line","stacktrace":""}}
_WDCreateSession: {"value":{"error":"session not created","message":"Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line","stacktrace":""}}
_WDCreateSession ==> Webdriver Exception: HTTP status = 500
__WD_Post: URL=
HTTP://127.0.0.1:4444/session//url; $sData={"url":"http://google.com"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"unknown command","message":"POST /session//url did not match a known command","stacktrace":""}}
__WD_Post ==> Webdriver Exception: {"value":{"error":"unknown command","message":"POST /session//url did not match a known command","stacktrace":""}}
_WDNavigate: {"value":{"error":"unknown command","message":"POST /session//url did not match a known command","stacktrace":""}}
_WDNavigate ==> Webdriver Exception: HTTP status = 404
__WD_Post: URL=
HTTP://127.0.0.1:4444/session//element; $sData={"using":"xpath","value":"//a[@class='gsfi']"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"unknown command","message":"POST /session//element did not match a known command","stacktrace":""}}
__WD_Post ==> Webdriver Exception: {"value":{"error":"unknown command","message":"POST /session//element did not match a known command","stacktrace":""}}
_WDGetElement: {"value":{"error":"unknown command","message":"POST /session//element did not match a known command","stacktrace":""}}
_WDGetElement ==> No match: unknown command

 

Share this post


Link to post
Share on other sites
5 minutes ago, Jury said:

I'm a little confused about using  _WD_ or _WD  as for example in _WD_Navigate or _WDNavigate  this one seems to work _WDNavigate

The Console gives me:

_WDStartup: OS: WIN_10 WIN32_NT 16299
_WDStartup: AutoIt: 3.3.14.3
_WDStartup: WD.au3: 0.1.0.3

The latest version is 0.1.0.9. Please update to that and then try again.

https://github.com/Danp2/WebDriver/releases/latest

Share this post


Link to post
Share on other sites

@Jury There was an updated version of geckodriver released earlier this week, so you should make sure that you have the latest version of it as well.

Also, if Firefox isn't installed in the default location, you'll need to provide the location of the executable. You can read more info about moz:firefoxOptions here.

Share this post


Link to post
Share on other sites

Thanks I'd hoped this would do the trick (but didn't):

 

Func SetupGecko()
$ff = '--binary C:\Program Files (x86)\Mozilla Firefox\firefox.exe'
_WDOption('Driver', 'geckodriver')
_WDOption('DriverParams', $ff)
_WDOption('Port', 2828)

$sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}'
EndFunc

 

Share this post


Link to post
Share on other sites

The DriverParams is used to pass parameters to the web driver. It's not for indicating the location of the browser executable. This would be done as part of DesiredCapabilities, which gets passed to _WD_CreateSession.

Edit: @Jury I just reread the flags section and see where they say this should work as you indicated. Can you post the contents from the Scite output window?

Edited by Danp2

Share this post


Link to post
Share on other sites

Thanks a lot, @Danp2. Your UDF works great. Now I have 2 questions. First, what is the syntax of $sDesiredCapbilities? For example, how do I integrate 'start-maximized' option in the $sDesiredCapabilities? The 2nd question is, what happens if I don't call _WD_DeleteSession() function at the end of my code? Will it create any prolem if I do it repeatedly, such as temporary files piling up in the computer? Currently I'm not calling this function because I want to keep the website open after the code is finished. I just call _WD_Shutdown(). Your answers will be greatly appreciated.

Share this post


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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Danp2
      Introduction
      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.
      Requirements
      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/
      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 --
      https://www.autoitscript.com/wiki/WebDriver
      Please post any questions, suggestions or errors in the GH&S thread.
      https://www.autoitscript.com/forum/topic/201106-webdriver-udf-help-support-ii/
    • 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://127.0.0.1:9515/session/b72166b774d7fefb258b3721fc1d4306/element/657e6b5d-31a9-46a8-85c4-acb7f72bf659/text __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!
    • By JohnWIlling
      We are running on a VIrtual Machine via Remote Desktop.  We are having a situation where the loading of the chromedriver.exe is taking longer on the VM than on a physical machine.  It is causing the first call to  WD_Post in _WD_CreateSession to fail.
      To workaround the Issue, I used a simplified version of (_WinAPI_GetTcpTable) UDF to Loop waiting for the driver port to be in the listening state.  At that point, I know that the Post will work:
      Func _WaitForPort($ListenPort) Do Local $tMIB_TCPTABLE = DllStructCreate("dword[6]") Local $aRet = DllCall("Iphlpapi.dll", "DWORD", "GetTcpTable", "struct*", $tMIB_TCPTABLE, "DWORD*", 0, "BOOL", True) Local $dwSize = $aRet[2] $tMIB_TCPTABLE = DllStructCreate("DWORD[" & $dwSize / 4 & "]") $aRet = DllCall("Iphlpapi.dll", "DWORD", "GetTcpTable", "struct*", $tMIB_TCPTABLE, "DWORD*", $dwSize, "BOOL", True) If $aRet[0] <> 0 Then Return SetError(1) Local $iNumEntries = DllStructGetData($tMIB_TCPTABLE, 1, 1) Local $aRes[$iNumEntries][6] For $i = 0 To $iNumEntries - 1 Local $Type = DllStructGetData($tMIB_TCPTABLE, 1, 2 + $i * 5 + 0) $aRet = DllCall("ws2_32.dll", "ushort", "ntohs", "uint", DllStructGetData($tMIB_TCPTABLE, 1, 2 + $i * 5 + 2)) ; local port Local $Port = $aRet[0] ConsoleWrite("Checking Row:" & $i & " State:<" & $Type & "> Port:<" & $Port & ">" & @CRLF) ; Type 2 is LISTENING If $Type = 2 And $Port = $ListenPort Then Return 1; EndIF Next Sleep(500); Until 0; Return 0; EndFunc ;==>_WaitForPort  
×
×
  • Create New...