Help us understand the problem. What is going on with this article?

PuppeteerでWordPressのインストールを実行した

More than 1 year has passed since last update.

WordPressの環境作成をCIする場合に、一応セットアップまで見ておくかというときに。

Puppeteerをインストール

$ yarn install puppeteer

Puppeteerスクリプト

Passwordの入力周りがJavascriptなので、waitをしておくのが無難だった。

wpsetup.js
const puppeteer = require('puppeteer');

(async () => {
  try {
    const browser = await puppeteer.launch({
      // headless: false, // デバッグ用
      ignoreHTTPSErrors: true
    });
    const page = await browser.newPage();
    // 言語選択がデフォルトのenでよければ、いきなりstep=1に飛んでOK
    await page.goto(
      process.argv[2] + '/wp-admin/install.php?step=1',
      {waitUntil: 'networkidle0'}
    );
    await page.type('#weblog_title', 'PUPPETEER')
    await page.type('#user_login', 'admin')
    // それなりに複雑なパスワード
    await page.type('#pass1-text', 'Pass00+345+Word')
    await page.type('#admin_email', 'test@example.com')
    await page.click('#blog_public')
    await page.click('#submit')

    browser.close()
  } catch(e) {
    console.log(e)
    process.exit(1)
  }
})();

node wpsetup.js https://127.0.0.1:8443のように実行する。

実行はCircleCIでやってるので、Fromイメージにはcircleci/node:8-browsersを使いました。
なんか動かないなーというときはDEBUG=puppeteer:session環境変数をつかいます。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした