PhantomJS + CasperJSで テスト終了時に警告が出まくる問題への対処方法

phantomjs

警告の内容

CasperJSでテストを書いていると、スクリプト終了時にPhantomJSが次のような大量の警告を吐いて止まらなくなります。

Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL ...
Domains, protocols and ports must match.

これではまともにテスト結果が見られない上、CIも回せません。

PhantomJS v1.9.8はバギーなのでv1.9.7を使う

以下のスレッドにヒントが書かれていました。

To anyone who has a problem with this. Downgrade PhantomJS to 1.9.7 and run casperjs with the –ssl-protocol=tlsv1 to be functionally completely the same as PhantomJS 1.9.8.
There won’t be an updated PhantomJS 1.x version which fixes this issue.

Mac OSXでの v1.9.7 のインストール法

brewだと1.9.8が入ってしまいます。
バイナリを本家から直接ダウンロードして使います。

ただし、最新版へのリンクしかありませんので、バージョン番号を変えて直接リンクを開いてください。
一応、こちらにリンクも貼っておきます。

brewでインストールした既存のphantomjsはアンインストールしておくことを忘れないでください。