dgendrud Posted August 11, 2023 Share Posted August 11, 2023 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 More sharing options...
Danp2 Posted August 11, 2023 Share Posted August 11, 2023 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? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
dgendrud Posted August 11, 2023 Author Share Posted August 11, 2023 OK, thanks I tried the _WD_GetMouseElement first but could not get it to work. I'll start using DEBUG full. Link to comment Share on other sites More sharing options...
dgendrud Posted August 12, 2023 Author Share Posted August 12, 2023 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 More sharing options...
Danp2 Posted August 12, 2023 Share Posted August 12, 2023 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. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
dgendrud Posted August 12, 2023 Author Share Posted August 12, 2023 I think you're saying to check to make sure that the returned value from _WD_GetElementFromPoint is empty. Yes it is. So that is why the _WD_Get statement is not working. Do I have a workaround? Link to comment Share on other sites More sharing options...
dgendrud Posted August 12, 2023 Author Share Posted August 12, 2023 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 More sharing options...
Danp2 Posted August 12, 2023 Share Posted August 12, 2023 Yes.... don't call _WD_ElementAction without a valid element ID. 😉 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted August 12, 2023 Share Posted August 12, 2023 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. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
dgendrud Posted August 12, 2023 Author Share Posted August 12, 2023 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 More sharing options...
dgendrud Posted August 13, 2023 Author Share Posted August 13, 2023 My _WD_ElementAction issue for getting the symbol under the mouse (inner html) is solved. Switching to the monitor with positive coordinates resolved it. Thanks a lot for the help with this. Doug Link to comment Share on other sites More sharing options...
Danp2 Posted August 13, 2023 Share Posted August 13, 2023 You really should look into using the correct setting for MouseCoordMode. Also, it would be interesting to know more about why _WD_GetMouseElement didn't work for you. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
dgendrud Posted August 15, 2023 Author Share Posted August 15, 2023 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 More sharing options...
Danp2 Posted August 15, 2023 Share Posted August 15, 2023 Cores won't have any effect since Autoit is single threaded. Clock speed and storage speed (SSD vs HD) is likely where you will see the biggest gain. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
dgendrud Posted August 15, 2023 Author Share Posted August 15, 2023 Exactly what I need to know Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now