OpenScript has rich features to identify xpath. Below are various ways that can be leveraged to spy object properties.
- Inspect Path :
a. Open openscript IDE and then navigate to Script >Inspect Path as below:
b. A pop up appears for selecting object.Browser opens up. Objects are highlighted with green on mouse hover. The respective xpath is visible in ‘Path’ in ‘Select Object’. Press F10 when you mouse hover on the desired object .
c. Copy and paste the xpath in ‘Path ‘ text area. This is the required xpath of the selected object.
2. Object Details :
a. Open openscript IDE and then navigate to View >Object Details as below:
b. In the Object Details panel,click on ‘Connect to Browser’.
c. Browser opens up.Traverse to the desired object.
d. Click on ‘Find a node to inspect object by selecting object in browser’ in Object Details panel.
e. Pop up appears for selecting object.Object is highlighted with green on mouse hover. Press F10 and capture the xpath in ‘Path’ in ‘Select Object’.
3. Object Test :
a. Open openscript IDE and go to ‘Tree View’
b. Right click on any node.(e.g Run) and Click on Add -> Other on context menu. Expand ‘Web Test’, select ‘Object Test’ and click on ‘OK’.
c. Enter test name in ‘Object Test’ pop up.Click on ‘Capture object in browser’. Browser opens.Move your mouse position to the required object. It appears in green.
d. Press F10 and click on ‘OK’ button. The attributes along with corresponding values of the element are seen in ‘Object Test’.
Note: Above are the 3 ways to spy objects from openscript and now you can see how to get details without openscript, if it is a web based application. One can simply do from browser itself and here is the solution.
4. Developer Tools :
In Internet explorer press F12 ,one can see the developer tool pane down in the page. Click on ‘Select Element’ and move the cursor to the element. The attributes of the same are seen under ‘DOM Explorer’. One can customize the xpath using these parameters and can use in scripting.
Sample Xpath derivation:
- Find the title of the window from head section in DOM structure.
- Find the form attributes from body section.
- Find parameters of the element from body of the DOM structure.
Note : Most of the times, document index is 0.
Xpath is derived as below:
/web:window[@title=’Google’]/web:document[@index=’0′]/web:form[@id=’tsf’ or @name=’f’ ]/web:input_text[@id=’lst-ib’ or @name=’q’]