Jump to content

Recommended Posts

Posted

What's with this thread:

 

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

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

Posted

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:
 

  Reveal hidden contents

Then I modify for Opera:
 

  Reveal hidden contents

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

  Reveal hidden contents

Opera don't launch.

Help please!

 

Posted

@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

 

Posted
  On 3/9/2018 at 2:35 PM, Danp2 said:

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

Expand  

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:

 

  Reveal hidden contents

 

Posted

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.

Posted
  On 3/9/2018 at 4:03 PM, mrPuh said:

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

Expand  

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

Posted (edited)

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

Who can help solve this problem?

Edited by mrPuh
Posted

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

 

Posted
  On 3/17/2018 at 3:09 PM, 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

Expand  

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

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

Posted

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

 

Posted (edited)

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
Posted

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.

Guest
This topic is now closed to further replies.
×
×
  • Create New...