Discussion:
ie automation
(too old to reply)
g***@pnmac.com
2018-04-16 17:57:05 UTC
Permalink
Hi. There is an IE website I am trying to automate. But there is no ID of the field.. Here is part of the code...

<div class="option" data-selectable data-value="881">Report 1</div>

<div class="option selected active" data-selectable data-value="888">Report 2</div>

<div class="option" data-selectable data-value="889">Report 3</div>

...


I am not sure what the vbs syntax would be to make the Report 3 be selected active and the rest not active.

Please help.

Thanks in advance....
Mayayana
2018-04-16 23:09:12 UTC
Permalink
<***@pnmac.com> wrote

| I am not sure what the vbs syntax would be to make the Report 3 be
selected active and the rest not active.
|

An OPTION is a type of tag. Naming a DIV class as
"option" doesn't make it an OPTION element. Why
aren't you just using OPTION?
Mayayana
2018-04-17 01:50:00 UTC
Permalink
<***@pnmac.com> wrote

....
Looking at this again, it appears you're using some
kind of javascript wrapper class. That's not IE document
object model. Whether you can use VBS with it, I don't
know. But if you're going to use pre-cooked script
libraries you'll probably need to use pre-cooked methods
to access them. In other words, if you're using some
kind of javascript class, like "selectjs" or some such, then
it will have its own methods to deal with selection.

data-* attributes are custom. They have no specific
meaning, only allowing you to store data. If you want
to do something like make #3 "selected" and the others
not, without using OPTION buttons or checkboxes,
then it's up to you. You're doing it from scratch, so you
can do as you like. I guess if it were me I'd do something
like change the border and/or background color when
the item is selected.

If this hasn't been helpful then it might be a good
idea to post more of your code and explain more of
what you're trying to do.
JJ
2018-04-17 09:35:25 UTC
Permalink
Post by g***@pnmac.com
Hi. There is an IE website I am trying to automate. But there is no ID of the field.. Here is part of the code...
<div class="option" data-selectable data-value="881">Report 1</div>
<div class="option selected active" data-selectable data-value="888">Report 2</div>
<div class="option" data-selectable data-value="889">Report 3</div>
....
I am not sure what the vbs syntax would be to make the Report 3 be selected active and the rest not active.
Please help.
Thanks in advance....
If you have MSIE v10+, you can use the `documentQuerySelector()` method of
the `document` object to select the element based on the `data-value`
attribute's value. i.e. with below selector.

.option[data-value="889"]

If your MSIE is older than v10, the `documentQuerySelector()` method is not
yet exist. So, you'll have to manually search for the element by first
selecting all elements whose class name is `option` using
`getElementsByClassName()`. Then enumerate the found elements using a loop
to check the presence of the `data-value` attribute, and if it exists, check
its value.

If you get multiple matches, you might also want to check the element's
contents for a "Report 3" string.

If there are still multiple matches, identify the element based on its
location within the document structure. e.g. the third direct child element
(i.e. relative element index); parent element tag name, ID, class name, or
attribute(s); element index of the parent element; identification of the
next node sibling (which can be a text or an element); etc. There are
numerous properties and combinations which can be used.
g***@pnmac.com
2018-04-17 12:48:55 UTC
Permalink
Hi. My original intent was to find some way to automate a SELECT dropwon that is selectized.. It looks like there may be a better way of doing this.. the selectized dropdowns are new to me. I found out about them only after my vbs code to select/change them directly did not work. Is there another way of selecting/changing selectized dropdowns? It looks like there is an inherent script that runs whenever an option is selected.. based on my research of selectized dropdowns (i am thinking
selectize.js). But is there any way I can select values from a selectized IE dropdown?
Post by g***@pnmac.com
Hi. There is an IE website I am trying to automate. But there is no ID of the field.. Here is part of the code...
<div class="option" data-selectable data-value="881">Report 1</div>
<div class="option selected active" data-selectable data-value="888">Report 2</div>
<div class="option" data-selectable data-value="889">Report 3</div>
...
I am not sure what the vbs syntax would be to make the Report 3 be selected active and the rest not active.
Please help.
Thanks in advance....
Mayayana
2018-04-17 13:42:34 UTC
Permalink
Post by g***@pnmac.com
But is there any way I can select values from a selectized IE dropdown?
I still don't know what you're saying. :)
You want to set the selected item? Or
retrieve a value? This sample should
demonstrate your options:

<HTML><HEAD>
<SCRIPT LANGUAGE="VBScript">

Sub window_onload()
For i = 1 to 8
Set Opt = document.createElement("OPTION")
Opt.text = CStr(i)
Opt.value = CStr(i)
dropbox.add Opt
Set Opt = Nothing
Next
'-- note this will show "6" because the index is 0-based.
dropbox.selectedIndex = 5
End Sub

Sub dropbox_onchange()
Lab1.innerText = dropbox.value

End Sub

</SCRIPT>
</HEAD>
<BODY>
<SELECT ID="dropbox" SIZE=1>
</SELECT>
<LABEL ID="Lab1"></LABEL>
</BODY></HTML>

------------------------------

You can also write subs for click and
doubleclick events. For instance, if you
want multi-select, you could set the size
above to 8, then retrieve the selectedIndex
with each click or onchange, then do
something like set the backcolor red for
that item and keep a record of which
are red. A javascript library is doing the
dsame thing. It's just packaging the details.

You might want to get the help file for this.
It's hard if you don't have a reference because
the document object model is so vast. In this
case you'd want the DHTML help. I keep a
snippet of instructions for just this kind of
thing:

1)
This link should work to get the real ISO of the Win7 SDK
rather than a nonsense "web installer" link:

