Jump to content

WebDriver UDF - Help & Support


Recommended Posts

@Danp2

Little update about this issue.

I tried to run it with these desired capabilities.

'{"capabilities":{"alwaysMatch":{"chromeOptions":{"addExtensions":"C:\Users\KarlMueller\Desktop\Project CHROME\sso.crx","w3c":true,"enablePassThrough":false}}}}'

But I get this error.

WDStartup: OS:  WIN_10 WIN32_NT 17763 
_WDStartup: AutoIt: 3.3.14.5
_WDStartup: WD.au3: 0.1.0.21
_WDStartup: Driver: chromedriver.exe
_WDStartup: Params: --log-path="C:\Users\KarlMueller\Desktop\Project CHROME\chrome.log"
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities":{"alwaysMatch":{"chromeOptions":{"addExtensions":"C:\Users\KarlMueller\Desktop\Project CHROME\sso.crx","w3c":true,"enablePassThrough":false}}}}
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"Backtrace:\n\tOrdinal0 [0x010BA903+1550595]\n\tOrdinal0 [0x0103A701+1025793]\n\tOrdinal0 [0x00FBC6E5+509669]\n\tOrdinal0 [0x00F676FC+161532]\n\tOrdinal0 [0x00F673CA+160714]\n\tOrdinal0 [0x00F4221E+8734]\n\tOrdinal0 [0x00F42606+9734]\n\tOrdinal0 [0x00F42C80+11392]\n\tOrdinal0 [0x010542C7+1131207]\n\tGetHandleVerifier [0x011570FD+523789]\n\tGetHandleVerifier [0x01156E90+523168]\n\tGetHandleVerifier [0x0115E1E7+552695]\n\tGetHandleVerifier [0x011578FA+525834]\n\tOrdinal0 [0x0104B7FC+1095676]\n\tOrdinal0 [0x00F42053+8275]\n\tOrdinal0 [0x00F41DA7+7591]\n\tGetHandleVerifier [0x014BA3BC+4075724]\n\tBaseThreadInitThunk [0x772A0419+25]\n\tRtlGetAppContainerNamedObjectPath [0x778C662D+237]\n\tRtlGetAppContainerNamedObjectPath [0x778C65FD+189]\n"}}
_WD_CreateSession: {"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"Backtrace:\n\tOrdinal0 [0x010BA903+1550595]\n\tOrdinal0 [0x0103A701+1025793]\n\tOrdinal0 [0x00FBC6E5+509669]\n\tOrdinal0 [0x00F676FC+161532]\n\tOrdinal0 [0x00F673CA+160714]\n\tOrdinal0 [0x00F4221E+8734]\n\tOrdinal0 [0x00F42606+9734]\n\tOrdinal0 [0x00F42C80+11392]\n\tOrdinal0 [0x010542C7+1131207]\n\tGetHandleVerifier [0x011570FD+523789]\n\tGetHandleVerifier [0x01156E90+523168]\n\tGetHandleVerifier [0x0115E1E7+552695]\n\tGetHandleVerifier [0x011578FA+525834]\n\tOrdinal0 [0x0104B7FC+1095676]\n\tOrdinal0 [0x00F42053+8275]\n\tOrdinal0 [0x00F41DA7+7591]\n\tGetHandleVerifier [0x014BA3BC+4075724]\n\tBaseThreadInitThunk [0x772A0419+25]\n\tRtlGetAppContainerNamedObjectPath [0x778C662D+237]\n\tRtlGetAppContainerNamedObjectPath [0x778C65FD+189]\n"}}
_WD_CreateSession ==> Webdriver Exception: invalid argument: missing command parameters
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; $sData={"url":"https://telekom.de/"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x010BA903+1550595]\n\tOrdinal0 [0x0103A701+1025793]\n\tOrdinal0 [0x00FBC58E+509326]\n\tOrdinal0 [0x00F50FB9+69561]\n\tOrdinal0 [0x00F68DD7+167383]\n\tOrdinal0 [0x00F677F2+161778]\n\tOrdinal0 [0x00F673CA+160714]\n\tOrdinal0 [0x00F4221E+8734]\n\tOrdinal0 [0x00F42606+9734]\n\tOrdinal0 [0x00F42C80+11392]\n\tOrdinal0 [0x010542C7+1131207]\n\tGetHandleVerifier [0x011570FD+523789]\n\tGetHandleVerifier [0x01156E90+523168]\n\tGetHandleVerifier [0x0115E1E7+552695]\n\tGetHandleVerifier [0x011578FA+525834]\n\tOrdinal0 [0x0104B7FC+1095676]\n\tOrdinal0 [0x00F42053+8275]\n\tOrdinal0 [0x00F41DA7+7591]\n\tGetHandleVerifier [0x014BA3BC+4075724]\n\tBaseThreadInitThunk [0x772A0419+25]\n\tRtlGetAppContainerNamedObjectPath [0x778C662D+237]\n\tRtlGetAppContainerNamedObjectPath [0x778C65FD+189]\n"}}
_WD_Navigate: {"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x010BA903+1550595]\n\tOrdinal0 [0x0103A701+1025793]\n\tOrdinal0 [0x00FBC58E+509326]\n\tOrdinal0 [0x00F50FB9+69561]\n\tOrdinal0 [0x00F68DD7+167383]\n\tOrdinal0 [0x00F677F2+161778]\n\tOrdinal0 [0x00F673CA+160714]\n\tOrdinal0 [0x00F4221E+8734]\n\tOrdinal0 [0x00F42606+9734]\n\tOrdinal0 [0x00F42C80+11392]\n\tOrdinal0 [0x010542C7+1131207]\n\tGetHandleVerifier [0x011570FD+523789]\n\tGetHandleVerifier [0x01156E90+523168]\n\tGetHandleVerifier [0x0115E1E7+552695]\n\tGetHandleVerifier [0x011578FA+525834]\n\tOrdinal0 [0x0104B7FC+1095676]\n\tOrdinal0 [0x00F42053+8275]\n\tOrdinal0 [0x00F41DA7+7591]\n\tGetHandleVerifier [0x014BA3BC+4075724]\n\tBaseThreadInitThunk [0x772A0419+25]\n\tRtlGetAppContainerNamedObjectPath [0x778C662D+237]\n\tRtlGetAppContainerNamedObjectPath [0x778C65FD+189]\n"}}
+>12:03:54 AutoIt3.exe ended.rc:0

 

