cPAMIE/Python String and Date Comparisons

S

Sam R

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()
 
R

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('ascii','ignore'))

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

ie.Quit()



-RB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top