0 Shares 580 Views 2 Comments

a cool new way to retrieve Style Attributes easily

Oct 19, 2014
580 Views 2

I am sure, you must be knowing this by now. Just listing down this cool feature implemented in UFT 11.52 onwards. This is about retrieving style attributes of web objects runtime, for example retrieving background color, font, font color etc. All we used to do earlier is using objects property to retrieve such values. something like below

Browser("Test").Page("Test").Link("Google").Object.Currentstyle.Color

But now this has been made even more simplified to use in UFT. we directly use GetROProperty to retrieve the value or even use the property to identify the object. This method is called as Style/* Notation Web Object Identification and this process of object identification is called as Identification using Web Object Identifiers.

Web Object Identifiers can be used to limit the number of similar candidate objects to identify by using it before the regular object identification process. User does not specifically need to do any thing, this will be handled internally by UFT once you use any of the object identifier types.

Below are Web object Identifier types

CSS Web Object Identification – Using Properties defined in CSS.

User-Defined XPath Web Object Identification – Identification using defined XPath.

Automatic X-Path Web Object Identification – using UFT generate XPath property.

Attribute/* Notation Web Object Identification – using the attribute/* notation to access custom native properties of Web-based objects or events associated with Web-based objects

Style/* Notation Web Object Identification – using the style/* notation to access the values of CSS properties for a Web-based object.

In this post we are just discussing Style/* notation and how this simplifies our scripting.

using style/* notation, we can access the values of CSS properties for a web based objects . here is how to retrieve Value using GetROProperty using style/<property>.

to retrieve  properties of google button.

Print "Font Name: " & Browser("Google").Page("Google").WebButton("Google Search").GetROProperty("style/font-family")
Print "Font Size: " & Browser("Google").Page("Google").WebButton("Google Search").GetROProperty("style/font-size")
Print "Color : " & Browser("Google").Page("Google").WebButton("Google Search").GetROProperty("style/color")
Print "Background Color : " & Browser("Google").Page("Google").WebButton("Google Search").GetROProperty("style/background-color")

as mentioned earlier, we can identify and perform action using Style/*<property>

below example to click on the google button using background color property

Browser(“Browser”).Page(“Page”).WebButton(“style\background-color:=blue”).Click

You can find how easy is your scripts now, comparitively when we use CSS (DOM) to retireve style attributes. Here is the older method just for you to compare.

Set btn =Browser("Google").Page("Google").WebButton("Google Search").Object
Set btnStyle = btn.currentStyle
Print btnStyle.backgroundColor

You may be interested

Setting up Mobile Automation Project in Windows
Katalon Studio
77 views
Katalon Studio
77 views

Setting up Mobile Automation Project in Windows

Saket - Sep 20, 2017

This tutorial explains how to setup a mobile automation project and test a mobile app using Katalon Studio on Windows. This tutorial assumes that you are familiar…

Katalon Studio GUI Overview
Katalon Studio
147 views2
Katalon Studio
147 views2

Katalon Studio GUI Overview

Saket - Sep 14, 2017

GUI Overview After installing and setting up Katalon Studio for your automated test, you must understand the GUI. In this post we will walk you through the…

LeanFT Tutorial #4: Application Model Overview
LeanFT
124 views1
LeanFT
124 views1

LeanFT Tutorial #4: Application Model Overview

Saket - Sep 10, 2017

In this post we are going to focus on Application Model in LeanFT. Refer our earlier posts on LeanFT Getting Ready with LeanFT Browser Extensions and Settings…

2 Comments

  1. Hi Saket,

    how the Virtual object working, i created object and stored VOT but how expected object and actual object comparing runtime without support of OR .

    1) after prepare virtual object script my script is not executing why. kindly hep me.

    Reply

Leave a Comment

Your email address will not be published.

Most from this category

Join The Growing Group of 15000+ Test Automation Engineers

Signup for our newsletter and get access to free downloads, as well as tips, tricks and techniques and various test automation resources.
Name
Email Address
Secure and Spam free...