I’ve been unable to find a solution to my issue. I have an input field where I’m using static text with a randomly-generated number appended. I’m doing this because the page I’m testing only allows me to deactivate the test I’m running instead of letting me delete it completely once I’m finished.
In my script, I’m using
import org.apache.commons.lang.RandomStringUtils as RandomStringUtils
and using it in
WebUI.setText(findTestObject(‘Object Repository/Page_/input_Player Group Name_PlaceHoldertxtPlayerGroupName’), ‘Test_Group_’ + RandomStringUtils.randomNumeric(5))
It generates perfectly. However, within my script I then navigate to the page where it’s listed with the others like it. Since I’ve been trying to get this to work (and if/when it actually does) there is/will be other items on the page containing the name “Test_Group_”.
Any idea how to get the script to key in on the correct one?
Thanks for the speedy response. I really appreciate the assistance.
I’m not sure if I implemented your solution correctly or not, but based on what I’m getting I guess not.
I replaced WebUI.setText(findTestObject(‘Object Repository/Page_/input_Player Group Name_PlaceHoldertxtPlayerGroupName’), ‘Test_Group_’ + RandomStringUtils.randomNumeric(5))
WebUI.setText(findTestObject(‘Object Repository/Page_/input_Player Group Name_ctl00ctl00ActiveTabContentPlaceHolderRootActiveTabContentPlaceHoldertxtPlayerGroupName’),
randNum)
So it appeared to me, you wanted to append 'Test_Group_' + random-string to your various TestObject names. If that is not the case, then you need to clarify. For example, perhaps you don’t want Test_Group to be part of the string stored in the variable but instead, use:
I managed to figure it out. All I needed to do was nuke everything from the xpath and set the following in the Selector Editor field (this is taken from the XPATH as reported by devtools):
the /tr[ ] was the part that kept changing. The last iteration of this was /tbody/tr[20]/td[3]/a. the -1 is there because there’s a footer on the page.
Then the script just needs to click it like usual:
WebUI.click(findTestObject(‘Page_/a_Edit’))