Jump to content

WebDriver UDF - Help & Support


Recommended Posts

@omarjr16 Please post a fully runnable version of the script so that we can perform testing on our end. Otherwise, we can only guess at why you are encountering this issue.

P.S. I know that the Chrome web driver has some issues. You may want to try testing with Firefox to see if the issue remains. You could also confirm the web driver functionality by running the function in wd_demo.

Link to post
Share on other sites
  • Replies 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

This is the "General Help and Support" thread for the WebDriver UDF. The UDF itself can be downloaded here. So if you have any questions, suggestions or errors please post here.

use the _WD_ElementAction function like this: $sValue = _WD_ElementAction($sSession, $sElement, 'attribute', 'src') p.s. ... and remove @src from the xPath: "//img[@alt='NiceGirl']"

Time ago I wrote a function to extract data from  the source HTML code of tables. https://www.autoitscript.com/forum/topic/167679-read-data-from-html-tables-from-raw-html-source/ Seems that that fun

Posted Images

i want to run 2 sessions in the same time but i got this error when it was opening the second session also  its work fine using chromedriver but dont work with geckodriver... geckodriver dont support multi-sessions? :blink: 

1536439370982   webdriver::server       DEBUG   <- 500 Internal Server Error {"value":{"error":"session not created","message":"Session is already started","stacktrace":""}}
$sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}'

_WD_Option('Driver', 'geckodriver.exe')
_WD_Option('DriverParams', '--log trace')
_WD_Option('Port', 4444)

_WD_Startup()

$sSession1 = _WD_CreateSession($sDesiredCapabilities)
$sSession2 = _WD_CreateSession($sDesiredCapabilities)

 

Edited by omarjr16
Link to post
Share on other sites

I don't believe that the W3C specs require support for multiple sessions. It should be possible to launch multiple instances of geckodriver using a different port for each one. However, the Webdriver UDF hasn't been designed to support this scenario so YMMV.

I am able to communicate / control multiple Firefox tabs using a single instance of geckodriver. Perhaps you could provide a detailed description of what you are attempting to accomplish and why you don't think you can do that with a single instance of geckodriver.

Link to post
Share on other sites

i thought that opening multiple sessions will make it faster :blink: and i prove again that im stupid :P also i noticed that its possible to open multi sessions only if everysession use  diffrent data then the other sessions (google chrome) 

thank you anyways for helping me i dont need multiple sessions anymore ... this is my last question how to get style value (display: none; left: 780px; top: -682px;)

<div id="myid" style="display: none; left: 780px; top: -682px;">

i tried this but didnt work :/

$element = _WD_FindElement($Session, $_WD_LOCATOR_ByXPath, "//div[@id='myid']")
$style = _WD_ElementAction($sSession,$id ,'attribute', 'style' )
Edited by omarjr16
Link to post
Share on other sites

"Didn't work" isn't an adequate description of what occurred. ^_^

A few suggestions for you --

  • When asking for help, post a snippet of code that someone else can run without further modification.
  • Show the results from the Scite output panel or at least give enough details so that we aren't guessing at what didn't work as expected.
Link to post
Share on other sites

Hi Friends,

I'm trying to add a new cookie on Chrome using  _WD_Cookies($sSession, $sCommand, $sOption = '') and getting an error in response.

The other commands get, getall and delete are working perfect with Chrome.

I know the status of add cookie command is only partially complete on the status. but still like to check with the experts here :-)

When I try to set a new cookie, I am getting the error. 

{"value":{"error":"unknown error","message":"missing 'cookie'(Session infochrome=68.0.3440.106)","stacktrace":"Backtrace:\n\tOrdinal0 [0x0045DF70+778096]\n\tOrdinal0 [0x0040B42D+439341]\n\tOrdinal0 [0x003E807F+295039]\n\tOrdinal0 [0x003D3820+210976]\n\tOrdinal0 [0x003C8349+164681]\n\tOrdinal0 [0x003CF96B+194923]\n\tOrdinal0 [0x003C824F+164431]\n\tOrdinal0 [0x003B1B45+72517]\n\tOrdinal0 [0x003B2F2A+77610]\n\tOrdinal0 [0x003B2ECC+77516]\n\tGetHandleVerifier [0x004F9936+3478]\n\tOrdinal0 [0x004688C3+821443]\n\tOrdinal0 [0x00417066+487526]\n\tOrdinal0 [0x00417393+488339]\n\tOrdinal0 [0x004174A3+488611]\n\tOrdinal0 [0x0046AA67+830055]\n\tOrdinal0 [0x00416DAF+486831]\n\tOrdinal0 [0x004213FE+529406]\n\tOrdinal0 [0x0042C57B+574843]\n\tOrdinal0 [0x0042C6CD+575181]\n\tOrdinal0 [0x0042B92B+571691]\n\tBaseThreadInitThunk [0x75CD8484+36]\n\tRtlValidSecurityDescriptor [0x77AF2FEA+282]\n\tRtlValidSecurityDescriptor [0x77AF2FBA+234]\n"}}

Is this because the add command is not yet done for Chrome or any mistake in my program. Please help.

#include "wd_core.au3"
#RequireAdmin

