Blog

Latest Updates. News. Insights. Ideas.

July 2016 - Sahi Pro

Five Questions Series: Sahi Excel Framework

Posted by | Uncategorized | No Comments

In the third post on the Five Questions Series, we have Sahi Excel Framework today.
Previous posts in this series: Sahi Controller and Sahi Logs.

What is Sahi Excel Framework
The Sahi Excel Framework allows testers to write their test cases in Excel and run it from Sahi. Often a testing team consists of a mix of subject matter experts, some manual testers and testers with some automation experience. Writing tests in the language of the business allows all stake holders to participate and derive value out of the automation process.

Briefly, explain the syntax of Sahi Excel Framework.

Excel_Framework_001

Sahi Excel Framework

The first line of the sheet is the column header. All the blank lines are ignored.
loadSahi loads the Sahi script which has the functions defined in it.
Once you save the file, all the fields under the column Key Word become drop downs and you can choose your functions from the drop down.
[Documentation] row is ignored. You can use the Documentation row to highlight your test case summary.
Arguments are the parameters you pass to the functions.
// comments the step and does not execute the step.

As a domain/subject matter expert, how do I get started?
It is straightforward. Launch Script Editor and click on New > Scenario to launch a new file. Save it and start typing the function name in any of the rows under the Key Word column. You can then select the matching functions from the drop down. Once the functions are selected, enter the arguments for each function.

Now, include the functions library by pressing CTRL and clicking on any function. A Function Details popup will appear displaying the function details. You can view the function library or include it in the Excel file.

Function Details

Function Details

Modify the description for the test case, save the file and play it back.

What precautions will I have to take while creating the functions?
The functions you create will be used by the domain experts. So, make sure that the function names are easy to understand and descriptive at the same time. For example, verifyTotal is better compared to fn1550

How are the logs displayed?
When we run the Scenarios file, the logs clearly show the status of each test case followed by the time taken to run the test case. An overall status is also displayed along with total steps, time and browser details.

Scenarios Logs

Scenarios Logs


Any other questions in your mind?
Feel free to comment or ask your question(s) and we will get back to you.

Five Questions Series: Sahi Logs

Posted by | Uncategorized | No Comments

In the second post on the Five Questions Series, we have Sahi Logs today.
If you have not checked out our previous thread on Sahi Controller, click here.

How do you configure Sahi Logs?
There is no need to configure Sahi Logs separately. It is by default in-built within Sahi Pro. You need not write separate code to setup Sahi Logs. One can access Logs by clicking on Logs link from Sahi Dashboard or Sahi Script Editor. There is an option to view logs from Sahi Controller too.

Launch Logs

Launch Logs

What are the capabilities present in Sahi Logs?
For every script/suite played via Sahi, a log file is created. On clicking on Logs link, a window with the results in HTML is displayed. One can filter the results by using pagination tool or using SQL query.

Pagination_in_Logs

Pagination in Logs

SQL_in_Logs

The core capabilities include
– Logs for every script/suite
– Code Folding: When a function is called in a Sahi script, the logs for the function call are automatically “folded” in the reports
– Color coding of scripts, asserts and functions in red/green based on failure/success
– Script wise and Test Case wise summary
– Graphical representation of all scripts/suites run so far
– Comparison of suites where we can also compare screenshots, logs across scripts
– Detailed network activity for each request response

Code Folding

Code Folding

Graph

Graph


How can we monitor network activity in log files?
One can log HTTP request/response information for all network calls in the script. It is called HAR Logging. HAR refers to HTTP ARchive format of storing request response information. There are two ways to enable HAR Logging — globally or locally.

To enable HAR Logging Globally:
Add har_logging.enabled=true in userdata.properties and restart Sahi for this to take effect.

To enable HAR Logging Locally:
One can locally enable/disable HAR Logging inside a script using _startHarLogging() and _stopHarLogging() APIs.

An example of how HAR Logging would look is as follows:

HAR Logging

HAR Logging


Do logs record everything present in the script?
One has the option to mask certain information from appearing in the logs. Sometimes sensitive information like password, credit card details, bank account details may be entered via script, but we do not want it stored/displayed anywhere. We can then use APIs like _maskLogs to mask information and _unmaskLogs to start displaying steps in the playback logs and the Controller. This is mostly used after _maskLogs API.

Mask and Unmask Logs

Mask and Unmask Logs

How frequently are the logs updated?
Most of us want the logs to be up to date but do not like to refresh the logs page again and again. Auto Refresh Logs feature comes in handy here. By checking the ‘Auto Refresh Logs’ checkbox, the page is refreshed after every 2 seconds till the execution completes.

Auto Refresh

Auto Refresh

Any other questions in your mind?
Feel free to comment or ask your question(s) and we will get back to you.

Five Questions Series: Sahi Controller

Posted by | features, Sahi, tutorials | No Comments

Each week, we will pick a feature of Sahi Pro and hope to highlight its capabilities, benefits and tips on how to use it effectively by asking not more than five questions. We begin our Five Questions Series on Sahi Pro by focusing on Controller.

What is Sahi Controller?
Sahi Controller allows you to interact with Sahi and easily experiment and debug on the browser. Using Sahi Controller, one can easily identify elements, record and playback the scripts. One can launch Controller by pressing ALT and double clicking anywhere on the browser. Kick-start your web automation by recording using Sahi Controller and using the scripts as it is or creating functions out of the recorded snippets of code.

What are the capabilities of Sahi Controller?
Sahi Controller has many powerful capabilities spread across four tabs?—?Record, Playback, Clipboard and Info.

Sahi Controller

Sahi Controller

Record: This tab has controls to record a script. Recording is as easy as entering a name for the script and clicking on Record button. All the actions performed on the browser will be recorded and displayed in ‘Recorded steps’ tab.

One can identify elements using CTRL + mouseover and the Sahi Accessor for the element is displayed. Other actions like Click, Highlight, Set, Hover can also be performed on this element.

Action Buttons

Action Buttons

As seen in the image, each button invokes a        specific API.
  Click: _click API
  Hilight: _highlight API
  Set: _setValue API
  Hover: _mouseOver API

 

 

Assert: One can add assertions to verify if the end result is as expected. To add assertions, CTRL+mouseover an element. Click on ‘Assert’ button to view the possible assertions. It will be displayed in the ‘Evaluate Expression’ tab. Once tested, the assert statements can be appended to the main script.

Evaluate Expression: This can be used to evaluate snippets of Sahi code. Clicking on Test will evaluate the content and display the result (true/false/undefined) in the box below.

Smart dropdown for Evaluate Expression: If one wants to use Sahi API on only a part of the expression in the Evaluate Expression box, select the text and choose an action from the dropdown. This would in turn trigger an API and the results will be displayed in the box below. In this case, the ‘Is Visible’ option to trigger the API ‘_isVisible’ on the element ‘_textbox(“total”)’ is highlighted.

API on an element

API on an element

Playback: Using this tab, one can playback the scripts which are already recorded. Providing a Start URL and checking the checkbox will ensure that the script runs by first navigating to the URL mentioned. If the checkbox is not checked, the script will be executed on the current page without refreshing it.

Sahi Record Tab

Sahi Record Tab

Clicking on each of the links will open the respective window. For ex: Clicking on Logs will display the logs for all the scripts run so far. Clicking on a specific script on that page would display the specific logs.

Clipboard: This tab can be used to store small pieces of information.

Info: This tab shows the basic information of Sahi Controller, mode, browser, operating system and Java.

How are the elements on a web page identified?
Any element on the webpage can be identified by pressing CTRL and mouseover the element. The best Sahi accessor for the element is displayed by default in the Accessor field. One has the option to choose an alternative from the ‘Alternatives’ dropdown. Value shows the value of the current element. Prefix populates the prefix as needed when working with popup windows and multiple domains.

Element Identification

Element Identification

Tell us more about the Relational API and anchoring an element.
Sometimes, an element changes its position/name due to code changes and the whole script fails as the tool is not able to identify the element. To get rid of this issue, a very powerful option is Relational API and anchoring an element.

Let us take the following example where we have to identify the quantity field against “Ruby for Rails”.

Relational API

Relational API

If we identify the field in isolation, the Sahi Accessor reads:
_textbox(“q[1]”).
What if three more book titles are added before Ruby for Rails. The Accessor for the field against Ruby for Rails also changes. To avoid this situation, let us anchor the label ‘Ruby for Rails’ first and then identify the field against it.

Identify Ruby for Rails field

Identify Ruby for Rails field

Anchor the field

Anchor the field

Identify the quantity field

Identify the quantity field

How does recording with ‘Enable Accessor Repository’ on help?
If ‘Enable Accessor Repository’ checkbox is checked, Accessor Repository file text field appears. Once the user clicks on ‘Record’ button, Sahi will record using Accessor Repository. In the ‘Accessor Repository File’ text field, we mention the relative or absolute path to the Accessor Repository file.

Accessor Repository

Accessor Repository

Once a Accessor Repository file is chosen, an element will always be identified first by its AR entry, even when not in recording mode. This prevents the same element from being identified in multiple ways in different scripts.

When elements have been smartly identified using Relational APIs like _near or _under once, newer recordings on those pages will simply use the AR entry, so other users do not need to worry about doing it again or wrongfully using a different identification mechanism.

One important thing to note with Accessor Repository keys is that they must always be in the format $_ALL_IN_CAPS. If this is not followed, the scripts will still work fine, but the values will not come up properly in Script Editor’s context panel.

Any other questions in your mind?

Feel free to comment or ask your question(s) and we will get back to you.

Use fully-loaded Sahi Pro FREE for a month. Download Now Request a Demo