Jump to content
Danp2

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.

Share this post


Link to post
Share on other sites

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

Share this post


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.

Share this post


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

Share this post


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.

Share this post


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.

Share this post


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. :)

Share this post


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 :)

Share this post


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

Share this post


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,

Share this post


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.

Share this post


Link to post
Share on other sites

i must stop asking u everytime ...i wrote __WD_Alert($sSession, 'accept') instead of  _WD_Alert($sSession, 'accept')

Edited by omarjr16

Share this post


Link to post
Share on other sites

@Danp2 i noticed that using this udf will take alot of ram (+0.2mb everysec)  when i put a loop even if i close the window the session and windows driver everytime .. do u know how to fix that ?! is the problem from ur udf or from my script or maybe from winhttp.au3 /json.au3

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/
      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/201106-webdriver-udf-help-support-ii/
    • 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, 
      chrome_Details.txt
    • 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!
×
×
  • Create New...