Link to comment
Share on other sites

1 hour ago, rkskaras said:

Is it possible to start Chrome WebDriver with an extension? I tried to add "addExtensions" to $sDesiredCapabilities  but unfortunately, I don't know how. Can you help me with it?

This isn't something I've done, so YMMV with this feedback. I don't believe that "addExtensions" is applicable here since were manually building the DesiredCapacities string. Therefore, I suggest that you try something like this --

'{"capabilities":{"alwaysMatch":{"chromeOptions":{"Extensions":{"C:\Users\KarlMueller\Desktop\Project CHROME\sso.crx"},"w3c":true,"enablePassThrough":false}}}}'

 

Link to comment
Share on other sites

3 minutes ago, Danp2 said:

This isn't something I've done, so YMMV with this feedback. I don't believe that "addExtensions" is applicable here since were manually building the DesiredCapacities string. Therefore, I suggest that you try something like this --

'{"capabilities":{"alwaysMatch":{"chromeOptions":{"Extensions":{"C:\Users\KarlMueller\Desktop\Project CHROME\sso.crx"},"w3c":true,"enablePassThrough":false}}}}'

 

Thank you for reply.

But it is not working :/ 

 

I still get this error.

_WDStartup: OS: WIN_10 WIN32_NT 17763 
_WDStartup: AutoIt: 3.3.14.5
_WDStartup: WD.au3: 0.1.0.21
_WDStartup: Driver: chromedriver.exe
_WDStartup: Params: 
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities":{"alwaysMatch":{"chromeOptions":{"Extensions":{"C:\Users\KarlMueller\Desktop\Project CHROME\sso.crx"},"w3c":true,"enablePassThrough":false}}}}
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"Backtrace:\n\tOrdinal0 [0x010BA903+1550595]\n\tOrdinal0 [0x0103A701+1025793]\n\tOrdinal0 [0x00FBC6E5+509669]\n\tOrdinal0 [0x00F676FC+161532]\n\tOrdinal0 [0x00F673CA+160714]\n\tOrdinal0 [0x00F4221E+8734]\n\tOrdinal0 [0x00F42606+9734]\n\tOrdinal0 [0x00F42C80+11392]\n\tOrdinal0 [0x010542C7+1131207]\n\tGetHandleVerifier [0x011570FD+523789]\n\tGetHandleVerifier [0x01156E90+523168]\n\tGetHandleVerifier [0x0115E1E7+552695]\n\tGetHandleVerifier [0x011578FA+525834]\n\tOrdinal0 [0x0104B7FC+1095676]\n\tOrdinal0 [0x00F42053+8275]\n\tOrdinal0 [0x00F41DA7+7591]\n\tGetHandleVerifier [0x014BA3BC+4075724]\n\tBaseThreadInitThunk [0x772A0419+25]\n\tRtlGetAppContainerNamedObjectPath [0x778C662D+237]\n\tRtlGetAppContainerNamedObjectPath [0x778C65FD+189]\n"}}
_WD_CreateSession: {"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"Backtrace:\n\tOrdinal0 [0x010BA903+1550595]\n\tOrdinal0 [0x0103A701+1025793]\n\tOrdinal0 [0x00FBC6E5+509669]\n\tOrdinal0 [0x00F676FC+161532]\n\tOrdinal0 [0x00F673CA+160714]\n\tOrdinal0 [0x00F4221E+8734]\n\tOrdinal0 [0x00F42606+9734]\n\tOrdinal0 [0x00F42C80+11392]\n\tOrdinal0 [0x010542C7+1131207]\n\tGetHandleVerifier [0x011570FD+523789]\n\tGetHandleVerifier [0x01156E90+523168]\n\tGetHandleVerifier [0x0115E1E7+552695]\n\tGetHandleVerifier [0x011578FA+525834]\n\tOrdinal0 [0x0104B7FC+1095676]\n\tOrdinal0 [0x00F42053+8275]\n\tOrdinal0 [0x00F41DA7+7591]\n\tGetHandleVerifier [0x014BA3BC+4075724]\n\tBaseThreadInitThunk [0x772A0419+25]\n\tRtlGetAppContainerNamedObjectPath [0x778C662D+237]\n\tRtlGetAppContainerNamedObjectPath [0x778C65FD+189]\n"}}
_WD_CreateSession ==> Webdriver Exception: invalid argument: missing command parameters
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; $sData={"url":"https://bi-portal.telekom.de/cognos/bi/"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x010BA903+1550595]\n\tOrdinal0 [0x0103A701+1025793]\n\tOrdinal0 [0x00FBC58E+509326]\n\tOrdinal0 [0x00F50FB9+69561]\n\tOrdinal0 [0x00F68DD7+167383]\n\tOrdinal0 [0x00F677F2+161778]\n\tOrdinal0 [0x00F673CA+160714]\n\tOrdinal0 [0x00F4221E+8734]\n\tOrdinal0 [0x00F42606+9734]\n\tOrdinal0 [0x00F42C80+11392]\n\tOrdinal0 [0x010542C7+1131207]\n\tGetHandleVerifier [0x011570FD+523789]\n\tGetHandleVerifier [0x01156E90+523168]\n\tGetHandleVerifier [0x0115E1E7+552695]\n\tGetHandleVerifier [0x011578FA+525834]\n\tOrdinal0 [0x0104B7FC+1095676]\n\tOrdinal0 [0x00F42053+8275]\n\tOrdinal0 [0x00F41DA7+7591]\n\tGetHandleVerifier [0x014BA3BC+4075724]\n\tBaseThreadInitThunk [0x772A0419+25]\n\tRtlGetAppContainerNamedObjectPath [0x778C662D+237]\n\tRtlGetAppContainerNamedObjectPath [0x778C65FD+189]\n"}}
_WD_Navigate: {"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x010BA903+1550595]\n\tOrdinal0 [0x0103A701+1025793]\n\tOrdinal0 [0x00FBC58E+509326]\n\tOrdinal0 [0x00F50FB9+69561]\n\tOrdinal0 [0x00F68DD7+167383]\n\tOrdinal0 [0x00F677F2+161778]\n\tOrdinal0 [0x00F673CA+160714]\n\tOrdinal0 [0x00F4221E+8734]\n\tOrdinal0 [0x00F42606+9734]\n\tOrdinal0 [0x00F42C80+11392]\n\tOrdinal0 [0x010542C7+1131207]\n\tGetHandleVerifier [0x011570FD+523789]\n\tGetHandleVerifier [0x01156E90+523168]\n\tGetHandleVerifier [0x0115E1E7+552695]\n\tGetHandleVerifier [0x011578FA+525834]\n\tOrdinal0 [0x0104B7FC+1095676]\n\tOrdinal0 [0x00F42053+8275]\n\tOrdinal0 [0x00F41DA7+7591]\n\tGetHandleVerifier [0x014BA3BC+4075724]\n\tBaseThreadInitThunk [0x772A0419+25]\n\tRtlGetAppContainerNamedObjectPath [0x778C662D+237]\n\tRtlGetAppContainerNamedObjectPath [0x778C65FD+189]\n"}}
+>13:51:51 AutoIt3.exe ended.rc:0