_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')
_WD_Startup()
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}'
Global $sSession = _WD_CreateSession($sDesiredCapabilities)
If @Error Then
    msgbox(0,"Error", "Failed to create session." & @CRLF & "Select [Ok] to Exit")
    exit
EndIf
_WD_Navigate($sSession, "https://www.gmail.com") ;Navigate to URL
$sName = "Testname"
$svalue ="TestValue"
$sCookie = "{""name"":""" & $sName & """,""value"":""" & $svalue & """}"
$sRes = _WD_Cookies($sSession, 'add',$sCookie)
Msgbox(0,"Result of Add cookie", $sRes)
$sRes = _WD_Cookies($sSession, 'getall')
msgbox(0,"Result of getall", $sRes)
_WD_DeleteSession($sSession)
_WD_Shutdown()

 

Edited by PoojaKrishna
Corrected the code. _WD_Option calls need to come before _WD_Startup.
Link to post
Share on other sites

@PoojaKrishna Your code isn't runnable as posted (the _WD_Option calls need to come before _WD_Startup). The Chrome implementation for Add Cookies is partially implemented per their own documentation. There's an open issue, which you can read about here.

I haven't verified the Add Cookie functionality, so it's possible that the UDF is wrong. It's also possible that your $sCookie is missing needed data. :)

Link to post
Share on other sites
7 hours ago, Danp2 said:

Change this --

$sCookie = "{""name"":""" & $sName & """,""value"":""" & $svalue & """}"

to this --

$sCookie = '{"cookie": {"name":"' & $sName & '","value":"' & $svalue & '"}}'

and it should work correctly.

Yes, It worked perfect. Thank you so much for being so helpful Dan :)

Link to post
Share on other sites

@Danp2 screenshot dont work correctly (_WD_Window func)

Case 'screenshot'
            $sResponse = __WD_Get($_WD_BASE_URL & ":" & $_WD_PORT & "/session/" & $sSession & $sCommand)

you need to change it to

Case 'screenshot'
            $sResponse = __WD_Get($_WD_BASE_URL & ":" & $_WD_PORT & "/session/" & $sSession &"/"& $sCommand)

also "_WD_Timeouts" dont work with chromedriver u can only get the timeouts but not edit them... 

Link to post
Share on other sites

Hey all.

 

From http://www.softwareishard.com/blog/har-export-trigger/ :

"Basic automated HAR export is already supported by Firefox 41+ and all the user needs to do is set devtools.netmonitor.har.enableAutoExportToFile preference to enable it. As soon as this pref is true, a new HAR file is created automatically for every loaded page and stored in <your-firefox-profile-dir>/har/logs directory. "

What would be the good settings to put to capabilities so that it would work with this API? THanks a lot for you help,

Link to post
Share on other sites

@timmalos Probably the simplest solution is to manually run Firefox with the "--marionette" option and then connect to this browser with the following --

_WD_Option('Driver', 'geckodriver.exe')
_WD_Option('DriverParams', '--log trace --connect-existing  --marionette-port 2828')
_WD_Option('Port', 4444)

Local $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}'
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)

This way you get to use your standard user profile, so you can have the extension already installed and the prefs setup as desired.

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 levila
      Hi Guys, i just do some codding to automate login to some of the web.
      I manage to do the script but somehow after script done, some weird box popup. and keep looping until i close the main chrome.exe

      here is my code. kinldy pls assist, im very new to webdriver udf.
      #NoTrayIcon #include "wd_core.au3" #include "wd_helper.au3" $_WD_DEBUG = $_WD_DEBUG_None ; You could also use $_WD_DEBUG_Error Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://someoftheweb.com") _ChromeSetInputValueByName($sSession, "inputName", "Username") _ChromeSetInputValueById($sSession, "inputPassword", "Password") _ChromeSetMouseClick($sSession, "submit", "click") _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, "args":["--no-sandbox"]}}}}' EndFunc Func _ChromeSetInputValueByName($sSession,$name,$Value) $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='"&$name&"']") _WD_ElementAction($sSession,$sButton,'value', $Value) EndFunc Func _ChromeSetInputValueById($sSession,$Id,$Value) $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='"&$Id&"']") _WD_ElementAction($sSession,$sButton,'value', $Value) EndFunc Func _ChromeSetMouseClick($sSession,$Id,$Value) $sButton = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//button[@type='"&$Id&"']") _WD_ElementAction($sSession, $sButton, 'click', $Value) EndFunc  
    • By RohanM
      Hi Team,
      is there is a way to embed the webpage in auto it GUI using webdriver? what I want to do is that, I want to open edge browser inside the AutoIT GUI, in IE we have _IECreateEmbedded function but for the webdriver I am not able to find a function, please help  
      Rohan M
    • 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/
      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 --
      https://www.autoitscript.com/wiki/WebDriver
      Please post any questions, suggestions or errors in the GH&S thread.
      https://www.autoitscript.com/forum/topic/205553-webdriver-udf-help-support-iii/
      Previous support threads (Closed)
      https://www.autoitscript.com/forum/topic/192730-webdriver-udf-help-support/
      https://www.autoitscript.com/forum/topic/201106-webdriver-udf-help-support-ii/
       
    • 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)  
×
×
  • Create New...