Jump to content

_WD_ElementAction returning an error, cannot determine cause


Recommended Posts

Trying to access innerHTML property of an element.  An element is returned successfully.  HTML text of the element and the console error is included in script comments.

Getting an "unknown command" error, but I cannot see anything wrong with the command.

I have updated my Autoit a couple weeks ago.

 

 

 

 

TkrCpyTest.au3

Link to comment
Share on other sites

To better understand the issue, I would suggest that you use $_WD_DEBUG_Full for the debug level. This will give you the highest logging level. Here's an easy way to do this for a particular section of code --

_WD_DebugSwitch($_WD_DEBUG_Full)
$TkrElement = _WD_GetElementFromPoint($sSession, $avMousePos[0], $avMousePos[1])
Local $sTkrSymbol = _WD_ElementAction($sSession, $TkrElement, 'property', 'innerHTML')
_WD_DebugSwitch()

Also, make sure that you are using the latest release of the UDF to be sure you aren't hitting a problem that has already been resolved.

P.S. Have you tried using _WD_GetMouseElement?

Link to comment
Share on other sites

The debug info from Debug full (COPIED INTO THE SCRIPT COMMENTS) - "HTTP status = 405 ResponseText=HTTP method not allowed" seems to imply that this command does not work on this type of element.  When I Inspect this element in Firefox, and copy the innerHTML, it returns the stock symbol where the mouse is, which is a blue hyperlink.  I have tried to get several other properties, but none of them return a value and have the same error.  It still appears that the element is returned successfully.  Is there another command that could return the innerHTML?

As shown in the console text, my UDF is up to date.

I plan to try _WD_GetMouseElement again later.

Thanks again

TkrCpyTest.au3

Link to comment
Share on other sites

An element ID isn't being returned by _WD_GetElementFromPoint. This is the output from the initial Javascript code --

__WD_Post: URL=HTTP://127.0.0.1:4444/session/29d6044e-e727-42eb-b663-6d8dd51d60fb/execute/sync; Data={"script":"return document.elementFromPoint(arguments[0], arguments[1]);", "args":[-646, 257]}
__WD_Post ==> Success [0] : HTTP status = 200 ResponseText={"value":null}

Looking at the function, it is coded to exit when Null is detected but it still returns a status code indicating success. 🤔

You can see from the output from _WD_ElementAction that the Element ID is missing (it should come between "/element/" and "/property").

__WD_Get: URL=HTTP://127.0.0.1:4444/session/29d6044e-e727-42eb-b663-6d8dd51d60fb/element//property/innerHTML
__WD_Get ==> Unknown Command [18] : HTTP status = 405 ResponseText=HTTP method not allowed
_WD_ElementAction ==> Unknown Command [18] : Parameters:   Command=property   Option=innerHTML

I'm not sure if we will change the behavior of _WD_GetElementFromPoint based on the above. For now, you should examine the result to ensure that it isn't empty.

Link to comment
Share on other sites

TkrElement = __WD_Get: URL=HTTP://127.0.0.1:4444/session/7ba6cd9e-9795-4812-81ed-6f24631eac98/element//property/innerHTML

No, I was looking at the wrong variable:  The returned value of _WD_GetElementFromPoint, is shown above.

 

Link to comment
Share on other sites

P.S. Unconfirmed, but I suspect that the javascript used in _WD_GetElementFromPoint is returning Null because of the negative value you are passing for the X coordinate. If you are going to use MouseGetPos(), then you likely need to translate these coordinates to be relevant for the browser window or use a different setting for MouseCoordMode.

 

Link to comment
Share on other sites

OK, thanks, I will pursue that approach.  I have 2 monitors and am using the left screen for the webpage I am using the mouse on.   My x coordinates on the left screen are (-) and on the right screen (+). 

Also, BTW, I had trouble getting a mouse click work for a hot key:

;HotKeySetEx("{RCLICK}", "TkrToTC2000") ; Right Click mouse hot key for TC tkr capture
;COULD NOT MAKE THIS RIGHT MOUSE CLICK WORK,

HotKeySet("^{RIGHT}", "TkrToTC2000")

I didn't work on this much but plan to get back to it when I can get the access to the tkr symbol working as it will be more convenient.  If you see an obvious error in this, pls comment, but I think I will be able to get it working later.

Thanks,

Doug

 

Link to comment
Share on other sites

Yes, good points.  I have switched back/forth between Mouse modes 1 and 2, and both seem to be working here.  Two monitors and I have been using "absolute" for the most part.  This puts (0,0)  at the top rt of left screen and top left of right screen.  I'm not sure exactly what "client" mode does as I have only tried it a few times.  "Relative" is a complete mystery.

As for the _WD_GetMouseElement , I tried that originally and it wasn't working but I had several issues going.  I suspect it may work fine, and I'll try it out again soon.

I should, maybe, start another subject on this but I'm starting a new computer build to increase speed of my script executions.  In general, I'm wondering what features in Intel CPUs are most important for script execution speed - clock speed, cores, - - -? 

Thanks again, Doug

 

 

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