Click here to Skip to main content
15,034,353 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to increment the field value by 1 everytime we run the script in seleniumn java>

What I have tried:

I have a field where the field value needs to be unique so i need to increment by 1 everytime i run the script can some one pls give inputs
Posted
Updated 1-Aug-21 21:59pm

1 solution

You need to save the value and reload it each time the code runs. See Properties (Java Platform SE 7 )[^] for one way to do it.
   
Comments
Member 15289910 2-Aug-21 4:17am
   
thanks for the response ...is there any other way which is easier
Richard MacCutchan 2-Aug-21 4:28am
   
Well you could just store it in a simple text file. But whatever you choose, you have to save the value somewhere external to your application. And writing it to disk is the best choice.

But since I have no idea what your application is doing it is impossible to suggest any alternative.
Member 15289910 2-Aug-21 4:33am
   
In my application there are 2 fields which need to have unique value.So i enter all the values in the screen and save and then next time when the script runs the two fields need to have unique value.For now what i have thought is to take a list of webelement of both the fields and then increment the value by 1 .... but incrementing part is where the confusion lies...is there any other link which you know i could refer to get easier solution
Richard MacCutchan 2-Aug-21 4:36am
   
Sorry, I do not really understand what actual problem you are trying to solve. What are these values being used for and why?
Member 15289910 2-Aug-21 6:52am
   
iAM automating an applicaiton . I have a Add Screen where i need to add the Values and in that screen there are 2 fields where the values that needs to be entered should be unique. So in this Case when i run the script everytime i need to enter unique values for those 2 fields.This is the test case and wanted to KNow how to iterate the loop to get a unique value each time i run the script.Hope iam clear
Richard MacCutchan 2-Aug-21 6:55am
   
"when i run the script everytime i need to enter unique values for those 2 fields"
OK, but what are these values then used for, and why must they be unique?
Member 15289910 3-Aug-21 1:26am
   
these values are then used in another screen and hence it needs to be unique.So sum it up:
Screen1 : Enter all the inputs which includes the values for the unique fields
and save the values
Screen2 : I navigate to this screen and select the field which has unique value.
So everytime i make a selection of the field in this screen the value should be unique which comes from Screen 1 hope iam clear

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900