Part-1
Getting URL from HTML form.
------------------------------------------------------------------------------------
If you want to access URL from a form's action, use the below code.
Syntax: Browser().Page().Object.getElementsByTagName("form")(IndexOfTheForm).action
Example: Msgbox Browser("name:=Google").Page("title:=Google").Object.getElementsByTagName("form")(0).action
Throughout this article I have used Google for all my examples.
How to find hyperlink's color of your webpage
------------------------------------------------------------------------------------
Here is the code to find link's color of your webpage.
Example: Msgbox Browser("name:=Google").Page("title:=Google").Object.alinkColor
How to find a textbox's auto-complete property is enabled or not
------------------------------------------------------------------------------------
Use the below code to find whether the textbox's auto-complete property is enabled or not.
Example: Msgbox Browser("name:=Google").Page("title:=Google").Object.getElementsByName("q")(0).autocomplete
Getting default checked property for radio button and checkbox
------------------------------------------------------------------------------------
If you want to know radio button's or checkbox's default checked property in QTP, then use the simple code which I use frequently.
Msgbox Browser("name:=Google").Page("title:=Google").WebRadioGroup("name:=meta").Object.defaultChecked
Or
Msgbox Browser("name:=Google").Page("title:=Google").Object.getElementByID("cty").defaultChecked
Finding host or hostname of the location or URL.
------------------------------------------------------------------------------------
To find host and port number.
Msgbox Browser("name:=Google").Page("title:=Google").Object.getElementsByTagName("A")(0).Host
To find host name.
Msgbox Browser("name:=Google").Page("title:=Google").Object.getElementsByTagName("A")(0).HostName
Find destination URL
------------------------------------------------------------------------------------
The below code to find a destination URL or an anchor point.
Msgbox Browser("name:=Google").Page("title:=Google").Object.getElementsByTagName("A")(0).Href
Part -2 will be published soon
Please refer the below link, if you want to know more about DOM.
Nice Post thanks
ReplyDeleteKissAnime alternatives