LoginSignup
1
0

More than 3 years have passed since last update.

CodeceptionのE2EテストでseeInSourceはなるべく使わない方が良い件

Last updated at Posted at 2019-07-16

背景

Codeceptionで要素を見るためにseeInSourceを使っていたら、ローカルでは通ってもサーバー上では全て落ちていた。

原因

ローカル上のE2Eテストとサーバー上でのE2Eテストで出力されるHTMLが異なる場合があった。
具体的にはサーバー上ではタグに勝手に閉じタグ< />が付くなど。

$I->seeInSource('<meta property="og:title" content="hogehoge">');

とテストコードを書いても

<meta property="og:title" content="hogehoge" />

サーバー上では的な具合でHTMLが出力されてしまう。

対処法

seeInSourceをなるべく使わないこと。
上記の例ではseeElementInDOMを使う。

$I->seeElementInDOM('meta[property="og:title"][content="hogehoge"]');

参考

How to test with Codeception if the page has meta-tag?

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0