Help with Login Applescript

I need help with an Applescript. I can get it to go to a website but not enter the credentials I need can someone help me? the code is below

tell application "Google Chrome"
activate
open location "Website"
tell application "System Events"
	keystroke "username"
	delay 1.0
	tell application "System Events"
		keystroke "Password"
		delay 1.0
	end tell
end tell

end tell

It runs, but does not enter the username and password, can someone help? I changed site, username and password for security reasons.

Not that I condone automating password entry (:man_facepalming:t3:), but I would note that using the Fake web browser allows you to carry out web site interactions much more easily and with much more reliability than any other Mac scripting option I’ve tried so far; though I suspect some commercial enterprise testing solutions may exist that provide even more functionality and reliability.

In the past, I’ve tried to script Safari and Chrome to do various things, and anything beyond the most basic seemed to quickly fall foul of timing or interaction issues. At some point I discovered Fake and it made things so much easier. Whilst Safari and Chrome have potentially improved since I last tried, since using Fake, I’ve never gone back to trying with anything else.

Selenium is your friend here.

I don’t know what that means.

The Web Driver? I’d need help learning how to use it.

Do you have keyboard maestro then? It has a action to get elements on the front browser and insert text, click buttons, select from dropdowns, etc.

I have BTT, I can run an apple script from it to open a specific site.

From there is where I’m stuck, how do I get it to automate typing in username and PW into specific location on the site? All youtube vids show creating a dialog box first.

The way I have it setup now is to have the site already logged in.

Right. What I’m trying to point you towards is how you can tell the computer a specific location. Both selenium and keyboard maestro allow you to in effect say get me the login input box and fill it with this data.

Both require an understanding of how websites work (query selectors) but it I don’t know of a way more effective than either option.