From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/webdriver/index.html | 109 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 files/ja/web/webdriver/index.html (limited to 'files/ja/web/webdriver/index.html') diff --git a/files/ja/web/webdriver/index.html b/files/ja/web/webdriver/index.html new file mode 100644 index 0000000000..bccb8b04d4 --- /dev/null +++ b/files/ja/web/webdriver/index.html @@ -0,0 +1,109 @@ +--- +title: WebDriver +slug: Web/WebDriver +tags: + - Automation + - Index + - Landing + - Reference + - Testing + - Web + - WebDriver + - 自動化 +translation_of: Web/WebDriver +--- +

WebDriver は、ユーザーエージェントの観察と制御を可能にする遠隔制御インターフェイスです。プロセスの外のプログラムがウェブブラウザーの動作を遠隔で指示する方法として、プラットフォームと言語に中立なワイヤープロトコルを提供します。

+ +

ユーザーに一貫した使い勝手を提供するには、異なるプラットフォーム上の多くのブラウザーで相互に実行できる命令セットを書くことができることが重要です。ウェブプラットフォームでの新しい開発の波、端末の多様性の増加、テクノロジー間の実際の相互運用性の要求を背景に、 WebDriver はクロスブラウザーテストのためののツールを提供します。

+ +

提供されるものは、ウェブ文書内の DOM 要素を検出したり操作したり、ユーザーエージェントの動作を制御したりするためのインターフェイスです。これは主に、ユーザーエージェントを別な制御プロセスから自動制御するテストを、ウェブ作者が書くことができるようにすることが目的ですが、場合によってはブラウザー内のスクリプトが — おそらく他の — ブラウザーを制御するために使用することもできます。

+ +

使い方

+ +

それでは、 WebDriver で何が実現でき、どのように見えるのでしょうか。 WebDriver はプログラミング言語に中立なので、この質問に対する答えは、使用している WebDriver クライアントと言語の選択によって異なります。

+ +

しかし、 Python で書かれた有名なクライアントを使用すると、 WebDriver との対話は次のようになるでしょう。

+ +
from selenium import webdriver
+from selenium.webdriver.common.by import By
+from selenium.webdriver.common.keys import Keys
+from selenium.webdriver.support.ui import WebDriverWait
+from selenium.webdriver.support.expected_conditions import presence_of_element_located
+
+wait = WebDriverWait(driver, 10)
+
+with webdriver.Firefox() as driver:
+    driver.get("http://google.com/ncr")
+    driver.find_element_by_name("q").send_keys("cheese" + Keys.RETURN)
+
+    wait.until(presence_of_element_located((By.CSS_SELECTOR, "h3>a")))
+
+    results = driver.find_elements_by_css_selector("h3>a")
+    for i, result in results.iteritems():
+        print("#{}: {} ({})".format(i, result.text, result.get_property("href")))
+ +

これは次のような出力結果になります。

+ +
#1 Cheese - Wikipedia (https://en.wikipedia.org/wiki/Cheese)
+
+ +

リファレンス

+ +
+
+

コマンド

+ +

{{ListSubpages("/ja/docs/Web/WebDriver/Commands")}}

+ +

種類

+ + +
+ +
+

能力

+ +

{{ListSubpages("/ja/docs/Web/WebDriver/Capabilities")}}

+ +

エラー

+ +

{{ListSubpages("/ja/docs/Web/WebDriver/Errors")}}

+
+
+ +

仕様書

+ + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('WebDriver')}}{{Spec2('WebDriver')}}初回定義
+ +

ブラウザーの互換性

+ + + +

{{Compat("webdriver", 2)}}

+ +

関連情報

+ + + +

{{QuickLinksWithSubpages}}

-- cgit v1.2.3-54-g00ecf