Sunday, May 28, 2017

#1 2015-12-03 12:40:20 am

ccstone
Member
Registered: 2009-02-07
Posts: 409

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.

Applescript:


-------------------------------------------------------------------------------------------
# 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 }
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Last edited by ccstone (2015-12-03 12:42:43 am)

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.033 seconds, 10 queries executed ]

RSS (new topics) RSS (active topics)