Can it be because of I am using WebDriver version 78.0.3904.70 on Google Chrome version 78.0.3904.87  ?

Link to comment
Share on other sites

6 minutes ago, Danp2 said:

@rkskaras The format of DesiredCapabilities is obviously incorrect. I gave a shot at assisting you to fix it, but obviously I was wrong.

Let us know if you come up with a working example. :thumbsup:

:D 

I don't know.

I tried 

{"capabilities":{"alwaysMatch":{"chromeOptions":{"Extensions":"sso.crx","w3c":true,"enablePassThrough":false}}}}

and

'{"capabilities":{"alwaysMatch":{"chromeOptions":{"Extensions":"C:\\Users\\KarlMueller\\Desktop\\Project CHROME\\sso.crx","w3c":true,"enablePassThrough":false}}}}'

and also

'{"capabilities":{"alwaysMatch":{"chromeOptions":{"Extensions":"C://Users//KarlMueller//Desktop//Project CHROME//sso.crx","w3c":true,"enablePassThrough":false}}}}'

I know that the Format is now okay. But it still does not work 

Link to comment
Share on other sites

I would suggest to use "goog:chromeOptions" instead of "chromeOptions" and add "excludeSwitches": ["enable-automation"] in the options.

Since I don't have a crx flle, I tested loading extension folder and it worked OK, even though a balloon popped up warning not to use an extension when Chrome is in developer mode. My test capabilities are as below:

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, ' & _
'"args": ["start-maximized", "load-extension=C:\\users\\cycho\\appdata\\local\\google\\chrome\\user data\\default\\extensions\\pkedcjkdefgpdelpbcmbmeomcjbeemfm\\7819.902.0.1_0"] }}}}'

