1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Python + Selenium 4で Edge のヘッドレス (Headless) 起動の設定

Posted at

概要

PythonでWeb操作の自動化をする際に、ヘッドレス設定をそのまま使えるところがなく困ったのでメモしておく

環境

  • Selenium 4.0.0.a7
  • python 3.9.5

コード例

automateWeb.py
# -*- coding: utf-8 -*-

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.options import Options

options = Options()
options.use_chromium = True
options.headless = True

service_args = ['--verbose']

browser = webdriver.Edge(
  executable_path='msedgedriver.exe',
  options=options,
  # service_args = service_args,
  # service_log_path=service_log_path,
  # verbose=True
  )

browser.implicitly_wait(10) 
browser.get('{target url}')
   # 省略

参考

Selenium 4 With Python: All You Need To Know
テスト オートメーションに WebDriver (Chromium) を使用する
Chromium-固有 のオプションを使用する

1
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?