How to test the ability of a website to be logged into.

I need to test the ability of a website to be logged into. Software, script or something to log into a website and send a report by email to report if the website could be logged into or not. needs to run on Windows 2008R2.
LVL 1
jimmylew52Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Justin StearCommented:
Using Python you can do this:

#We need urllib module
import urllib
#These are the user and password parameters, check that field names are the same at the page form and put your real user and password values on myuser and mypassword
params = urllib.urlencode({'user': 'myuser', 'password': 'mypassword'})
#This is the url of the login page, put the real url here
site = "http://www.mysite.com/login.html"
#We save the result of the post in variable f
f = urllib.urlopen(site, params)
#We read the result
result = f.read()
#We print the result, so we can see if we are logged in
print result
#Finished, so we close f
f.close()

Open in new window


From:
https://www.daniweb.com/software-development/python/threads/257012/website-login-testing#post1119769
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jimmylew52Author Commented:
Python run on Linux, I need to run this on Windows 2008R2. We are a windows only shop.
0
Justin StearCommented:
Yes, Python does run on Linux, but you can also run it on Windows.

http://www.winservermart.com/HowTo/Install-Python-In-Windows-Server.aspx
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

jimmylew52Author Commented:
So I see. Install python for windows but i have no idea how to get this to work. I don't see where it is installed. How do I get this script to run?
0
jimmylew52Author Commented:
If I'm doing this right:  
I moved the python directory to c:\python
I savde the script to a file test.py

C:\python\python35\python test.py

I get:

File "test.py", line 12
print result^

SyntaxError: Missing parentheses in call to 'print'
0
jimmylew52Author Commented:
Using python 3:    corrected code

#We need urllib module
import urllib.parse
import urllib.request
#These are the user and password parameters, check that field names are the same at the page form and put your real user and password values on myuser and mypassword
params = urllib.parse.urlencode({'username': 'UID', 'password': 'password', 'submit' : 'login'})
#This is the url of the login page, put the real url here
site = "https://mysite.mycompany.com"
#We save the result of the post in variable f
f = urllib.request.urlopen(site, params)
#We read the result
result = f.read()
#We print the result, so we can see if we are logged in
#print result
result = open('c:\\phython.html',w)
#Finished, so we close f
f.close()

Still getting error:

TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str.

I think the question was answered and I will open a question in python for the answers to the error.
0
jimmylew52Author Commented:
Not complete answer but farther along than I was.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.