LoginSignup
3
4

More than 5 years have passed since last update.

PythonでSeleniumを実行するための導入

Posted at

Selenium導入

自動テストツールSeleniumの導入を説明するページです。

テスト環境

  • OS
    Windows10(64bit)
  • Selenium実行ツール
    Python(3.6.5)

Pythonの準備

Pythonの準備を行います。

  • Python
    Pythonの準備を行います。
    https://www.python.org/
    上記からPythonをダウンロードし、インストールします。
  • 環境変数
    インストールが完了したら、
    「python.exe」と「pip.exe」を環境に変数に設定します。
    それぞれのパスは下記になります。
    • python.exe
      C:\Program Files\Python36
    • pip.exe
      C:\Program Files\Python36\Scripts

Seleniumの準備

Seleniumの準備を行います。

  • Seleniumのインストール
    コマンドプロンプトを起動し、下記のコマンドを実施。
pip install selenium

Seleniumの実施

Pythonを使用し、Seleniumを実行します。

任意のディレクトリにPythonファイルを作成し、下記コードを記載。

from selenium import webdriver
browser = webdriver.Ie("ダウンロードしたIE用のドライバーのパス\\IEDriverServer_x64_3.11.1\\IEDriverServer.exe")

作成したファイルの拡張子は「.py」となります。

コマンドプロンプトを開き下記を実行。

cd 作成したpythonファイルのディレクトリ
pythonファイル名(拡張子込み)

上記を実施すると、IEが開きます。

3
4
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
3
4