Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Nesstech/selenium

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

selenium

概要

Seleniumの環境構築が面倒だったため、Docker上で開発環境を再現できるように設定ファイルとサンプルスクリプトをまとめました。 docker-compose up -dするだけでSeleniumとPythonおよびHeadless Chromeの環境が出来上がります。ブラウザを用いた処理を自動化したい場合や、テスト自動化のベースとしてご利用ください。HeadlessなのでGUI環境のないサーバー上でも動作します。

事前準備

Dockerをインストールして、dockerコマンドとdocker-composeコマンドが使用できるようにしてください。

使い方

インストールと起動方法

$ git clone https://github.com/sikkimtemi/selenium
$ cd selenium
$ docker-compose up -d

正常に起動できていれば下記のようになります。

$ docker-compose ps
    Name               Command           State           Ports
-----------------------------------------------------------------------
chrome         /opt/bin/entry_point.sh   Up      0.0.0.0:5900->5900/tcp
python         tail -f /dev/null         Up
selenium-hub   /opt/bin/entry_point.sh   Up      0.0.0.0:4444->4444/tcp

終了方法

$ docker-compose down

サンプルスクリプトの実行

$ docker exec -it python /root/script/sample.py

実行するとGoogleにアクセスしてスクリーンショットを取得します。 script/imagesディレクトリに画像ファイルが保存されます。

VNC接続によるデバッグ

VNCで接続するとブラウザの動きを確認しながらデバッグすることができます。Docker環境のIPアドレスにVNC(デフォルトは5900番ポート)でアクセスした上で、サンプルスクリプトを実行してみてください。デフォルトのパスワードは"secret"です。

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 90.7%
  • Dockerfile 9.3%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.