Press login button in a website

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Press login button in a website

23 Jun 2021, 07:23

Hi,

I am following some YouTube totorials on COM.
I learned how to input certain thing by finding the ElementByID
However, in the example on YouTube, the websites' login button also had an ID, but the website
I'm testing it with does not.

Does anyone know how to fix this ?

If I inspect the button, it shows this html code:

Code: Select all

<button class="btn btn-block btn-primary btn-lg" type="submit" data-bind="disable: _loading()">
<span data-i18n="login_submit_button">Inloggen</span>   <------------------- I THINK I NEED TO DO SOMETHING WITH THIS
<i class="fa fa-caret-right" data-bind="visible: !_loading()"></i> 
<div class="dot-opacity-loader" style="display: none;" data-bind="visible: _loading()">
<span></span>
<span></span>
<span></span>
</div>
</button>
This is the code that works already:

Code: Select all

^q::
Url := "https://login.parcelpro.nl/"
Username := "[email protected]"
Password := "fakepassword.com"

web_browser := ComObjCreate("InternetExplorer.Application")
web_browser.Visible := True
web_browser.Navigate(Url)

while web_browser.busy
{
	sleep,500
}
Sleep, 1000
username_input := web_browser.document.getElementbyID("email")
username_input.value := UserName
username_input := web_browser.document.getElementbyID("password")
username_input.value := Password

return
teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Press login button in a website

24 Jun 2021, 12:18

Try web_browser.document.querySelector("button.btn-lg").click()
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Press login button in a website

25 Jun 2021, 01:12

teadrinker wrote:
24 Jun 2021, 12:18
Try web_browser.document.querySelector("button.btn-lg").click()
Hi @teadrinker , thanks for your reply.

Unfortunately it doesn't work, for some reason it clear the username and password fields:
Attachments
Schermafbeelding 2021-06-25 081021.jpg
Schermafbeelding 2021-06-25 081021.jpg (21.66 KiB) Viewed 721 times
teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Press login button in a website

25 Jun 2021, 07:00

@WalkerOfTheDay
When I click this button by the mouse, the same happens, cos these password/login are wrong (I suppose).
Also you can try this:

Code: Select all

WinActivate, % "ahk_id" . web_browser.hwnd
web_browser.document.querySelector("button.btn-lg").focus()
Send, {Enter}
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Press login button in a website

25 Jun 2021, 08:15

That's odd. If I enter the correct credentials in Internet Explorer, I keep getting this error.

When I do it in Mozilla FireFox, strangely enough the credentials work.

I think someway Internet Explorer isn't supported for this website.
teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Press login button in a website

25 Jun 2021, 08:21

WalkerOfTheDay wrote: I think someway Internet Explorer isn't supported for this website.
It is possible.
aifritz
Posts: 301
Joined: 29 Jul 2018, 11:30
Location: Germany

Re: Press login button in a website

27 Jun 2021, 04:18

Code: Select all

web_browser.document.querySelector("button.btn-lg").submit()
or perhaps just a submit?
teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Press login button in a website

27 Jun 2021, 09:18

@aifritz, good idea, I forgot about submit. Or like this: web_browser.document.querySelector("form.pt-3").submit()
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Press login button in a website

30 Jun 2021, 01:50

@teadrinker and @aifritz

Thanks for your suggestions. Unfortunately this website doesn't seem to accept logins from Internet Explorer,
even manually with the correct credentials it doesn't work.

So I cannot test your code :x

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: aitaixy, Nerafius, RandomBoy and 179 guests