Cartwheels Posted September 30, 2023 Report Share Posted September 30, 2023 I was playing around with Chrome elements and trying to get to a search box using wording in the element. The code below is what I came up with. It is a little unrefined and slow but may be a good solution in certain circumstances. You may have to tab to get the cursor on the body of the webpage to start off. The example below should put the cursor in the search box on this webpage. <WINDOW ACTIVATE Title="Navigating a webpage using Chrome and elements - Macro Express and Macro Express Pro - Macro Express Forums -" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/> <DELAY Flags="\x01" Time="1"/> <TEXT TYPE Action="0" Text="<CTRLD><SHIFTD>i<SHIFTU><CTRLU>" _COMMENT="Opens Inspect"/> <DELAY Flags="\x01" Time="1.5"/> <TEXT TYPE Action="0" Text="<CTRLD>f<CTRLU>"/> <DELAY Flags="\x01" Time="1"/> <TEXT TYPE Action="0" Text="elSearchField" _COMMENT="Finds element in code. The key here is finding a unique id, name or other. The lettering in blue is what the search will be looking for."/> <DELAY Flags="\x01" Time="1"/> <TEXT TYPE Action="0" Text="<TAB>" _COMMENT="To close find and highlight element"/> <TEXT TYPE Action="0" Text="<ENTER>"/> <DELAY Flags="\x01" Time="1"/> <TEXT TYPE Action="0" Text="<SHIFTD><F10><SHIFTU>" _COMMENT="Opens menu on selected element"/> <DELAY Flags="\x01" Time="1"/> <TEXT TYPE Action="0" Text="ff" _COMMENT="Selects Focus on webpage"/> <TEXT TYPE Action="0" Text="<ENTER>"/> <DELAY Flags="\x01" Time="1.2"/> <TEXT TYPE Action="0" Text="<CTRLD><SHIFTD>J<SHIFTU><CTRLU>" _COMMENT="Closes Inspect"/> Quote Link to comment Share on other sites More sharing options...
rberq Posted September 30, 2023 Report Share Posted September 30, 2023 Interesting. I was not aware of Chrome elements. I played with a National Weather Service page on Chrome, and was able to navigate to a "location" entry field and set focus to the field using your technique. It's unclear to me why I would use elements instead of just "<CTRLD>f<CTRLU>location" on the visible web page. Apparently this and other element features would be useful to developers??? I'm afraid I am in over my head .... Quote Link to comment Share on other sites More sharing options...
Cartwheels Posted October 1, 2023 Author Report Share Posted October 1, 2023 True, most of the time using <CTRLD>f<CTRLU> and also using the tab key is going to be the best way to get your target. There are times though, I've done automation on websites (example bank websites) where they are constantly making little changes that causes the normal way to go haywire. You fix your code only to have it go haywire again a couple months later. I have not employed the above tactic anywhere yet though. Also, I have found locations on websites where using the tab key to get to target can be inconsistent and you just can't find a way that works every time. What brought me to this was that I was trying out Python/ Selenium programming. Those languages and others use elements to get to target. They do it without opening the inspection window though. Quote Link to comment Share on other sites More sharing options...
rberq Posted October 1, 2023 Report Share Posted October 1, 2023 Yes, I have had the same problem where web sites screw up my code with their silly changes. I will keep the elements thing in mind and maybe try it on a couple sites. I seldom if ever use Chrome, so I wonder if similar techniques can work on Firefox. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.