Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active March 16, 2016 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/a7222cff4f9e541add13 to your computer and use it in GitHub Desktop.
Save kurozumi/a7222cff4f9e541add13 to your computer and use it in GitHub Desktop.
【Python】Seleniumを使ってフォームに入力したテキストを消す方法
# coding: utf-8
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
# FireFoxを起動
driver = webdriver.Firefox()
# Googleにアクセス
driver.get("https://www.google.co.jp")
# 検索ボックスの要素を取得
element = driver.find_element_by_name("q");
# キーワード入力
element.send_keys("sss")
# 10秒待つ
time.sleep(10)
# キーワードを消す
element.clear()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment