I am doing a project which behaves like autologin using xdotool. Below is the bash script command:
if [ "$url" == "https://github.com/login" ]; then
sleep 5
xdotool type $WUSER
xdotool key Tab
xdotool type $DECPASS
xdotool key Return
else
exit 1
fi
There will be a default URL for login page (eg: https://github.com/login), which will run this script below on the browser startup:
- automatically type in the username
- press tab key
- type in the password
- click enter
At the moment I use sleep 5 (wait 5 seconds until running the next command) which is a bit hacky because some pages load really fast and others don't.
Question
How to check first if the page is fully loaded before running the command? Maybe it will look something like this, or if there's some other better methods.
if [ "$url" == "https://github.com/login" ]; then
if [ <page is fully loaded> ]; then
xdotool type $WUSER
xdotool key Tab
xdotool type $DECPASS
xdotool key Return
else
<wait until page loads>
fi
else
exit 1
fi