The extension folder is the folder where manifest.json file for the extension is located.

Link to comment
Share on other sites

1 hour ago, CYCho said:

I would suggest to use "goog:chromeOptions" instead of "chromeOptions" and add "excludeSwitches": ["enable-automation"] in the options.

Since I don't have a crx flle, I tested loading extension folder and it worked OK, even though a balloon popped up warning not to use an extension when Chrome is in developer mode. My test capabilities are as below:

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, ' & _
'"args": ["start-maximized", "load-extension=C:\\users\\cycho\\appdata\\local\\google\\chrome\\user data\\default\\extensions\\pkedcjkdefgpdelpbcmbmeomcjbeemfm\\7819.902.0.1_0"] }}}}'

The extension folder is the folder where manifest.json file for the extension is located.

Wow, Thank you very much! This worked like a charm :) 

 

Link to comment
Share on other sites

@Danp2 Can I narrow down the search by doing something like this? 

$wSaveBI = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//li[@id='toolactions_SAVE-tbb'@changed_by_user='False']")

This does not work by the way.  

Basically I am clicking on an element to save my progress but I am wanting to double-check if it was actually saved or not. And the only way to do, I have found (I looked into many possible ways of testing if it was clicked or not), is to narrow the FindElement. 

If the element is clicked or not it has the same id (and everything else is the same. Class and all), but the @changed_by_user is different. (not clicked = false clicked = true)

