There is no one or absolute way for building test automation. I use the following approach to choose the technology or tool I use to build my test automation framework:
- Open source
- Most popular in the community
- Regular maintenance by community
- Able to solve my problem
- Log into a web interface
- Fill in details as SQL statement to be run into a web form
- Kicking off the exporter script via web form
- Exporter script will execute the SQL statement and generate the output as text file
- The text file will be sent to a FTP account
- SpecFlow
I use this BDD tool for user readability purpose to explain the flow of the test scenarios
- Selenium web driver in .NET
This is used to do the web interface interactions such as log in, filling in SQL details, and kicking off the tests
- WinSCP
To log into the FTP server
- Batch script
To run WinSCP.exe in order to delete and download files from FTP server
- C# code
Using the Process class to run the batch script. It is also used to verify and display the output.
- NUnit
To verify output
Scenario: Kicking off PageUp ExporterGiven I delete the output fileWhen I log into Feature ManagerAnd I kick off an Exporter process with query “SELECT * from dbo.applicant where semail like ‘%test%’ and linstid = ‘543’”Then I verify that the file is exportedAnd we verify that the file has “60” rowsAnd we verify that the file has “100” delimitersAnd we verify that the email address contains “test”And we verify that the file size is “19484”
The step definitions for the 1st step consists of C# code that calls the batch file:
[Given(@”I delete the output file”)]public void GivenIDeleteTheOutputFile(){string fileName = @”c:PageUpOutexporterTest..txt”; File.Delete(fileName);Process p = new Process();p.StartInfo.UseShellExecute = false;p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = “C:\exporter_delete.bat”;p.Start();}
The batch file calls a text file which WinSCP needs:
@ECHO OFFcd c:Program Files (x86)WinSCPstart WinSCP.exe /console /script=c:exporter_delete.txt:END
The text file consists of more MS DOS commands to perform the operation on the FTP server:
# Automatically abort script on errorsoption batch abort# Disable overwrite confirmations that conflict with the previousoption confirm off# Connect using a password# open sftp://user:password@example.com -hostkey=”ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx: xx:xx:xx:xx:xx:xx” # Connectopen sftp://tuneup:iScWxPjvi7Oal6m@securestorage.pageuppeople.com -hostkey=”ssh-dss 1024 9e:bd:6f:c8:f9:68:18:81:f0:50: ce:71:dd:d6:53:2e” cd /# Download file to the local directory d:rm *.txt# Disconnectclose# Exit WinSCPexit
Leave a Reply