Skip to content

Instantly share code, notes, and snippets.

@dtsn
Created June 8, 2011 16:27
Show Gist options
  • Save dtsn/1014764 to your computer and use it in GitHub Desktop.
Save dtsn/1014764 to your computer and use it in GitHub Desktop.
Selenium Query to store a time so it can be checked against a select box with timeframes spaced at 5 minute intervals
/**
* Selenium Query to store a time so it can be checked against a select box with timeframes spaced at 5 minute intervals
*/
javascript{(Math.floor((parseFloat(this.browserbot.getCurrentWindow().document.getElementById('e_startTime').innerHTML.split(' ')[1].replace(':', '.'))*20) + 0.5)/20).toFixed(2).toString().replace('.', ':')}
// It's just doing this really
var time = document.getElementById('e_startTime').innerHTML;
console.log(time);
time = time.split(' ')[1];
console.log(time);
time = time.replace(':', '.');
console.log(time);
time = parseFloat(time);
console.log(time);
time = Math.floor((time*20) + 0.5)/20;
console.log(time);
time = time.toFixed(2);
console.log(time);
time = time.toString();
console.log(time);
time = time.replace('.', ':');
console.log(time);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment