Skip to content

Commit

Permalink
wrap button clicks in try catch to prevent script from hanging
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Thornton committed Sep 16, 2020
1 parent 5368d33 commit 27616a0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 30 deletions.
10 changes: 7 additions & 3 deletions src/commands/texei/sharingcalc/recalculate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ export default class Recalculate extends SfdxCommand {

this.debug(`DEBUG Clicking 'Recalculate' button`);

await page.click(
`#ep > .pbBody > .pbSubsection > .detailList > tbody > .detailRow > td > input[name="rule_recalc"].btn`
);
try {
await page.click(
`#ep > .pbBody > .pbSubsection > .detailList > tbody > .detailRow > td > input[name="rule_recalc"].btn`
);
} catch (ex) {
console.log('Unable to recalculate sharing.', ex.message);
}

await navigationPromise;

Expand Down
32 changes: 18 additions & 14 deletions src/commands/texei/sharingcalc/resume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,24 @@ export default class Resume extends SfdxCommand {

this.debug(`DEBUG Clicking 'Resume' button`);

// Resume either Group Membership or Sharing Rules
if (this.flags.scope === "groupMembership") {
await page.click(
`#gmSect > .pbBody > .pbSubsection > .detailList > tbody > .detailRow > td > input[name="group_resume"].btn`
);

// click the yes button to recaulcate group memberships immediately
await page.click(
`div#group_resume_dialog_buttons > input[value=" Yes "]`
);
} else {
await page.click(
`#ep > .pbBody > .pbSubsection > .detailList > tbody > .detailRow > td > input[name="rule_resume"].btn`
);
try {
// Resume either Group Membership or Sharing Rules
if (this.flags.scope === "groupMembership") {
await page.click(
`#gmSect > .pbBody > .pbSubsection > .detailList > tbody > .detailRow > td > input[name="group_resume"].btn`
);

// click the yes button to recaulcate group memberships immediately
await page.click(
`div#group_resume_dialog_buttons > input[value=" Yes "]`
);
} else {
await page.click(
`#ep > .pbBody > .pbSubsection > .detailList > tbody > .detailRow > td > input[name="rule_resume"].btn`
);
}
} catch (ex) {
console.log('Unable to resume sharing.', ex.message);
}

await navigationPromise;
Expand Down
30 changes: 17 additions & 13 deletions src/commands/texei/sharingcalc/suspend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,23 @@ export default class Suspend extends SfdxCommand {

this.debug(`DEBUG Clicking 'Suspend' button`);

// Suspend either Group Membership or Sharing Rules
if (this.flags.scope === "groupMembership") {
page.on("dialog", dialog => {
dialog.accept();
});

await page.click(
`#gmSect > .pbBody > .pbSubsection > .detailList > tbody > .detailRow > td > input[name="group_suspend"].btn`
);
} else {
await page.click(
'#ep > .pbBody > .pbSubsection > .detailList > tbody > .detailRow > td > input[name="rule_suspend"].btn'
);
try {
// Suspend either Group Membership or Sharing Rules
if (this.flags.scope === "groupMembership") {
page.on("dialog", dialog => {
dialog.accept();
});

await page.click(
`#gmSect > .pbBody > .pbSubsection > .detailList > tbody > .detailRow > td > input[name="group_suspend"].btn`
);
} else {
await page.click(
'#ep > .pbBody > .pbSubsection > .detailList > tbody > .detailRow > td > input[name="rule_suspend"].btn'
);
}
} catch (ex) {
console.log('Unable to suspend sharing.', ex.message);
}

await navigationPromise;
Expand Down

0 comments on commit 27616a0

Please sign in to comment.