Skip to content

Commit

Permalink
fix: use specific version, fix headless, use sleep instead of waitFor…
Browse files Browse the repository at this point in the history
…Timeout
  • Loading branch information
kkalev committed Dec 1, 2024
1 parent ec044be commit fbcf965
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/puppeteer/puppeteer:latest AS puppeteer
FROM ghcr.io/puppeteer/puppeteer:23.9.0 AS puppeteer
FROM node:20-bullseye-slim

LABEL gr.gunet.puppeteer.maintainer="info@gunet.gr"
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ console.log(url[0]);
* `assertTextInSource`
- Check that a certain text is present in page source (for instance when handling text/json/xml pages)
- Arguments
- `page`
- `page` element
- `value` to search for
- Example: `await gunet.assertTextInSource(page,'OAuth2Token');`
* `assertPageTitle`
Expand All @@ -85,6 +85,10 @@ console.log(url[0]);
- `selector`
- `value` typed
- Example: `await gunet.type(page, "#token",'999666');`
* `sleep`
- Sleep for `ms`
- Arguments
- `ms`
* `submitForm`
- Submit Form
- Arguments
Expand Down
8 changes: 4 additions & 4 deletions gunet.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const path = require("path");

const BROWSER_OPTIONS = {
acceptInsecureCerts: true,
headless: process.env.HEADLESS === "true",
headless: process.env.HEADLESS === "true" ? 'shell' : false,
// devtools: process.env.CI !== "true",
defaultViewport: null,
slowMo: process.env.CI === "true" ? 0 : 10,
Expand Down Expand Up @@ -142,10 +142,10 @@ exports.assertNoTicketGrantingCookie = async (page) => {
}

exports.casLogin = async (page, user, password, cas_type = 'simple-cas', cas_lang = "en") => {
await page.waitForTimeout(1000)
await this.sleep(1000);
await this.loginWith(page, user, password);
await this.assertTicketGrantingCookie(page);
await page.waitForTimeout(2000)
await this.sleep(2000);
if (cas_type == 'simple-cas') {
if (cas_lang === 'en') {
await this.assertInnerText(page, '#content div h2', "Log In Successful");
Expand All @@ -167,7 +167,7 @@ exports.casLogin = async (page, user, password, cas_type = 'simple-cas', cas_lan
exports.submitForm = async (page, selector) => {
console.log(`Submitting form ${selector}`);
await page.$eval(selector, form => form.submit());
await page.waitForTimeout(2500)
await this.sleep(2500);
}

exports.type = async (page, selector, value) => {
Expand Down

0 comments on commit fbcf965

Please sign in to comment.