Jump to content

IE DOM Elements visual selector tool


Gianni
 Share

Recommended Posts

Hi Chimp, 

This is very handy and really good tool. The tool works perfectly, captures the red dotted area and copies to the clipboard. My question is about the example: 

Line-18: Clicking on "Existing user? Sign In" works fine 

image.png.cce6f2437ec7752225b144585cb43abf.png

But in Line-22 setting the value didn't work. As you can see from the screenshot, the input box is not filled. 

image.png.983e054208289f559b86305090e3a37d.png

I tried to replace Line-22 as the following (with my limited knowledge), but yet didn't work either: 

; fill the username input
$hDOM_Element = $oIE.document.QuerySelector($sInputUserId)
;$hDOM_Element.value = $sMyUserId
_IEFormElementSetValue($hDOM_Element, "$sMyUserId")

As a reference, these are the values that I read from the tool: 

$sSignIn = "body > div:nth-of-type(2) > header > div > ul > li:nth-of-type(1) > a" ; <-- SigIn element selector here
$sInputUserId = "body > div:nth-of-type(5) > div > form > ul > li:nth-of-type(1) > input" ; <-- UserId input selector here
$sInputPasswd = "body > div:nth-of-type(5) > div > form > ul > li:nth-of-type(2) > input" ; <-- Password input selector here
$sSignInButn = "body > div:nth-of-type(5) > div > form > ul > li:nth-of-type(5) > button" ; <-- Sig In button selector here

 

 

TY.

Link to comment
Share on other sites

Hi @taylansan
Thank you for appreciation,
...when I tried the example the first time, it worked well and the login was prformed regularly, now, trying it again I see that, as you are reporting, some selectors does not find the reference to the input elements .... however I also see that by changing the index from 5 to 4 in the component 'div:nth-of-type(4)' of the following selectors, the script works again, 

$sInputUserId = "body > div:nth-of-type(4) > div > form > ul > li:nth-of-type(1) > input" ; <-- UserId input selector here
$sInputPasswd = "body > div:nth-of-type(4) > div > form > ul > li:nth-of-type(2) > input" ; <-- Password input selector here
$sSignInButn = "body > div:nth-of-type(4) > div > form > ul > li:nth-of-type(5) > button" ; <-- Sig In button selector here

...but this is strange... maybe the web page has some hidden part that dynamically changes some DOM hierarchy .. (?)
I will look into the matter to see if I understand where the cause of this strangeness lies ...
thanks again for reporting.

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Hi @taylansan and also to all of you who have come to read ...

after some debugging I've found the cause of the issue you reported.
The 'subtle' problem was not in the javascript function that retrieves the CSS selector, it was instead caused by a "div" element that I injected into the page, to be used as an highlighter on the element where the right-click was performed.

To highlight the right-clicked element, Instead of poisoning the page by injecting the div element, now I use an innocuous colored 5px dotted outline

well, the "debuged" listing is now posted in first post replacing the previuos one.

Bug reports, suggestion and improovements are welcome.
Thank You

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • 2 months later...

Hi Chimp,

Thanks you so much for this tool!

I'm using it for Autohotkey automation to get selectors... and it works well. (very handy) I also put it in a RPA editor I create, so I'm ask you if for you it's ok I'm using it and also if it 's possibile to convert it in ahk language, and to integrate it in this tool package.

Thanks you for your answer

Arnaud

Link to comment
Share on other sites

Hi Arnaud, I'm glad You find it useful,  of course feel free to use it as you better like.
P.S.
A note to keep in mind is that the derived selector is a "brute force" selector, ie, the returned selector contains the complete path from the root element of the web page down to the target element. So in the eventuality that the page structure is modified, or is dynamically modified by some script, the selector obtained before any changes may no longer be valid after the changes.

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

On 2/12/2018 at 11:20 PM, Chimp said:

Hi Arnaud, I'm glad You find it useful,  of course feel free to use it as you better like.
P.S.
A note to keep in mind is that the derived selector is a "brute force" selector, ie, the returned selector contains the complete path from the root element of the web page down to the target element. So in the eventuality that the page structure is modified, or is dynamically modified by some script, the selector obtained before any changes may no longer be valid after the changes.

Thanks you so much Chimp!

If I understand It use ids... and if it's a page with dynamics ids, it won't run.

I'm also using iMacros to record selectors, and there is an'option to not use ids in the path. Then useful in this case.

Do you think it's possibile to than in your code: "HTML path without ids"?

Link to comment
Share on other sites

Hi @adegard,

 the selector returned by the embedded javascript function doesn't relies on any ID, it returns a "full path" selector that makes no use of intermediate IDs, (this is why I called it a "brute force" selector).
This kind of selector, if from one side has the advantage of being immune to the dynamic ID naming, from the other side is vulnerable to the changes performed on the html tree  structure.

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Hi @chimp ,

Thanks you so much again for your answer (I understoud now)

I'm trying to modify your script to use it as Macro Recorder: so when I Left Click, I save the selector in a Edit form, and then continue to navigate, instead of staying on the same web-page...

 

[EDIT]: Maybe I find the trick... see file. I reload the GUI each time page in loading. It's working!

 

IE_selector_Recorderv3.au3

Edited by adegard
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

×
×
  • Create New...