您的位置:首页 > 编程语言 > Python开发

python3下的IE自动化模块PAMIE

2011-12-17 16:10 495 查看
PAMIE是Python下面的用于IE的自动化模块,支持python2和python3,python3的下载地址:http://sourceforge.net/projects/pamie/files/PAMIE/PAM3.0%20for%20Python%203.0/
PAMIE是Python Automated Module for I.E. 的缩写。

简单的例子:

# To use Pamie you must first create a new script or text file that you can saveas mytest.py.
# This will import the cPAMIE class file so you can use it's methods
from cPAMIE import PAMIE
# create a new instance of the PAMIE object
ie = PAMIE( )
# Lets navigate to google - this methods takes a string as the URL
ie.Navigate("'www.google.com" )
ie.textBoxSet("q", "python" ) #control name, value
# Now Submit the form.
ie.buttonClick("'btnG" )


但是我们实际使用中,实际上会碰到许多的控件。如,input ,radio ,checkbox.

下面针对不同控件给出函数列表, 大家看名字大概就应该明白是干什么的. 权当手册使用吧,呵呵 :

状态控制
实际应用中,需要考虑IE的状态,比如访问一个网页,随即进行操作,在网页未下载完成的情况下,容易出错
PAMIE 则考虑到下面的情况

_wait() : 等待整个页面下载完成

_frameWait() : 等待一个frame下载完成

_docGetReadyState: 获取文档对象的状态

复制代码

TextArea

getTextArea (name): 获取一个textarea,可能使用 id,name 或者 index

getTextAreaValue(name, attribute): 获取一个textarea的属性值

getTextAreasValue() 获取所有textarea

setTextArea(name): 给textarea赋值

textAreaExists(name): 查看指定名称的textarea 是否存在

复制代码

Input

getTextBox(name):

getTextBoxValue(name, attribute):

getTextBoxes():

getTextBoxesValue()

setTextBox( name, value):

getInputElements():

复制代码

Button

buttonExists(self, name): 检查一个button是否存在

clickButton(self, name): 点击一个按钮, name 可以是 name,id,index甚至是value属性的值

clickButtonImage(self, name): 同上,点击一个图片按钮

复制代码

Radio

getRadioButton(name):

def getRadioButtonSelected(name):

getRadioButtonValues(name):

getRadioButtons():

复制代码

CheckBox

checkBoxExists(self, name): 检查一个单选框是否存在

复制代码

ListBox

getListBox(name):

getListBoxItemCount(name):

getListBoxOptions(name):

getListBoxSelected(name):

getListBoxValue(name, attribute):

listBoxUnSelect(name, value):

selectListBox(name, value):

复制代码

Image

getImage( name):

getImageValue(name, attribute):

getImages():

getImagesValue( attribute):

imageExists(name):

复制代码

form

formExists( name):

getForm( name=None):

getFormValue( name, attribute):

getFormVisibleControlNames( name=None):

getForms():

getFormsValue( attribute):

复制代码

a

clickHiddenLink( name):

getLink( name):

getLinkValue( name, attribute):

getLinks( filter=None):

复制代码

table

getTable( name):

getTableData( name):

getTableRowIndex( name, row):

getTableText(tableName,rownum,cellnum, frameName=None):

getTables( filter=None):

tableCellExists( tableName, cellText):

tableExists( name):

tableRowExists( name, row):

复制代码

div

divExists( name):

getDiv( name):

getDivValue( name, attribute):

getDivs():

getDivsValue( attribute):

复制代码

通用 Element

clickElement( element): 点击一个节点。

clickHiddenElement( element):

findElement( tag, attributes, val, elementList=None):

findElementByIndex( tag, indexNum, filter=None, elementList=None):

findText( text):

fireElementEvent( tag, controlName, eventName):

textFinder(text):

getElementChildren( element, all=True):

getElementParent( element):

getElementValue( element, attribute):

getElementsList( tag, filter=None, elementList=None):

复制代码

操作类函数:
用于控制IE的动作

navigate( url):

changeWindow( wintext): 转而控制另外一个窗体对象

pause( string = "Click to Continue test"):

goBack(self):

findWindow( title, indexNum=1):

closeWindow( title=None):

refresh(self):

resize( iWidth, iHeight):

quit(self):

复制代码

信息资源类:
获取当前IE的属性

getIE(self):

getPageText(self):

locationURL(self):

outerHTML(self):

randomString( length):

复制代码

最后给大家奉上 Win32Com, PAM30
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: