By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,433 Members | 776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,433 IT Pros & Developers. It's quick & easy.

cPAMIE/Python String and Date Comparisons

P: n/a
Hi,
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=cPAMIE.PAMIE()

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

ie.Quit()

Nov 7 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
RB
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.'
else:
print date_txt + ' is not today\'s date.'

ie=cPAMIE.PAMIE('http://www.prophet.net/quotes/stocknews.jsp?symbol=MSFT')
sleep(1) # let the browser start loading...

while ie.getIE().Busy: # wait for the page to fully load
sleep(1)
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.'
else:
print '\"' + search_txt + '\"' + ' not found on page.'

ie.Quit()

-RB

Nov 9 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.