views:

450

answers:

3

Hi everyone,

I want to get the business hours from ScotiaBank branches that are near to me.

The base-URL is: http://maps.scotiabank.com/

I then,

Click on the "Branches" radiobox.

Click on the "Open Saturdays" checkbox.

Enter "B3H 1M7" (my postal code) into the search box.

Click the Search button.

Click on the first result that pops up (Micmac shopping centre).

Store the business hours as a variable (called businessHours).

And now I'm stuck.

How can I export the data that I assigned to the variable to a text file or anywhere else where I can view it later? I'm not sure if this is even possible with Selenium, but if it's not, can you tell me an alternative of how I could do this?

Below is the HTML code for the current Selenium script that I have.

<tr>
    <td>open</td>
    <td>/en/index.php</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>rb_branch</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>cb_saturday</td>
    <td></td>
</tr>
<tr>
    <td>type</td>
    <td>input_address</td>
    <td>B3H 1M7</td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>btn_search_address</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>result0</td>
    <td></td>
</tr>
<tr>
    <td>storeTextPresent</td>
    <td>Mon:    9:30 AM - 5:00 PM    Thu:    9:30 AM - 8:00 PM
<br />Tue:    9:30 AM - 5:00 PM    Fri:    9:30 AM - 5:00 PM
<br />Wed:    9:30 AM - 5:00 PM    Sat:    9:00 AM - 1:00 PM</td>
    <td>businessHours</td>
</tr>
+1  A: 

Here's an idea - if you can't write to a file or DB, you can certainly write quick little web app, and have selenium enter the data and click Submit there!

Don Branson
+1  A: 

Assuming your wanting to only work with Selenium Core and/or IDE and you want to persist this information, then you might try sending it to some type of free online service via javascript call. Selenium can execute an arbitrary piece of javascript via an eval call (example here).

One possible suggestion would be a twitter account (or other free online public service with a simple API). A modification of the bookmarklet that Twitlet produces could post to a twitter account any information you want.

Another option might be a google document or some other online note service.

If you don't really need Selenium to persist the information, but want it aggregated and shown at the end of the execution, you might store each set of business hours in a variable, appending as you go, and then have your last action be to evaluate javascript that will popup an alert box with the results. You could then manually consume the data in the alert box.

Just some ideas. Good luck.

EDIT-

Here is an example of storing a value and retrieving it along with executing arbitrary javascript via the eval and runscript methods on the google homepage:

<tr>
    <td>open</td>
    <td>/</td>
    <td></td>
</tr>
<tr>
    <td>type</td>
    <td>q</td>
    <td>dog</td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>btnG</td>
    <td></td>
</tr>
<tr>
    <td>storeValue</td>
    <td>q</td>
    <td>searchWord</td>
</tr>
<tr>
    <td>assertValue</td>
    <td>q</td>
    <td>${searchWord}</td>
</tr>
<tr>
    <td>assertEval</td>
    <td>alert(&quot;${searchWord}&quot;);</td>
    <td>null</td>
</tr>
<tr>
    <td>runScript</td>
    <td>alert(&quot;${searchWord}&quot;);</td>
    <td></td>
</tr>
<tr>
    <td>assertAlert</td>
    <td>dog</td>
    <td></td>
</tr>
Benjamin Lee
Thanks Benjamin.I'll leave the question open for a while longer to see if any one else has any more alternatives.
Dennis
No problem. Good luck in finding a solution. If you find one outside of this forum, please post it for everyone.
Benjamin Lee
I just checked out the example but it didn't help me because the reply for that post doesn't say how to call the javascript function.
Dennis
Please see edit. I hope that helps.
Benjamin Lee
The edit was more helpful, but I'm afraid I won't be able to use javascript unless I learn it. And right now I've been learning a lot of new stuff that I'd like to take a break from learning something completely new.
Dennis
I posted this question somewhere else as well.http://clearspace.openqa.org/message/57860#57860It hasn't been solved there either. Hopefully this will be solved with an easy solution. I've searched for this stuff online but the field seems to be fairly untouched.
Dennis
A: 

You can export your test from Selenium IDE to use with Selenium RC. Then, using the programming language of your choice you can write out to a file, or to a database.

Dave Hunt