Smile – Web Window with Log-In

Hey Folks,

I’ve finally got a working example of logging into a site with Smile’s web window class.

Obviously the username and password are dummies, and I’ve commented-out the submit-button-click.

With the correct bonafides it successfully logs into the site.

I’m surprised there are not many examples on the net of doing this and related tasks with Smile.

Fortunately Emmanuel and François helped me enough to figure this out.


-------------------------------------------------------------------------------------------
# Working Load Web Window with Log-In
-------------------------------------------------------------------------------------------
# REQUIRES Smile » http://www.satimage.fr/software/en/downloads/index.html
# I'm using the latest Smile beta on OSX 10.11.1
-------------------------------------------------------------------------------------------

set theurl to "https://www.mycardioforlife.com/customer-login"
set webWindow to make new web window with properties {path name:theurl, script:webWindowScript}

-------------------------------------------------------------------------------------------
script webWindowScript
	on pageloaded webWindow
		
		set webWindowUserName to "The-User-Name"
		set webWindowPassword to "The-Password"
		
		set jsStr to "
document.forms['loginform']['Username'].value = '" & webWindowUserName & "';
document.forms['loginform']['password'].value = '" & webWindowPassword & "';
// document.getElementById('#btnSubmit').click();
"
		callJavaScript webWindow script jsStr
		
	end pageloaded
end script
-------------------------------------------------------------------------------------------


Chris


{ MacBookPro6,1 · 2.66 GHz Intel Core i7 · 8GB RAM · OSX 10.11.1 }
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