Skip to content

Instantly share code, notes, and snippets.

@stalniy
Created August 16, 2017 08:12
Show Gist options
  • Save stalniy/cbd08db1472c41d35b9e751022333bb6 to your computer and use it in GitHub Desktop.
Save stalniy/cbd08db1472c41d35b9e751022333bb6 to your computer and use it in GitHub Desktop.
Submit google form
function c(name) {
return $x(`//div[@role="listitem" and @jscontroller and .//*[@role="heading" and text()[contains(., "${name}")]]]`)[0];
}
function report(attrs) {
const name = c('Name');
name.click();
setTimeout(() => {
const option = $x(`//*[@role=option and .//text()[contains(., "${attrs.name}")]]`, name)[0];
if (!option) {
alert(`Unable to find ${attrs.name}`);
return;
}
option.click();
const type = c('Shift is');
if (attrs.isStarted) {
$x('//*[@role="radio" and ..//*[contains(text(), "Started")]]/..', type)[0].click();
} else {
$x('//*[@role="radio" and ..//*[contains(text(), "Ended")]]/..', type)[0].click();
}
setTimeout(() => {
// TODO: click on "Submit" button
}, 1000);
}, 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment