I have an application running in Docker, when I run it on my machine with headless new, it works normally, but when I run it in Docker it doesn’t find the selector, I’ve already tried all the alternatives using waitForSelector
my Dockerfile
FROM node:slim
# We don't need the standalone Chromium
# Install Google Chrome Stable and fonts
# Note: this installs the necessary libs to make the browser work with Puppeteer.
RUN apt-get update && apt-get install gnupg wget -y &&
wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg &&
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' &&
apt-get update &&
apt-get install google-chrome-stable -y --no-install-recommends &&
rm -rf /var/lib/apt/lists/*
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/google-chrome-stable
# Create working directory
WORKDIR /app
# Copy project files to container
COPY . .
# Install NPM dependencies for function
RUN npm install
# Expose app
EXPOSE 3050
# Run app
CMD ["npx", "nodemon", "server.js"]
my script:
await page.type('[id="login-input"]', pEmail, { delay: this.typeDelay });
setTimeout(async function () {
await page.click('[type="submit"]');
}, 3000);
await page.waitForNavigation();