The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

20130305

sahi - automated web form submit using values from tab separated csv file, in linux

here's a simple sahi script that reads a tab separated csv file into a 2 dimensional array, logs into mywebsite.com, navigates to a user profile page, and updates user input text field values for "first name" and "last name", saves (submits the user profile form), then logs out of mywebsite.com:

########test_read_file_and_update_user_name.sah###############

// start URL: http://mywebsite.com/login.jsf

var $ar = _readCSVFile("/home/me/userprofile.csv", "\t");

_setValue(_textbox("username"), "myusername");

_setValue(_password("password"), "mypassword");

_click(_button("log in"));

_click(_link("User profile"));

_setValue(_textbox("firstname"), $ar[0][0]);

_setValue(_textbox("lastname"), $ar[0][1]);

_click(_button("Save"));

_click(_link("log out"));


##########################################################

start URL is a comment showing what you manually paste into the sahi controller > playback > start url field

userprofile.csv looks like this in a text editor:
"nick"    "humphrey"

see part 1 of this tutorial:
sahi - automated web data extraction, export to tab separated csv file, in linux

No comments:

Post a Comment