https://download.microsoft.com/download/2/E/9/2E911956-F90F-4BFB-8231-E292A7B6F287/GRMSDK_EN_DVD.iso

Otherwise, try this and make sure you get the
X86 version:

https://www.microsoft.com/en-us/download/details.aspx?id=18950

2)
Open the ISO using 7-Zip. Inside the Setup\WinSDKDocWin32
folder, take out cab5.cab. Inside that, find and extract this file:

WinSDK_DHTML_hxs_......

3)
Go here to get the HXS to CHM converter:

https://www.jsware.net/jsware/hxs2chm.php5

(You'll also need to download Microsoft's free
HTML Help Workshop.)

4)
With that you can get yourself a WMI CHM reference that
includes all methods, classes, etc. The HXS to CHM converter
might require a bit of setup -- it needs the help workshop
and 7-Zip paths to work -- but once set up the conversion
is basically a 1-click operation.

Anyone who wants other docs might want to convert
the whole shebang: Extract all 6 CABs from the help folder
and use the converter to convert them all to CHM in one
shot. Then you get Windows Script Host, IE DOM, shell....
pretty much anything that MS has docs for -- which takes
forever to look up online -- has a corresponding help file.

With that you end up with full, accessible, local help,
but without the gargantuan bloat of a full Windows SDK
installation, and without the help files being limited
in terms of how you can read them. All Windows versions
support CHM help files as a native format.
g***@pnmac.com
2018-04-17 13:59:11 UTC
Permalink
Post by g***@pnmac.com
Hi. There is an IE website I am trying to automate. But there is no ID of the field.. Here is part of the code...
<div class="option" data-selectable data-value="881">Report 1</div>
<div class="option selected active" data-selectable data-value="888">Report 2</div>
<div class="option" data-selectable data-value="889">Report 3</div>
...
I am not sure what the vbs syntax would be to make the Report 3 be selected active and the rest not active.
Please help.
Thanks in advance....
Hi. Simply trying to call the validation event behind the dropdown. But since this is a selectize dropdown, there is no OnClick event. Here is some info on selectized dropdowns:
https://github.com/selectize/selectize.js/blob/master/docs/api.md
Notice there is no Onclick event. I am simply trying to call maybe the getOption() event. But when I use the followingin my vbscript file I am getting a "object doesn't support this property or method" error.
g***@pnmac.com
2018-04-17 14:33:47 UTC
Permalink
Post by g***@pnmac.com
Post by g***@pnmac.com
Hi. There is an IE website I am trying to automate. But there is no ID of the field.. Here is part of the code...
<div class="option" data-selectable data-value="881">Report 1</div>
<div class="option selected active" data-selectable data-value="888">Report 2</div>
<div class="option" data-selectable data-value="889">Report 3</div>
...
I am not sure what the vbs syntax would be to make the Report 3 be selected active and the rest not active.
Please help.
Thanks in advance....
https://github.com/selectize/selectize.js/blob/master/docs/api.md
Notice there is no Onclick event. I am simply trying to call maybe the getOption() event. But when I use the followingin my vbscript file I am getting a "object doesn't support this property or method" error.
If you need the full code of the selectize.js from my site please let me know. It looks like there is no getoption() event in it, but there are a lot of other events. trying to figure out which one is called when a user selects an option from the dropdown, and call that from my vbscript.
g***@pnmac.com
2018-04-17 14:39:33 UTC
Permalink
Post by g***@pnmac.com
Post by g***@pnmac.com
Post by g***@pnmac.com
Hi. There is an IE website I am trying to automate. But there is no ID of the field.. Here is part of the code...
<div class="option" data-selectable data-value="881">Report 1</div>
<div class="option selected active" data-selectable data-value="888">Report 2</div>
<div class="option" data-selectable data-value="889">Report 3</div>
...
I am not sure what the vbs syntax would be to make the Report 3 be selected active and the rest not active.
Please help.
Thanks in advance....
https://github.com/selectize/selectize.js/blob/master/docs/api.md
Notice there is no Onclick event. I am simply trying to call maybe the getOption() event. But when I use the followingin my vbscript file I am getting a "object doesn't support this property or method" error.
If you need the full code of the selectize.js from my site please let me know. It looks like there is no getoption() event in it, but there are a lot of other events. trying to figure out which one is called when a user selects an option from the dropdown, and call that from my vbscript.
looks like there is indeed an getoption event/function in it. just trying to figure out how to call the functions in the selectize.js using vbs
Mayayana
2018-04-17 14:39:53 UTC
Permalink
<***@pnmac.com> wrote

| Hi. Simply trying to call the validation event behind the dropdown. But
since this is a selectize dropdown, there is no OnClick event. Here is some
info on selectized dropdowns:
| https://github.com/selectize/selectize.js/blob/master/docs/api.md
| Notice there is no Onclick event. I am simply trying to call maybe the
getOption() event. But when I use the followingin my vbscript file I am
getting a "object doesn't support this property or method" error.
|

You're on your own with that. It's a wrapper that has
nothing to do with IE directly, and nothing to do with VBS.
You'll need the selectize.js docs, if there are any. You'll
probably want to ask in a forum for javascript "libraries".

That's a whole different world: People with little scripting
experience who are trying to set up interactive websites.
From what I've seen it seems to be a semi-WYSIWYG
scenario: People trading snippets of code to accomplish
specific things, using vastly complex js wrappers.

This group is for people who are actually doing the scripting
themselves, and using VBS. Many people here know about the
IE document object model, but that doesn't help you if
you're using a custom wrapper.

Continue reading on narkive:
Loading...