Skip to content

Instantly share code, notes, and snippets.

@kurozumi

kurozumi/input-clear.py

Last active Mar 16, 2016
Embed
What would you like to do?
【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