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 comment
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
Link to comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...