Skip to content

Commit

Permalink
fix login error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
sandorfr committed Jul 29, 2018
1 parent c867240 commit e64f531
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions Tasks/GhostThemeUploader/ghostThemeUploaderTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as path from "path";
import * as fs from "fs-extra";
import * as tl from "vsts-task-lib/task";
import * as puppeteer from "puppeteer";
import { timeout } from "q";

let themePath = tl.getPathInput("theme");
let takeScreenshotsEnabled = tl.getBoolInput("takeScreenshots");
Expand Down Expand Up @@ -64,16 +65,22 @@ async function themeUpload() {
await page.type('input[name=password]', password);
await takeScreenshot(page, 'login.filled.png');
await page.click('button.login');
await page.waitForNavigation({ waitUntil: 'networkidle0' });
await takeScreenshot(page, 'login.done.png');
console.log('Logged in with ', userName);

var mainError = await page.$('p.main-error');
if (mainError != null){
var message = await page.evaluate(document => document.querySelector('p.main-error').innerText) as string;
throw new Error(message);
try {
await page.waitForNavigation({ waitUntil: 'networkidle0', timeout: 3500 });
await takeScreenshot(page, 'login.done.png');
console.log('Logged in with ', userName);
}
catch (err) {
var mainError = await page.$('p.main-error');
if (mainError != null) {
var message = await page.evaluate(document => document.querySelector('p.main-error').innerText) as string;
throw new Error(message);
} else {
throw err;
}
}


await page.goto(page.url() + 'settings/design', { waitUntil: 'networkidle0' });
await takeScreenshot(page, 'theme.page.png');

Expand Down

0 comments on commit e64f531

Please sign in to comment.