469,935 Members | 1,924 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,935 developers. It's quick & easy.

cPAMIE/Python String and Date Comparisons

I am new to Python, and PAMIE has been a very useful tool for my
website functionality testing.
I was wondering if anyone knows how to do the following testcases with
either PAMIE or Python.
1. Load a page http://www.prophet.net/quotes/stocknews.jsp?symbol=MSFT
Verify that the string 'News for MSFT' exists on the page.
Verify that the date '7 November 2005' is equal to today's date.

Your help would be greatly appreciated and here is what I have so far

import cPAMIE

ie.Navigate ('http://www.prophet.net/quotes/stocknews.jsp?symbol=MSFT')


Nov 7 '05 #1
1 1888
Here's an example:

import cPAMIE
import time
from time import sleep
search_txt = 'MSNBC Pairs Chung, Povich'
date_txt = '8 November 2005'

date_tuple = time.strptime(date_txt,'%d %B %Y')
today_tuple = time.localtime()

if date_tuple[:3] == today_tuple[:3]:
print date_txt + ' is today\'s date.'
print date_txt + ' is not today\'s date.'

sleep(1) # let the browser start loading...

while ie.getIE().Busy: # wait for the page to fully load
sleep(1) # extra pauses tend to help.

# Get ASCII string of page data without HTML tags.
page_txt =
str((ie.getIE().Document.body.innerText).encode('a scii','ignore'))

if search_txt in page_txt:
print '\"' + search_txt + '\"' + ' found on page.'
print '\"' + search_txt + '\"' + ' not found on page.'



Nov 9 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

220 posts views Thread by Brandon J. Van Every | last post: by
699 posts views Thread by mike420 | last post: by
40 posts views Thread by Xah Lee | last post: by
6 posts views Thread by Maileen | last post: by
77 posts views Thread by Ben Finney | last post: by
6 posts views Thread by Aswin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.