0

I am trying to automate e few simple processes on the client side of a web service in our internal net. The little program is supposed to handle a few simple clicks, that everyone has to do. The automation works, yet the very first step is driving me nuts. I can´t log into the service.

Here is the button on the site:

<a tabindex="0" class="x-btn x-unselectable x-box-item x-btn-default-small" id="button-1083" role="button" aria-disabled="false" aria-hidden="false" style="margin: 0px; left: 2px; top: 0px; width: 145px; right: auto;" hidefocus="on" unselectable="on" data-componentid="button-1083">

<span class="x-btn-wrap x-btn-wrap-default-small " id="button-1083-btnWrap" role="presentation" style="table-layout: fixed;" data-ref="btnWrap" unselectable="on"><span class="x-btn-button x-btn-button-default-small x-btn-text    x-btn-button-center " id="button-1083-btnEl" role="presentation" data-ref="btnEl" unselectable="on"><span class="x-btn-icon-el x-btn-icon-el-default-small  " id="button-1083-btnIconEl" role="presentation" data-ref="btnIconEl" unselectable="on">

</span><span class="x-btn-inner x-btn-inner-default-small" id="button-1083-btnInnerEl" data-ref="btnInnerEl" unselectable="on">Login</span></span></span></a>

I can find the button on the website with

Document.getElementById("button-1083") 

but I can´t simulate the "click".

Any help is appreciated greatly.

Ryan Wilson
  • 10,223
  • 2
  • 21
  • 40
xiles
  • 1
  • 1
  • Please provide us more code. –  Jan 21 '19 at 13:47
  • If you are not able to click programatically using .Click() than try to make a sample html page with only 1 button and try to click it from your code to check whether you are able to click it or not. If not than it can be possible that some security settings in IE preventing you to click the control. In that situation, You need to allow the JS script related settings and other relevant settings in IE to make it work. Let us know about your testing result. We will try to provide you further suggestions. – Deepak-MSFT Jan 22 '19 at 03:07
  • I am able to click other buttons on the exact same page. Those buttons have an onclick property and work fine. So i assume it cannot be security settings. I do not fully understand how the above mentioned button works. It changes the class property when I press the button with the mouse, or do a mouseover. When I release the mouse button and "fire" the event it changes the tabindex to 1, i think. – xiles Jan 23 '19 at 06:52
  • Maurice, what kind of code are you interested in for helping me? The button is nested in a container. The container doesn´t seem to be the issue, as i can control an input box above the button concerned here. – xiles Jan 23 '19 at 07:07

2 Answers2

0

If you are using VBScript as your title says, you can use:

Document.getElementById("button-1083").Click()

else if you are using javascript as you have that listed in your tags:

document.getElementById("button-1083").click();

This is a possible duplicate of (Click Button on Webpage via VBScript?)

Ryan Wilson
  • 10,223
  • 2
  • 21
  • 40
0

If we see the code than we can find that it is not the actual button input but it is /a link tag which has role as button and which contains span tags.

Other thing is to notice that all tags contains unselectable="on" style in it. Which makes it non selectable. User can only select it if start selecting from outside.

Reference:

unselectable attribute for div (HTML4 & HTML5)

We can see that only 1 span tag contains the Login text in it. So if your goal is to click it than you can try to click using it's span id which is button-1083-btnInnerEl

I made a test on my side with code below. I use the same HTML from your original post.

Dim IE As InternetExplorer
Dim URL As String
Dim btnGo As Object

Sub Macro_1()

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
URL = "C:\Users\Administrator\Desktop\sample.html"
IE.navigate (URL)

Do
DoEvents
Loop Until IE.readyState = 4



Set btnGo = IE.document.forms(0).all("button-1083-btnInnerEl")
btnGo.Click

End Sub

I am able to click Login on web page. You can see in output below.

enter image description here

You can make a test on your side and let me know, If I missunderstand your requirement. I will try to correct myself.

Deepak-MSFT
  • 10,379
  • 1
  • 12
  • 19