Jump to content

WebDriver UDF - Help & Support (II)


Danp2
 Share

Recommended Posts

When I updated my geckodriver.exe now my script give me this:

_WD_IsLatestRelease: True
_WD_IsLatestRelease ==> Success
_WDStartup: OS: WIN_10 WIN32_NT 18362
_WDStartup: AutoIt: 3.3.14.5
_WDStartup: WD.au3: 0.3.0.7 (Up to date)
_WDStartup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)
_WDStartup: Driver: C:\Users\PC1\Documents\Dropbox\autoit_new\resources\geckodriver.exe
_WDStartup: Params: 
_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 f...
__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":""}}
_WD_CreateSession: {"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_CreateSession ==> Webdriver Exception: HTTP status = 500
__WD_Post: URL=HTTP://127.0.0.1:4444/session//url; $sData={"url":"https://..."}
__WD_Post: StatusCode=405; ResponseText=HTTP method not allowed...
_WD_Navigate: HTTP method not allowed

I don't understand and can't see anything in the geckodriver update information that seems to apply.

 

BTW: I see this now:  _WDStartup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)

 

 

Edited by Jury
Link to comment
Share on other sites

I was about to use the WebDriver UDF for the first time but noticed that v0.3.0.7 zip file's comment has what looks like a SHA1 hash, which I assume is used to verify the zip file's integrity.  If that is what it is, then it does not match the zip file's calculated SHA1 hash.  If the zip file's comment is not supposed to be the file's SHA1 hash or it's no longer maintained, then please disregard this post.  If it is supposed to be the file's current SHA1 hash, is it safe to assume that the file was updated but the hash was not and that the current contents are okay?

21EBE3A418EBC3F5385C8FB4ECABB5E652208D57  (zip file's current comment)
0108A80EE0497B983BC01022B70F356C0B67AE4C  (calculated SHA1 hash)

image.png.b0fc3c2ef91565c20f0fe3e5dda5f2c3.png

image.png.cb52aea6b8e233b8cc1b3c656787e295.png

 

Edited by TheXman
Redacted profile name
Link to comment
Share on other sites

@TheXman Not sure where that comes from TBH. Must be something automatically occurring when I publish a new release. 🤷‍♂️

Edit: Turns out that is the commit from when the release was created, ie: https://github.com/Danp2/WebDriver/commit/21ebe3a418ebc3f5385c8fb4ecabb5e652208d57

:thumbsup:😆

Edited by Danp2
Link to comment
Share on other sites

Okay thanks.  If it's something that's being added by Github, then I'll just ignore it.

Edited by TheXman
Link to comment
Share on other sites

My Debug.log shows this error, any idea how to trace this?

[0827/124417.110:ERROR:exception_snapshot_win.cc(98)] thread ID 18920 not found in process
[0827/124417.160:ERROR:process_reader_win.cc(123)] NtOpenThread: {Access Denied} A process has requested access to an object, but has not been granted those access rights. (0xc0000022)

Can we write custom text in Chrome.log? if yes how....

Edited by hemal
Link to comment
Share on other sites

1 hour ago, Danp2 said:

@hemal Did this produce any errors or unexpected results on the Autoit side?

No Its not creating any unexpected result. But just want to make sure the full proof script. I am not aware about the impact.

Secondly, Can we put or write lines in chrome.log file?  or you suggest to write status log in separate file.

Link to comment
Share on other sites

@hemal If you want to investigate the errors from the Chrome log, then I would recommend checking Google for similar errors. As far as logging goes, you probably can't output to the same file due to locking issues, so using a separate file is recommended.

FYI, the most recent UDF release allows you to log to a file instead of the Scite console.

Link to comment
Share on other sites

Hello all,

can someone please let me know if I can start a session in chrome with shellexecute and access to this session with WebDriver.

When I am already logged in into a website I do not want to start a new session to login again with the WebDriver.

So my plan is to access to a website, which requires to log in and access to the site with the WebDriver.

I don't want to login with the WebDriver since it would require additional efforts to make it safe.

I have tried a lot with the demo, which is really great. But I don't know how to handle that. I have tried the examples of previous posts, but it doesn't work. 

Hope someone can help me :)

 

Thanks in advance!

Link to comment
Share on other sites

