Skip to content

Commit

Permalink
fix(timestamp): Used new Date().getTime() instead of `performance.n…
Browse files Browse the repository at this point in the history
…ow()`

Changed `waitUntil` function to be compatible with NodeJS without the need for a polyfill.
Now it uses `new Date().getTime()` instead of `performance.now()`. This change was necessary to fix the `ReferenceError: performance is not defined` error when trying to run `waitUntil` function inside of a node script. This is because `performance` is only defined inside the browsers (which this module was originally created for).
  • Loading branch information
LukeSavefrogs committed Feb 15, 2022
1 parent c73bd59 commit 644f243
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/SeleniumEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ const SeleniumEngine = {
* @returns
*/
waitUntil: function (testCondition, timeout_ms = 30000, checkInterval_ms = 1000) {
let start_ts = performance.now();
let start_ts = new Date().getTime();

return new Promise((resolve, reject) => {
let timer = window.setInterval(() => {
let elapsed_time = parseInt(performance.now() - start_ts);
let elapsed_time = parseInt(new Date().getTime() - start_ts);

// Se il timeout è un numero
if (
Expand Down

0 comments on commit 644f243

Please sign in to comment.