Tips & tricks - Web testing
The following tips and tricks are relevant when testing web applications.
In this topic:
- Work with the Web SDK
- Use the Object Identification Center (OIC) with Web objects
- Declare your browser in your test
- Decide which browser to use for your Web steps.
- Describe objects using XPath or CSS expressions
Work with the Web SDK
Make sure you include:
C#: using HP.LFT.SDK.Web;
Java: import com.hp.lft.sdk.web.*;
JavaScript: var Web = LFT.Web;
Use the Object Identification Center (OIC) with Web objects
-
Open your browser only after the UFT Developer runtime engine is running.
-
Supported only on UFT Developer 23.4 or earlier: If you are using UFT Developer with Microsoft Edge Legacy, you must open the browser session with the Edge Agent for Functional Testing, available from the Windows Start menu.
Declare your browser in your test
Even if you are working with objects from an application model, declare your browser in the context of your test and then pass the browser as an argument when you instantiate your application model class:
Decide which browser to use for your Web steps.
- Use the Launch method to open a new browser.
- Use the Attach method to run your steps on an open browser tab (or one that was opened by your application during the session).
Describe objects using XPath or CSS expressions
Use the XPathDescription and CSSDescription classes when it would be difficult to uniquely describe an object using properties and values.
The Object Identification Spy automatically generates suggested values that you can use for the XPath and CSSSelector properties.
Note:
- Keep in mind that XPath and CSS values are ordinal and can be more complex to maintain as your application changes over time.
- If two objects on a page have the same value for their id attribute, the XPath values generated for those objects may be identical.
See also: