Question

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>
Was it helpful?

Solution

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>

OTHER TIPS

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!

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top