Knowledge Base Article

Home Page > Knowledge Base > Rapise

Home Page > Knowledge Base > Rapise > Rapise Web

Article Dynamically changing object locators for Web applications

by Adam S on Thursday, September 24, 2015

Sometimes you want to dynamically change the XPATH or CSS used in a specific object from within the test script itself. This article explains the process for doing this.
The solution is to override the built-in HTML locator functionality (used when testing Web applications) and modify the XPATH / CSS locator on the fly. The following simple example will show you how to adjust the XPATH or CSS of a specific object:

Normally you'd use a learned object such as:


to override the XPATH locator, we just pass it through as an extra JavaScript object parameter:

    SeS('Log_In', { xpath: '/html/body//a[@id=\'HeadLoginView_HeadLoginStatus2\']' } ).DoClick();

Or to use CSS we'd simply use:

    SeS('Log_In', { xpath: 'css=html > body > form#ctl01 > div:nth-of-type(3) > div:first-of-type > div:nth-of-type(2) > a#HeadLoginView_HeadLoginStatus' } ).DoClick();
Article Info
Last Updated: 9/24/2015
Article ID: KB172
# Views: 435
Powered by KronoDesk v1.1.0.15 | © Copyright Inflectra Corporation 2011-2016 | Licensed to Inflectra Corporation.