Highlighted
Absent Member.
Absent Member.
1450 views

SP10 - unable to click a checkbox because of unique id.

Jump to solution

I'm using SilkPerformer 10, IE9, I'm recording a browser driven test on a website using Ajax.

When I record a script the I have the following code

 BrowserCheckBoxSelect("//INPUT[@id='userid_38223']", CHECKBOX_CHECKED);


the problem being that the userid is unique for the id (the user who signed into the webpage has a unique id).  When I look at all my other choices on the browser there is nothing unique for me to replace the @id.  The only way for me, I think would be to use the xpath.

/html/body/div[2]/div/div/div/div/div/div[3]/div/div/input

How would I be able to code the clicking of an object (in this case a checkbox) using the xpath above if it is possible?

Thanks,

Scott

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Hi Sfeger and welcome to the Silk Performer forum.

The XPath locator string which you highlighted, would not be recognised as a valid XPath locator to uniquely identify the element on the page.

However, there are different approaches you can take to address the scenario.

1. You mentioned that there did not seem to be no other Property / Values which would uniquely identify the element, to confirm this, I would highly recommend adding the ‘id’ attribute to the ignored DOM attributes name list within Silk Performer – SILK PERFORMER | SETTINGS | ACTIVE PROFILE | WEB (BROWSER-DRIVEN), carry out another recording against the application, interact with the checkbox and see what XPath locator string is generated.

The following kb article explains, Xpath locator strings work in Silk Performer:

community.microfocus.com/.../555.preferred-dom-attribute.aspx

2. Depending on the elements on the screen and which element you wish to interact with, you could possibly use the syntax such as //INPUT[1], which means the first element which uses the HTML input tag is selected, of course the parameter [1] can be customized to suit your needs.

Example

BrowserCheckBoxSelect("//INPUT[1], CHECKBOX_CHECKED);

The problem here is the input tag would not only be used by checkboxes but also text boxes etc. So there maybe an issue in uniquely identifying the element you wish to choose.

Regards

Paul

View solution in original post

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

Hi Sfeger and welcome to the Silk Performer forum.

The XPath locator string which you highlighted, would not be recognised as a valid XPath locator to uniquely identify the element on the page.

However, there are different approaches you can take to address the scenario.

1. You mentioned that there did not seem to be no other Property / Values which would uniquely identify the element, to confirm this, I would highly recommend adding the ‘id’ attribute to the ignored DOM attributes name list within Silk Performer – SILK PERFORMER | SETTINGS | ACTIVE PROFILE | WEB (BROWSER-DRIVEN), carry out another recording against the application, interact with the checkbox and see what XPath locator string is generated.

The following kb article explains, Xpath locator strings work in Silk Performer:

community.microfocus.com/.../555.preferred-dom-attribute.aspx

2. Depending on the elements on the screen and which element you wish to interact with, you could possibly use the syntax such as //INPUT[1], which means the first element which uses the HTML input tag is selected, of course the parameter [1] can be customized to suit your needs.

Example

BrowserCheckBoxSelect("//INPUT[1], CHECKBOX_CHECKED);

The problem here is the input tag would not only be used by checkboxes but also text boxes etc. So there maybe an issue in uniquely identifying the element you wish to choose.

Regards

Paul

View solution in original post

0 Likes
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.