Click here to Skip to main content
15,887,965 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.
 
Share this answer
 
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

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