Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

cURL based shell script for Web Application Loign test

Posted on 2012-03-30
11
Medium Priority
?
968 Views
Last Modified: 2012-06-19
Hi

I want to develop a cURL based shell script in Linux (RHEL 5) so that it could connect java based web application login page which is JSP page, login, after login browse few links and tabls inside it and then logs out.

I have seen few tutorials on Internet about cURL but could not make out how to use the cURL based shell script to do the above mentioned task

I want to use this cURL based shell script to automate the web application testing.

If I run command :

curl -cookies http://10.192.34.17:9090/Web/JSP/AstraWorkFlow/login/logon.jsp

It returns the login page similar to the one attached.
login.jsp.txt
0
Comment
Question by:ashuji
  • 6
  • 3
  • 2
11 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 37790164
first: I guess you mean to use --cookie-jar instead of -cookie option to store the cookie in a file
second: you need to use curl a 2'nd time with the previsous stored cookie-jar and pass proper login credentials
0
 

Author Comment

by:ashuji
ID: 37794739
HI

Thanks for suggestion.  I am new to curl and could not exactly understand what you were trying to suggest, is it possible if you can show an example command for loggin into the JSP page I attached in my question.
0
 

Author Comment

by:ashuji
ID: 37795594
I tried what you said, I first ran above mentioned URL with --cookies-jar and then below mentioned URL for loggin in, but it again brings login page instead of showing logged in:

curl -cookies-jar --user-agent "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" "http://192.168.1.10:9090/Web/JSP/WebappWorkFlow/login/logon.jsp?username=test&password=test&press=%20Log%20In%20" > login.html

Please refer to the login file attached in my qustion and suggest what changes may I make.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Accepted Solution

by:
ahoffmann earned 1500 total points
ID: 37795833
# the calls are as follows:
curl --cookies-jar cookie-file ......
curl --cokkie cookie-file .....

NOTE that these options use -- (double dash)
0
 

Author Comment

by:ashuji
ID: 37799792
I tried these, after running second command if I store the output of second command in a file say page.html and then view that file using links command, it shows error "session expired".

Looks like its unable to login,  can you please examin the JSP file I attached, should I used function submit() instead of using "ress=%20Log%20In%20" in my first link ?
0
 

Author Comment

by:ashuji
ID: 37799817
the submit() is a javascript.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 37799887
> the submit() is a javascript.
simplest is to use a proxy or browser plugin and see what this javascript actually sends, then c&p the request to the curl call
with FF you can use LiveHTTPHeader or TamperData add-on
0
 
LVL 26

Expert Comment

by:arober11
ID: 37804184
Alternatively you could use: http://seleniumhq.org/
0
 

Assisted Solution

by:ashuji
ashuji earned 0 total points
ID: 37804887
Selenium does not support IE and my appliaiton only work fine in IE so I can't use Selenium.
0
 
LVL 26

Expert Comment

by:arober11
ID: 37805019
Selenium has a driver to playback written/recorded sessions on IE, but if you want a toll that can record / play back in IE have a look at iMacro's, not as flexible as Selenium but does the basics, see: http://www.iopus.com/imacros/home/ie/welcome-v8.htm.
0
 

Author Closing Comment

by:ashuji
ID: 38098783
Selenium was offers as part of solutin and I already knew that Selenium does not work with IE.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question