Skip to content

Instantly share code, notes, and snippets.

@github0013
Last active October 26, 2022 22:37
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save github0013/5746397 to your computer and use it in GitHub Desktop.
Save github0013/5746397 to your computer and use it in GitHub Desktop.
東京三菱UFJ銀行BizStation(法人用ネットバンク)をOSX(mac)で!Rubyで!Selenium WebDriverで使い倒す!

BizSTATION 動作環境

https://bizstation.bk.mufg.jp/service/kankyou.html
Firefoxでも使えるみたいだか、どうもユーザーエージェントの偽装が無いと拒否される。
あ、と言うか、Mac自体対象外だった...

拒否される

http://takahashifumiki.com/others/2071/
http://docs.komagata.org/4950

FirefoxへのBizSTATION証明書のインポート

必ず年に1回証明書の更新があるが、この時に「エクスポート不可」で証明書を発行しているとInternet Explorerから取り出すことが出来ないので、Firefoxへインポートが出来ない。
https://bizstation.bk.mufg.jp/info/061102_1.html

証明書の再発行をする

BizSTATIONへ電話して再発行したいという。理由を正直に「Firefoxにインポートしたいんで...」というややこしそうなので、新しいパソコンを買ったからそっちから使いたいとか言えば良い。 別途料金も必要ない。
https://bizstation.bk.mufg.jp/otoiawase/

証明書の再発行で必ずエクスポート不可チェックを外す

https://bizstation.bk.mufg.jp/info/061102_1.html
この同じ画面で再発行をする事になるが必ず不可で発行する。そしてとりあえずInternet Explorerに証明書のインストールを行う。 証明書が入ったら、Internet Explorerからエクスポートをする。
https://bizstation.bk.mufg.jp/info/info24/
https://bizstation.bk.mufg.jp/info/info24/ie_export.html

.pfx 拡張子のファイルが出来るのでこれを以降のFirefoxで使っていく。

Firefoxで新しいプロファイルを作る

プロファイル作成画面

別段必要は無いが、やった方がすっきりすると思うので...
https://support.mozilla.org/ja/kb/profile-manager-create-and-remove-firefox-profiles

/Applications/Firefox.app/Contents/MacOS/firefox-bin -profilemanager

まずseleniumが使う専用のプロファイルを作成。 名前、保存先が指定できるので名前を selenium とでもしておき、保存先はデフォルトでも構わないが自分の場合はプロジェクト配下に置いた。

seleniumプロファイルで起動後、上でエクスポートした.pfxをインポートする
http://takahashifumiki.com/others/2071/
「3. クライアント証明書のインストール」参照

そして一旦Firefoxを完全に閉じる。

irbからでも良いので下を実行する

require "selenium-webdriver"

                                                # 設定したプロファイル名で指定
profile = Selenium::WebDriver::Firefox::Profile.from_name('selenium').tap do |prof|
  # ユーザーエージェントを変更する 
  prof['general.useragent.override']              = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)"
  # SSLのチェック画面をすっ飛ばす
  prof['security.default_personal_cert']          = "Select Automatically"
end

driver = Selenium::WebDriver.for(:firefox, profile: profile)
driver.navigate.to "https://bizst.bk.mufg.jp/biz/dfw/Login"

後はやりたい放題! アクセスできた画面

すっ飛ばしてるのでこの画面は出ない

SSLのチェック画面をすっ飛ばす

環境
$ uname -a
Darwin mac.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64


$ gem list -d selenium

*** LOCAL GEMS ***

selenium-webdriver (2.33.0)
    Author: Jari Bakken
    Homepage: http://selenium.googlecode.com
    Installed at: /Users/ac/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0

    The next generation developer focused tool for automated testing of
    webapps


$ ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin11.4.2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment