HTML5 Click / getElementByID not working on SAP Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Sonic1305
Posts: 12
Joined: 09 Oct 2017, 07:58
Contact:

HTML5 Click / getElementByID not working on SAP

09 Oct 2017, 08:29

Hello,

I tried to automate a process on our SAP Webinterface but it did not work. I wanted a left-sided menu to show and to click into the search bar which appeared at the bottom with one Hotkey.
I used the following code which worked well on other Websites like Google calendar but not on SAP.

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

	^!s::
wb := ComObjCreate("InternetExplorer.Application")
wb.Visible := True
wb.Navigate("http://URL.com")
while wb.busy
sleep 100
btn := wb.document.getElementById("__button0")
btn.Click()

Return

If it could help, here is the code of the button I try to click:

Code: [Select all] [Download] (Untitled.html)GeSHi © Codebox Plus

<div tabindex="0" title="Work-Center-Navigation einblenden/ausblenden" class="sapBUiBelNavIcon sapBUiIcon-shellMenu sapUiIconMirrorInRTL" id="__button0" role="button" style="cursor: pointer" aria-label="Work-Center-Navigation einblenden/ausblenden" data-sap-ui="__button0"></div>


I would really appreciate some help because I need this for work.

Thanks in advance,

Sonic
"Declare variables, not war."
teadrinker
Posts: 307
Joined: 29 Mar 2015, 09:41

Re: HTML5 Click / getElementByID not working on SAP

09 Oct 2017, 14:23

Hi, Sonic1305,
Launch this code:

Code: [Select all] [Download] GeSHi © Codebox Plus

wb := ComObjCreate("InternetExplorer.Application")
wb.Visible := True
wb.Navigate("http://URL.com") ; specify the correct url
while wb.busy
sleep 100
btn := wb.document.getElementById("__button0")
MsgBox, % IsObject(btn)
try wb.Quit()

What number appears in MsgBox?
Sonic1305
Posts: 12
Joined: 09 Oct 2017, 07:58
Contact:

Re: HTML5 Click / getElementByID not working on SAP

10 Oct 2017, 02:02

Hey teadrinker,

Thank for the help. The Number 1 appears but I had to modify the sleep time because the Webinterface wasn´t loading fast enough. I tried that yesterday already but I still don`t know what to do.
"Declare variables, not war."
teadrinker
Posts: 307
Joined: 29 Mar 2015, 09:41

Re: HTML5 Click / getElementByID not working on SAP

10 Oct 2017, 16:32

Ok, if your IE object is supposed to be visible, we can try to emulate the click via ControlClick:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Sonic1305
Posts: 12
Joined: 09 Oct 2017, 07:58
Contact:

Re: HTML5 Click / getElementByID not working on SAP

11 Oct 2017, 02:07

I tried your Code but it was not working. I also tried other Buttons of the Website but None of them worked.

How can a whole Website be resistent against simulated button clicks?
"Declare variables, not war."
teadrinker
Posts: 307
Joined: 29 Mar 2015, 09:41

Re: HTML5 Click / getElementByID not working on SAP

11 Oct 2017, 12:04

Can you see the button you want to click when the site opens, or you need to scroll the page?
getBoundingClientRect() does not always work, check it:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Sonic1305
Posts: 12
Joined: 09 Oct 2017, 07:58
Contact:

Re: HTML5 Click / getElementByID not working on SAP

12 Oct 2017, 01:58

Ok I noticed that the coords do not always show, but even if the button is visible. It only works if the URL I specified brings me to the logon page first and after I logged in it works but if it opens directly, it won´t show the coords.
So how should I continue now? And the button is at the top left corner.

Thank you for your Patience.
"Declare variables, not war."
teadrinker
Posts: 307
Joined: 29 Mar 2015, 09:41

Re: HTML5 Click / getElementByID not working on SAP

12 Oct 2017, 03:30

the coords do not always show
Do you mean, the MsgBox does not appear? It means that the button with ID "__button0" was not found, I can't say, why. It's necessary to see the page.
It only works if the URL I specified brings me to the logon page first and after I logged in it works

Don't you want to consider the way: first to navigate to the logon page, to log in through filling the form, and then go to the needed page and trying to get the button?
Sonic1305
Posts: 12
Joined: 09 Oct 2017, 07:58
Contact:

Re: HTML5 Click / getElementByID not working on SAP

12 Oct 2017, 03:42

The MsgBox does appear, but with the coords 0.0000/0.00000. And the way the coords did show correctly does unfortunately not fix the Problem that the button click does not work :/

I would show you the page, but (I don´t know if you know SAP?) you don´t have Access to it because it is a Business Software.
"Declare variables, not war."
teadrinker
Posts: 307
Joined: 29 Mar 2015, 09:41

Re: HTML5 Click / getElementByID not working on SAP

12 Oct 2017, 06:29

Ok, do you know, what Accessible Info Viewer is and how to use it?
Sonic1305
Posts: 12
Joined: 09 Oct 2017, 07:58
Contact:

Re: HTML5 Click / getElementByID not working on SAP

12 Oct 2017, 06:34

I've not heard about it yet.
"Declare variables, not war."
teadrinker
Posts: 307
Joined: 29 Mar 2015, 09:41

Re: HTML5 Click / getElementByID not working on SAP

12 Oct 2017, 07:07

Accessible Info Viewer
Open your site in Internet Explorer, then launch Accessible Info Viewer. The window will appear:

Image

You need to drag-n-drop the crosshair from the top-left corner of the window to the button in IE. The information about the button will appear in the window. Then get the screenshot of the window and send it here.
Sonic1305
Posts: 12
Joined: 09 Oct 2017, 07:58
Contact:

Re: HTML5 Click / getElementByID not working on SAP

12 Oct 2017, 07:32

Image
Attachments
Unbenannt.JPG
Unbenannt.JPG (51.37 KiB) Viewed 198 times
"Declare variables, not war."
teadrinker
Posts: 307
Joined: 29 Mar 2015, 09:41

Re: HTML5 Click / getElementByID not working on SAP

12 Oct 2017, 09:06

At first try the next code:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Sonic1305
Posts: 12
Joined: 09 Oct 2017, 07:58
Contact:

Re: HTML5 Click / getElementByID not working on SAP

12 Oct 2017, 09:28

It Failed to get an accessible object.
There must be a way to Control this....
"Declare variables, not war."
teadrinker
Posts: 307
Joined: 29 Mar 2015, 09:41

Re: HTML5 Click / getElementByID not working on SAP

12 Oct 2017, 09:43

Ok, one more:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Sonic1305
Posts: 12
Joined: 09 Oct 2017, 07:58
Contact:

Re: HTML5 Click / getElementByID not working on SAP

13 Oct 2017, 01:58

No MsgBox is appearing and the target button looks like he is selected in some way.
Maybe this is the first glimmer of hope?
"Declare variables, not war."
teadrinker
Posts: 307
Joined: 29 Mar 2015, 09:41

Re: HTML5 Click / getElementByID not working on SAP

13 Oct 2017, 02:47

Maybe. :) Selected, but not pressed?
Sonic1305
Posts: 12
Joined: 09 Oct 2017, 07:58
Contact:

Re: HTML5 Click / getElementByID not working on SAP

13 Oct 2017, 03:12

Not pressed.
"Declare variables, not war."
teadrinker
Posts: 307
Joined: 29 Mar 2015, 09:41

Re: HTML5 Click / getElementByID not working on SAP  Topic is solved

13 Oct 2017, 16:55

Let's try to find out button's coordinates and then to use ControlClick once again.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], honyakusha, Odlanir, omareg94 and 9 guests