Is there a way to do something like this?

Link to comment
Share on other sites

@Danp2 

15 hours ago, Danp2 said:

@nooneclose This is really an xpath locator question, but I believe something like this should work --

"//li[@id='toolactions_SAVE-tbb' and @changed_by_user='False']"

 

It didn't work. 

I found some documentation on Xpath locator. :)  

If I get it to work I will post the code :D 

Edited by nooneclose
Found sources had to change my questions
Link to comment
Share on other sites

Here is the working code for my issue. (Issue was how do I code my script to test if data was properly sent. The button that saves doesn't change and the only difference on the page at all is that buttons element class changes from on to off) Thanks, @Danp2 for telling and showing me Xpath.

Here are the elements I had to work with: (first one is when the save button is unclicked. The second is when its clicked)

<a role="button" id="toolactions_SAVE-tbb_anchor" onkeydown="itemAKey(event,this)" title="Save Work Order CTRL+ALT+S" hotkey="S" eventtype="SAVE" class="on" <img role="button" tabindex="-1" id="toolactions_SAVE-tbb_image" src="nav_icon_save.gif" alt="Save Work Order CTRL+ALT+S" draggable="false"></a>
 

<a role="button" id="toolactions_SAVE-tbb_anchor" onkeydown="itemAKey(event,this)" title="Save Work Order CTRL+ALT+S" hotkey="S" eventtype="SAVE" class="off opacity_20"><img role="button" tabindex="-1" id="toolactions_SAVE-tbb_image" src="nav_icon_save.gif" alt="Save Work Order CTRL+ALT+S" draggable="false"></a>
 

Here is the working code that I used in a do until loop. :D 

Local $wSaveBI = ""
Local $wSavedI = ""

; Loop until the data is saved
Do
    $wSaveBI = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@id='toolactions_SAVE-tbb_anchor' and @class='on']")

    _WD_ElementAction($sSession, $wSaveBI, 'click')
    Sleep(2000)

    $wSavedI = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@id='toolactions_SAVE-tbb_anchor' and contains(@class,'off')]")

    ;ConsoleWrite("Test: " & $wSavedI & @CRLF)

Until $wSavedI <> ""

 

Edited by nooneclose
grammar
Link to comment
Share on other sites

1 hour ago, Danp2 said:

@nooneclose You could look into using _WD_WaitElement, which handles the looping for you. :thumbsup:

@Danp2 What are you talking about Willis? You telling me I could have avoided a lot of looping? I'm sad and happy all at the same time. 

I will try this thank you.

Edited by nooneclose
Found the documentation
Link to comment
Share on other sites

Here are the command I use

WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='files[]' and @id='inputFile']", 0, 500, True)
$Upload = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='files[]' and @id='inputFile']")
,_WD_ElementAction($sSession, $Upload, 'click')

and here is the debugging part 

__WD_Post: URL=HTTP://127.0.0.1:17556/session/BAC28C55-EE1C-4967-B64D-D7879AB55E49/element; $sData={"using":"xpath","value":"//input[@name='files[]' and @id='inputFile']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"ELEMENT":"efefb6e7-95fa-433f-8e9f-bedfeec2d220","element-6066-11e4-a52e-4f735466cecf":"efefb6e7-95fa-433f-8e9f-bedfeec2d220"}}
_WD_FindElement: {"value":{"ELEMENT":"efefb6e7-95fa-433f-8e9f-bedfeec2d220","element-6066-11e4-a52e-4f735466cecf":"efefb6e7-95fa-433f-8e9f-bedfeec2d220"}}
__WD_Get: URL=HTTP://127.0.0.1:17556/session/BAC28C55-EE1C-4967-B64D-D7879AB55E49/element/efefb6e7-95fa-433f-8e9f-bedfeec2d220/displayed
__WD_Get: StatusCode=500; $iResult = 0; $sResponseText=Unknown error...
_WD_ElementAction: Unknown error...

and nothing happen with element action

It seems that the input file only accept drag and drop or clicking on the left or right button to open file dialog 
 


 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...