Jump to content
Macro Express Forums

Navigating a webpage using Chrome and elements


Recommended Posts

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"/>

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...