Highlighted
Absent Member.
Absent Member.
816 views

Parameterize XPath Object Identification

Jump to solution

I am writing a script to select a checkbox in a row from a table, and either click yes or no. However, once I finish that checkbox the checkbox cannot be used again since it has already been given a yes or no. On the 2nd iteration, it will choose the 2nd checkbox, and give a yes or no. The 3rd, 4th, etc. 

I am trying to parameterize a number given from the XPath from the object identification. The Xpath given as, (for 3 rows):

//form[@id="matchAndSettleForm"]/table/tbody/tr[4]/td/div/div[3]/table/tbody/tr[1]/td[1]/div/div[2]
//form[@id="matchAndSettleForm"]/table/tbody/tr[4]/td/div/div[3]/table/tbody/tr[2]/td[1]/div/div[2]
//form[@id="matchAndSettleForm"]/table/tbody/tr[4]/td/div/div[3]/table/tbody/tr[3]/td[1]/div/div[2]

As you see, the third digit (red) corresponds to the row that the checbox is in that the script will select. I need to parameterize that number so that the script will check a different row every iteration, and also work for multiple pages. I will have to go through over 3000 rows, so I will need a way to make the script work for every page. Also, the table has 25 rows per page, so once the 26th iteration comes, the parameter number will need to be back at 1 again, since the 1st row on the second page is still the 1st row, not the 26th. 

Is there a way to do this?

0 Likes
1 Solution

Accepted Solutions
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: Parameterize XPath Object Identification

Jump to solution

Hi JPatton,

You can create a parameter of type "Iteration Number" in VuGen (see here).

Then you can set the Object ID Method to JavaScript and evaluate the XPATH in JS, using the parameter.

Use modulo to compensate for paging.

For example:

 

var iter=ArgsContext.TC.getParam("iteration");
var iterMod=((parseInt(iter) + 24) % 25) + 1; // 1-based modulo 25 var xpath="//form[@id="matchAndSettleForm"]/table/tbody/tr[4]/td/div/div[3]/table/tbody/tr[" + iterMod + "]/td[1]/div/div[2]"; evalXPath(xpath);

 

Edo

 

View solution in original post

1 Reply
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: Parameterize XPath Object Identification

Jump to solution

Hi JPatton,

You can create a parameter of type "Iteration Number" in VuGen (see here).

Then you can set the Object ID Method to JavaScript and evaluate the XPATH in JS, using the parameter.

Use modulo to compensate for paging.

For example:

 

var iter=ArgsContext.TC.getParam("iteration");
var iterMod=((parseInt(iter) + 24) % 25) + 1; // 1-based modulo 25 var xpath="//form[@id="matchAndSettleForm"]/table/tbody/tr[4]/td/div/div[3]/table/tbody/tr[" + iterMod + "]/td[1]/div/div[2]"; evalXPath(xpath);

 

Edo

 

View solution in original post

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.