Wednesday, October 25, 2017

Description Programming

'==Descriptive Programming language
'creating the common browser and page object 
Set myPage= browser("creationtime:=0").page("title:=.*")
'creating ll Description objects 
'it contacins all th eobjects present in webpage
Set desc=Description.Create


' getting all childobjects 
set allPageObjects=myPage.ChildObjects(desc)
'priting all the objects from the page.//total count
print allPageObjects.count

'here we use micclass to get the property of classname'micclass

For i = 0 To allPageObjects.count-1 Step 1
    print "object *****"&i
    print allPageObjects(i).getroproperty("micclass")&"-----"&allPageObjects(i).getroproperty("visible")
Next
'print allPageObjects(0).getroproperty("micclass")
'-----------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------


'==Descriptiv language
'creating the common browser and page object
Set myPage= browser("creationtime:=0").page("title:=.*")
'creating ll Description objects
'it contacins all th eobjects present in webpage
Set desc=Description.Create


'filter TO GET PARTICULAT WEB ELEMENT


' to display the objects of only webedits
'desc("micclass").value="WebEdit"

'to get the complete Links
'desc("micclass").value="Link"

'to get the complete Links
desc("micclass").value="WebList"

' getting all childobjects
set allPageObjects=myPage.ChildObjects(desc)
'priting all the objects from the page.//total count
print "Totol number of objects are :-"&allPageObjects.count


'specific object from the page*******
'print allPageObjects(0).getroproperty("micclass")



'here we use micclass to get the property of classname'micclass

For i = 0 To allPageObjects.count-1 Step 1
    'print "object *****"&i
    print allPageObjects(i).getroproperty("micclass")&"-----"&allPageObjects(i).getroproperty("innertext")
Next



allPageObjects(0).SELECT ("Jan")

'Calling the function to get links
WebelementCount "Link"

Function WebelementCount(webelement)

    Set myPage= browser("creationtime:=0").page("title:=.*")
    Set desc=Description.Create
    desc("micclass").value=webelement
    set allPageObjects=myPage.ChildObjects(desc)

print "Totol number of objects are :-"&allPageObjects.count
For i = 0 To allPageObjects.count-1 Step 1
    print allPageObjects(i).getroproperty("micclass")&"-----"&allPageObjects(i).getroproperty("innertext")
Next
End Function


'-------------------------------------------------------------------------------------------------------------


'google links
Set myPage= Browser("creationtime:=0").Page("title:=.*")
set desc=Description.Create
desc("micclass").value="Link"
desc("height").value=21
set objLink=myPage.ChildObjects(desc)
print objLink.count

For i = 1 To objLink.count Step 1
    print objLink(i).getroproperty("innertext")
Next


'-----https://demo2.odoo.com/web#view_type=list&model=sale.order&menu_id=487&action=719
'demo2.
Set myPage=Browser("creationtime:=0").Page("title:=.*")
Set desc=Description.Create
desc("micclass").value="WebCheckBox"
desc("height").value=15
set ObjWebCheckBox=myPage.ChildObjects(desc)
print ObjWebCheckBox.count
ObjWebCheckBox(0).click



'---------**********************************************************************

'https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select
'Weblist
Set desc= Description.Create
desc("micclass").value="WebList"
desc("height").value=21

Set myPage=Browser("creationtime:=0").Page("title:=.*").ChildObjects(desc)

myPage.count
myPage(0).CaptureBitmap "f:\list.png",true
myPage(0).select(1)
'or
myPage(0).GetItem(3)


'*******************************************************************************88


Set box = Browser("creationtime:=0").Page("title:=.*").WebElement("class:=signin-box")

Set desc = description.Create
desc("micclass").value="WebEdit"

Set objEdits = box.ChildObjects(desc)
print " Total edit boxes -> "& objEdits.count
objEdits(0).set "username"
objEdits(1).set "password"



desc("micclass").value="WebButton"
Set objButton = box.ChildObjects(desc)
print "Total buttons -> " & objButton.count
print objButton(0).getroproperty("value")
'objButton(0).click


desc("micclass").value="WebCheckBox"
Set objCheckBox = box.ChildObjects(desc)
If  objCheckBox(0).getROProperty("checked") = 0 Then
objCheckBox(0).click
End If


'------
********************************************************************



'rediff mail 

Set desc =Description.Create
Set myPage=Browser("creationtime:=0").Page("title:=.*").WebElement("class:=login-form")
Set desc =Description.Create
desc("micclass").value="WebEdit"
Set objectWebEdit=myPage.ChildObjects(desc)
print "the total number of edit fields are:-"&objectWebEdit.count

'*********************************************************************
' entering values into username and password


objectWebEdit(0).set "sud3eer@rediffmail.com"
objectWebEdit(1).set "Kewl@080288"

'************************************************************************
'click on button now:-

desc("micclass").value="WebButton"
Set objectWebbutton=myPage.ChildObjects(desc)
print objectWebbutton(0).getroproperty("value")
objectWebbutton(0).click



'******************************************************************
'https://www.quikr.com/
' extracting from the boxes

Set myPage= Browser("creationtime:=0").page("title:=.*")
Set desc=description.Create
desc("micclass").value="WebElement"
desc("class").value="col-sm-4 col-md-4"

set categories=myPage.ChildObjects(desc)
print categories.count

Set desc_link= description.Create
desc_link("micclass").value="Link"



For j = 0 To categories.count-1
print"**********************"
set chilobj=categories(j).childObjects(desc_link)
'print "total links are -->"&chilobj.count
For k = 0 To chilobj.count-1
'extracting links from a box
'print chilobj.count
    print chilobj(k).GetRoProperty("innertext")
Next
   
Next

'************************************************************************
'  Working with object with in the object
'Exporting 
 datatable.AddSheet "quikr"'---adding excel sheet quikr
set myPage = Browser("creationtime:=0").Page("title:=.*")
Set descCategories = description.Create
descCategories("micclass").value="WebElement"
descCategories("html id").value = "cats"
Set categories= myPage.ChildObjects(descCategories)
print categories.count
Set desc_link = description.Create
desc_link("micclass").value= "Link"
Dim col_name
' category
For i=0 to categories.count-1
    col_name = "Category_"& i

' adding column wise i.e boxes
datatable.GetSheet("quikr").AddParameter col_name,""
    print "***********************************************"
Set objLink = categories(i).childObjects(desc_link)
' links
print "Total Links -> " & objLink.count
    For j=0 to objLink.count-1
        datatable.GetSheet("quikr").SetCurrentRow(j+1)
        linktext= objLink(j).getROProperty("innertext")   
        print linktext
        datatable(col_name,"quikr")=linktext
    Next
Next
datatable.ExportSheet "C:\quikr.xls","quikr"

'-----------------------------------------------------------------------------------------------------------





No comments:

Post a Comment

Description Programming

'==Descriptive Programming language 'creating the common browser and page object  Set  myPage= browser( "creationtime:=0...