Jump to content

Cannot open 'File Upload Control' on web page using _WD_ElementAction


Dmp
 Share

Recommended Posts

Hello SMEs:

Trying to automate the click on a "file upload control" on an internal web page, but to no avail. 

I can find the element id w/ _WD_FindElement, however cannot do anything w/ it afterwards. 

@error displays a "5."

Any insight on my issue would be appreciated, as always.

Question.au3

Link to comment
Share on other sites

Adding SciTE putput:

_WD_WaitElement ==> Success [0] : Parameters:   Strategy=xpath   Selector=//input[contains(@id, 'fuFileName')]   Delay=Default   Timeout=Default   Options=3
__WD_Post ==> Success [0] : HTTP status = 200
_WD_FindElement ==> Success [0] : Parameters:   Strategy=xpath   Selector=//input[contains(@id, 'fuFileName')]   StartNodeID=Default   Multiple=Default   ShadowRoot=3
__WD_Post ==> Invalid argument [5] : HTTP status = 400

Link to comment
Share on other sites

It's difficult to know for sure since we don't have the details on the target element. If it is of type '< input type="file" >', then you should take a look at _WD_SelectFiles.

FYI, _WD_WaitElement now returns the element ID of the found element, so your code can be rewritten to eliminate the repetitive call to _WD_FindElement.

Link to comment
Share on other sites

2 minutes ago, Dmp said:

_WD_FindElement ==> Success [0] : Parameters:   Strategy=xpath   Selector=//input[contains(@id, 'fuFileName')]   StartNodeID=Default   Multiple=Default   ShadowRoot=3

There's your real problem. _WD_FindElement doesn't take the same set of parameters as _WD_WaitElement, so you are passing an invalid value to the ShadowRoot parameter.

Link to comment
Share on other sites

 Question.au3

 

I removed the _WD_WaitElement lines, leaving only the _WD_FindElement code, however, I'm still having the same issue; in fact this is what I had written initially.

_WD_FindElement ==> Success [0] : Parameters:   Strategy=xpath   Selector=//input[contains(@id, 'fuFileName')]   StartNodeID=Default   Multiple=Default   ShadowRoot=3
__WD_Post ==> Invalid argument [5] : HTTP status = 400
_WD_ElementAction ==> Invalid argument [5] : Parameters:   Command=click   Option=Default

Link to comment
Share on other sites

Looking at Func _WD_SelectFiles($sSession, $sStrategy, $sSelector, $sFilename) .... so I can try this instead of having to contend w/ the file upload control, correct?

 

; select single file
 

_WD_SelectFiles($sSession, $_WD_LOCATOR_ByXPath, "//section[@id='examples']//input[@name='uploadedfile']", @ScriptDir & "\Screen1.png")

 

Link to comment
Share on other sites

__WD_Post: URL=HTTP://127.0.0.1:9515/session/48fdc5dd36c0d4d45eb352c1e71a933f/element; Data={"using":"xpath","value":"//input[contains(@id, 'fuFileName')]"}
__WD_Post ==> Success [0] : HTTP status = 200 ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"fe7afb87-400d-451b-96b1-45296e02db0a"}}
_WD_FindElement ==> Success [0] : Parameters:   Strategy=xpath   Selector=//input[contains(@id, 'fuFileName')]   StartNodeID=Default   Multiple=Default   ShadowRoot=Default
__WD_Post: URL=HTTP://127.0.0.1:9515/session/48fdc5dd36c0d4d45eb352c1e71a933f/element/fe7afb87-400d-451b-96b1-45296e02db0a/click; Data={"id":"fe7afb87-400d-451b-96b1-45296e02db0a"}
__WD_Post ==> Invalid argument [5] : HTTP status = 400 ResponseText={"value":{"error":"invalid argument","message":"invalid argument\n  (Session info: chrome=104.0.5112.102)","stacktrace":"Backtrace:\n\tOrdinal0 [0x009678B3+2193587]\n\tOrdinal0 [0x00900681+1771137]\n\tOrdinal0 [0x00814070+802928]\n\tOrdinal0 [0x00839A76+957046]\n\tOrdinal0 [0x0085D7AC+1103788]\n\tOrdinal0 [0x00838C04+953348]\n\tOrdinal0 [0x0085D9C4+1104324]\n\tOrdinal0 [0x0086DAE2+1170146]\n\tOrdinal0 [0x0085D5C6+1103302]\n\tOrdinal0 [0x008377E0+948192]\n\tOrdinal0 [0x008386E6+952038]\n\tGetHandleVerifier [0x00C10CB2+2738370]\n\tGetHandleVerifier [0x00C021B8+2678216]\n\tGetHandleVerifier [0x009F17AA+512954]\n\tGetHandleVerifier [0x009F0856+509030]\n\tOrdinal0 [0x0090743B+1799227]\n\tOrdinal0 [0x0090BB68+1817448]\n\tOrdinal0 [0x0090BC55+1817685]\n\tOrdinal0 [0x00915230+1856048]\n\tBaseThreadInitThunk [0x7761FA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x77C27A9E+286]\n\tRtlGetAppContainerNamedObjectPath [0x77C27A6E+238]\n"}}
_WD_ElementAction ==> Invalid argument [5] : Parameters:   Command=click   Option=Default

Link to comment
Share on other sites

Hello Danp2... returning to this subject, tried your _WD_SelectFiles UDF, however, I am still having issues either with the element's Xpath and, or the $sSelector.

This is what I tried:         _WD_SelectFiles($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='fuFileName']//input[@name='fuFileName']", $sFilePath)

Below is the XPath and the HTML for the File Upload Control element:

ChroPath defined XPath using id; class; name:  //input[@id='fuFileName']

<input type="file" name="fuFileName" id="fuFileName" style="width:300px;" xpath="1">
<input type="submit" name="btnUpload" value="Upload Excel File" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;btnUpload&quot;, &quot;&quot;, true, &quot;AddFiles&quot;, &quot;&quot;, false, false))" id="btnUpload" style="color:Maroon;font-family:Calibri;font-size:12pt;font-weight:bold;" xpath="1">
<span id="revFileName" style="font-size:15px;visibility:hidden;" xpath="1">Only files of types Excel is allowed</span>
<span id="rfvFileName" style="font-size:15px;visibility:hidden;" xpath="1">File Name is Required</span>
 

SciTE output:

__WD_Post: URL=HTTP://127.0.0.1:9515/session/66a5f2e89ef6071146a5b153267e1bec/element; Data={"using":"xpath","value":"//input[@id='fuFileName']//input[@name='fuFileName']"}
__WD_Post ==> No match [8] : HTTP status = 404 ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"selector\":\"//input[@id='fuFileName']//input[@name='fuFileName']\"}\n  (Session info: chrome=104.0.5112.102)","stacktrace":"Backtrace:\n\tOrdinal0 [0x009678B3+2193587]\n\tOrdinal0 [0x00900681+1771137]\n\tOrdinal0 [0x008141A8+803240]\n\tOrdinal0 [0x008424A0+992416]\n\tOrdinal0 [0x0084273B+993083]\n\tOrdinal0 [0x0086F7C2+1177538]\n\tOrdinal0 [0x0085D7F4+1103860]\n\tOrdinal0 [0x0086DAE2+1170146]\n\tOrdinal0 [0x0085D5C6+1103302]\n\tOrdinal0 [0x008377E0+948192]\n\tOrdinal0 [0x008386E6+952038]\n\tGetHandleVerifier [0x00C10CB2+2738370]\n\tGetHandleVerifier [0x00C021B8+2678216]\n\tGetHandleVerifier [0x009F17AA+512954]\n\tGetHandleVerifier [0x009F0856+509030]\n\tOrdinal0 [0x0090743B+1799227]\n\tOrdinal0 [0x0090BB68+1817448]\n\tOrdinal0 [0x0090BC55+1817685]\n\tOrdinal0 [0x00915230+1856048]\n\tBaseThreadInitThunk [0x7761FA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x77C27A9E+286]\n\tRtlGetAppContainerNamedObjectPath [0x77C27A6E+238]\n"}}
_WD_FindElement ==> No match [8] : Parameters:   Strategy=xpath   Selector=//input[@id='fuFileName']//input[@name='fuFileName']   StartNodeID=Default   Multiple=Default   ShadowRoot=Default

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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