Unanswered question

how can i use a variable to calculate if the time of my sended request with a variable exceeds?

in my project , i have a token that expired after 10 min , so i want to create a variable that test if the time spent on script from the start exceeds 10 min to refresh it , how can i create a variable that can calculate the time from the start ?

mohamed Y.
mohamed Y.

mohamed Y.

Level
0
76 / 100
points

Answers

I would suggest a JavaScript snippet and a fork. The js gets the current time and assigns it a variable. In the fork, have a loop with a 1 second delay and a second piece of js that keeps track of the time, maybe an if statement that refreshed the token at 9m 59s

mohamed Y.
mohamed Y.

mohamed Y.

Level
0
76 / 100
points

I tried this solution but i think i am doing something wrong .., in my scripts i added a java script under a fork which calculates the time , after the fork, there is the script and i m using a condition for each transaction to test the time spent , but it dosen't work
what shoul i do ?

mohamed Y.
mohamed Y.

mohamed Y.

Level
0
76 / 100
points

you mean the js is out of fork action ?
if i unterstand you , i will have a fork that contains my recorded script in parallel i will have a script js tracks the time ,
can i assign a value to neoload variables from script js ?

Something like this...

js to get time, store in variable tokenTime=now
request new token, tokenValue=new token
fork
....loop
........delay 1 sec
........js to calc diff between now and tokenTime
........if now > (tokenTime+9:58)
............tokenValue=request new token
............tokenTime=now
request uses tokenValue
request uses tokenValue

mohamed Y.
mohamed Y.

mohamed Y.

Level
0
76 / 100
points

okay , is that possible to create a neoload variables and set a value from js script ? for exemple

  • create a constant string
  • from the script js , i set a value in the constant string