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.

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.

20130317

in our company's application we have a page in our admin backend where we can run sql queries. we display the results in a table, so i made a script that runs an sql query then checks to see if at least one of the select parameters is visible. here's the code:

20130315

in our company's application we send out an email asking users to confirm their new membership application by clicking on a link:http://prod.mycompany.com/MembershipApplication/validateMembershipApplication?id=9354&email=me@example.com

but when i'm testing this usecase in sahi, i don't want to click on a production link, i want to use a link on my test server:http://localhost/MembershipApplication/validateMembershipApplication?id=9354&email=me@example.com

so here's how i replace the prod link with localhost:
#######################

when i use sahi to click on a link in gmail, gmail opens a confirm dialogue asking me to confirm to leave the page ("Leave page" button). here's the code to automatically accept the "Leave page" option:

20130313

i am currently making sahi tests for registering member applications for my employer and i needed a way to automatically generate a GLN number with a correct control/check digit, so here's my solution:

NOTE: when you run a sahi script that opens a new window, a new Sahi Controller window opens up for that new window. there you can find the _popup(identifier) (window title) in the "Prefix" field in the "Record" tab of that new Sahi Controller window.

20130307

this might not be what you were searching for, but apparently, only sahi pro offers encrypted passwords.

i am going to start on some admin scripts, testing our admin backend, but i don't want to put our admin user name and password in a sahi script file, so to get around this i'm going to make the scripts start after i've already manually logged in to the admin backend, i.e. no login function.

the limitation with this is that they can't be run in a suite. i have to start the sahi dashboard, choose my admin script, "Set", then log in with my admin credentials AND THEN "Run" the script.

UPDATE:
you can also semi-automate this by using sahi's "_prompt" functionality:_setValue(_textbox("username"), _prompt("Enter your username:"));_setValue(_password("password"), _prompt("Enter your password:"));

UPDATE 20130325:
you can also fully automate tests by reading admin login credentials (username, password) from a file, WITHOUT committing the contents of the file to version control.

20130305

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:

here's a simple web data extraction script that logs into mywebsite.com, navigates to a user profile page, extracts the input text field values for "first name" and "last name", saves the values in a tab separated csv file, then logs out of mywebsite.com:

eventually, after reading the sahi documentation, i noticed that images can also be identified by title. and jsf/richfaces also allows setting the title value dynamically :)<h:graphicImage value="/images/icons/delete.gif" title="#{trq.receiverRefId}" style="border:0" />

and here's the sahi script code:_click(_image($tr_id));

then we don't need any proximity qualifiers and we can precisely match any transport request in the subtable! :)