I have a number of automated ui tests which run in parallel using the wdio maxInstances. At the start of each test I generate a random / unique mobile number by doing the following:
07 - All numbers start with this number.
Followed by a 9 digit number based on time & date - `new Date().getTime().toString().substring(4, 13)`
Unfortunately I'm facing issues where occasionally the timestamp is exactly the same. This is due to the test generating the mobile number at exactly the same time. The second approach I tried was:
07 - All numbers start with this number.
Followed by a 6 digit number based on time & date - `new Date().getTime().toString().substring(4, 10)`.
Followed by a 3 digit random number - `Math.floor(Math.random() * 900 + 100);`.
This approach has resulted in less duplicated mobile numbers being generated, however I still occasionally get the same number generated.
Another approach I would like to try is to get the wdio instance thread/runner number and append it to the end of the mobile number. That way if a number is generated at the exact same time, the thread number will mean it will have a unique number. Is anyone able to shed some light on how to do this please.