@Tim772 The only way I know is to use the --remote-debugging-port parameter when launching Chrome. You can then use this same port number to communicate with the existing Chrome instance. Here's a simple example --

#include "wd_core.au3"

Local $sDesiredCapabilities, $sSession

ShellExecute("chrome.exe", "--remote-debugging-port=9222")

SetupChrome()
_WD_Startup()

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

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

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"debuggerAddress": "localhost:9222"}}}}'
EndFunc

Note: there are limitations to using this feature

Link to comment
Share on other sites

I would like to allow the Chrome instance I use to automatically update. The problem is that if Chrome updates, then the Chrome driver needs to be updated as well or otherwise it throws an error. Could a feature be added to automatically download and use the Chrome driver specific to the version of Chrome? I don't mind downloading 7-zip command line version once to allow this script to extract the latest driver, but updating the driver so often can be a pain.

Who else would I be?
Link to comment
Share on other sites

Hey all just wanted to share some code if you're struggling to send keys to your web session.
Here is how I was able to send an "ENTER" keystroke to my web session:
 

_WD_Action($sSession, 'actions', '{"actions": [{"type": "key", "id": "keyboard", "actions": [{"type": "keyDown", "value": "\uE007"}, {"type": "keyUp", "value": "\uE007"}]}]}')

Spent many hours trying to figure the sequence out. Hopefully this can help someone.

@giahh - Saw you trying to do this back in 2018

Referenced:
https://github.com/jlipps/simple-wd-spec#perform-actions

Link to comment
Share on other sites

Hello, I'm trying to get innerHTML attribute of the element on w3 webpage via chrome. But it comes back empty. What am I doing wrong?

Here is example script:

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

Local $sSession, $sDesiredCapabilities
SetupChrome()

_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_LoadWait($sSession)

_WD_Navigate($sSession, "https://www.w3.org/")
_WD_LoadWait($sSession)
Sleep (10000)

$sEl = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='w3c_container']")
$html = _WD_ElementAction($sSession, $sEl , 'Attribute', 'innerhtml')
MsgBox (0,"",$html)


_WD_Shutdown()


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

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

 

And the output in Scite:

__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"85.0....
_WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"85.0.4183.83","chrome":{"chromedriverVersion":"84.0.4147.30 (48b3e868b4cc0aa7e8149519690b6f6949e110a8-refs/branch-heads/4147@{#310})","userDataDir":"C:\\Users\\User1\\AppData\\Local\\Temp\\scoped_dir20792_1909389831"},"goog:chromeOptions":{"debuggerAddress":"localhost:54985"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:virtualAuthenticators":true},"sessionId":"a99a05f4fc74fc83ef07e96425615ef3"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/a99a05f4fc74fc83ef07e96425615ef3/execute/sync; $sData={"script":"return document.readyState", "args":[]}
__WD_Post: StatusCode=200; ResponseText={"value":"complete"}...
_WD_ExecuteScript: {"value":"complete"}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/a99a05f4fc74fc83ef07e96425615ef3/url; $sData={"url":"https://www.w3.org/"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Navigate: {"value":null}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/a99a05f4fc74fc83ef07e96425615ef3/execute/sync; $sData={"script":"return document.readyState", "args":[]}
__WD_Post: StatusCode=200; ResponseText={"value":"complete"}...
_WD_ExecuteScript: {"value":"complete"}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/a99a05f4fc74fc83ef07e96425615ef3/element; $sData={"using":"xpath","value":"//div[@id='w3c_container']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"a3c19afc-bab9-4627-b4c2-3f51946cc017"}}...
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"a3c19afc-bab9-4627-b4c2-3f51946cc017"}}
__WD_Get: URL=HTTP://127.0.0.1:9515/session/a99a05f4fc74fc83ef07e96425615ef3/element/a3c19afc-bab9-4627-b4c2-3f51946cc017/attribute/innerhtml
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":null}...
_WD_ElementAction: {"value":null}...

 

Thanks for any directions!

Edited by drr
Link to comment
Share on other sites

1 hour ago, drr said:

$html = _WD_ElementAction($sSession, $sEl , 'Attribute', 'innerhtml')

In this situation, you have to pass the attribute or property name using the proper case. The process is returning a Null because it can't find an attribute named "innerhtml". Change this to "innerHTML" and it should give you the desired result.

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...