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
IT, computer and programming tutorials and tips that i couldnt find anywhere else using google, from my daily work as a Senior Developer of solutions using Java and Linux.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment