Aug 13 2009 09:00:38 PM Posted By : rajasankar
Comments (0)

In this article, I am going to show, how to follow the web links in the Dynamic web page is easy with QEngine.

Here are the two function used in that.

You can get the DOM element property with the following function,

Code:
getElementProperty(tagName,propertyName,propertyValue,index,propertyNeeded,regExpRequired='false')

You can click on the element using the following function,
Code:
fireEventOnElement(tagName,propertyName,propertyValue,index,actionName,actionValue='',regExpRequired='false')

Here
tagName = DOM tag name such as TD,IMG,SPAN
propertyName= Property of the tag which is used such as Name,ID
propertValue= Value of the property.

First find the values in the page using getElementProperty,

Code:
getElementProperty("A","href",propertyValue,index,"href",regExpRequired='false')


Here the propertyValue is the one we don't know and that one we need. How to get this? Simple, use regex to get any value in href property.

Code:
getElementProperty("A","href",".*",index,"href","true")


Now this will match everything in that property and entire string. Let call this in a loop and get the values as an array.

Code:

i=1
while i>0:
values=[]
setLastWindow()
property=getElementProperty("A","href",".*",i,"href","true")
if property is not None and property!='':
values.append(property)
i=i 1
else:
i=0
return values


Now use the values in the fireEventOnElement function


Code:

for i in range(0,len(values)):
setLastWindow()
fireEventOnElement("A","href",values[i],i,"click","NONE","false")


You can also concatenate the web url if the value is relative.



Code:

for i in range(0,len(values)):
setLastWindow()
url="" values[i]
fireEventOnElement("A","href",url,i,"click","NONE","false")


Bingo!



You can use the same idea for any tag in the web page.

Let me know, how this works.

Rajasankar
rajasankar at zohocorp dot com

No one has commented yet! Be the first one to comment!

Post Comment

38.107.179.227 (38.107.179.227)