質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

selenium

Selenium(セレニウム)は、ブラウザをプログラムで作動させるフレームワークです。この原理を使うことにより、ブラウザのユーザーテストなどを自動化にすることができます。

Q&A

3回答

5918閲覧

selenium webdriverの起動方法

post123456

総合スコア73

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

selenium

Selenium(セレニウム)は、ブラウザをプログラムで作動させるフレームワークです。この原理を使うことにより、ブラウザのユーザーテストなどを自動化にすることができます。

0グッド

0クリップ

投稿2017/03/10 12:47

selenium webdriverにて起動を行おうとしているのですが、
以下エラーが表示されます。
私の環境は、win10 pro 64です。

mavenにて環境をjarに設定しています。
下記エラーに対してどう対処すればよいでしょうか?
エラー

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases at com.google.common.base.Preconditions.checkState(Preconditions.java:199) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109) at org.openqa.selenium.firefox.GeckoDriverService.access$000(GeckoDriverService.java:37) at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:95) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296) at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:277) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:238) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127) at App.main(App.java:9)

ソース

import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class App { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get("http://www.asial.co.jp"); driver.quit(); } } ``` ![イメージ説明](2c3045c985e41707f66698dc82e853f7.jpeg) - pom.xml ``` <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>Selenium</groupId> <artifactId>SeleniumDev</artifactId> <version>0.0.1-SNAPSHOT</version> <name>SeleniumTestPrj</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.0.0</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project> ```

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答3

0

webdriverのパスの問題かと思います。
また、windowsの場合、import chromedriver_binary、が必要のようです。

下記が参考になるかと思います。
https://watlab-blog.com/2019/08/10/chromedriver-path/

投稿2019/10/31 21:45

john_doe_

総合スコア354

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

イメージ説明

投稿2017/03/14 10:54

post123456

総合スコア73

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

GeckoDriver入れてます?

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases

The path to the driver executable must be set by the webdriver.gecko.driver system property;

とエラーに書いてありますが。

Selenium3.0 - Geckodriverを使ってFirefoxを起動する方法

投稿2017/03/10 19:45

kanbeworks

総合スコア829

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

post123456

2017/03/11 05:13

ありがとうございます。以下にコードを変更しましたが、 WebDriver driver = new FirefoxDriver();にてエラーが発生しているように見受けられます。 ドライバーの問題なのでしょうか? ``` import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class App { public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\\xampp\\htdocs\\selenium\\geckodriver-v0.15.0-win64\\geckodriver.exe"); WebDriver driver = new FirefoxDriver(); driver.get("http://www.asial.co.jp"); driver.quit(); } } ``` - エラー内容 ``` 1489208498305 mozprofile::profile INFO Using profile path C:\Users\hide\AppData\Local\Temp\rust_mozprofile.zlh7l0VBdtO9 1489208498311 geckodriver::marionette INFO Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe with args [] 1489208498812 geckodriver::marionette INFO Connecting to Marionette on localhost:61895 1489208502860 Marionette INFO Listening on port 61895 情報: Falling back to original OSS JSON Wire Protocol. [土 3 11 14:01:50 JST 2017] 情報: Falling back to straight W3C remote end connection [土 3 11 14:01:50 JST 2017] Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@67b92f0a, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@67b92f0a, version=, platform=ANY}], required capabilities = Capabilities [{}] Build info: version: '3.0.0', revision: '350cf60', time: '2016-10-13 10:48:57 -0700' System info: host: '■■■', ip: '■■■', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_102' Driver info: driver.version: FirefoxDriver at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:259) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:238) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127) at App.main(App.java:10) ```
post123456

2017/03/11 11:00

Firefoxが起動するだけで、そこで固まってしまう状況です。
kanbeworks

2017/03/12 14:20 編集

参考にされているのはアシアルさんの下記ブログ記事でしょうか。 http://blog.asial.co.jp/1180 上記の記事はネタとしては2013年で結構古いんで、もう少し新しいところを参考にされた方が良いかと思います。 例えば下記とか。 http://quesqa.com/selenium-geckodriver/ ついでに、Javaのバージョンはいくつですか? Seleniumは3.0以降からJava 8以降が必須になっていますが。 最初の質問の、Eclipseのスクリーンショットに「JRE システムライブラリー[J2SE-1.5]」という文字が見えますが、Java 5で動かしていたりとか。 もしJava 8より古い環境で実行する必要がある場合は、Selenum 3系ではなく、2系を使用して下さい。 もし意図せず「JRE システムライブラリー[J2SE-1.5]」となってしまっているのでしたら、以下について参考までにどうぞ。 ・MavenプロジェクトでJDKが1.5になってしまう問題を解決する設定 http://qiita.com/takahitonara/items/769c8775183b13c631c5
post123456

2017/03/14 10:53

ありがとうございます。 jre1.8になるようにpom.xmlを修正 コードも変更しましたが状況は変わりません。firefoxが開いたところでとまります。どう対処しましょう? **コード** ``` import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class App { public static void main(String[] args) { WebDriver driver; System.setProperty("webdriver.gecko.driver", "C:\\xampp\\htdocs\\selenium\\geckodriver-v0.15.0-win64\\geckodriver.exe"); driver = new FirefoxDriver(); driver.get("https://www.google.co.jp/"); driver.quit(); } } ``` **pom.xml** ``` <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>Selenium</groupId> <artifactId>SeleniumDev</artifactId> <version>0.0.1-SNAPSHOT</version> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> <name>SeleniumTestPrj</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.0.0</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project> ``` **エラー** ``` 1489488279241 geckodriver INFO Listening on 127.0.0.1:30147 情報: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end [火 3 14 19:44:40 JST 2017] 1489488282941 mozprofile::profile INFO Using profile path C:\Users\hide\AppData\Local\Temp\rust_mozprofile.1tbk1GIWEILg 1489488282953 geckodriver::marionette INFO Starting browser C:\Program Files\Mozilla Firefox\firefox.exe with args [] 1489488284846 geckodriver::marionette INFO Connecting to Marionette on localhost:56250 1489488300364 Marionette INFO Listening on port 56250 情報: Falling back to original OSS JSON Wire Protocol. [火 3 14 19:45:28 JST 2017] 情報: Falling back to straight W3C remote end connection [火 3 14 19:45:28 JST 2017] Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@67b92f0a, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@67b92f0a, version=, platform=ANY}], required capabilities = Capabilities [{}] Build info: version: '3.0.0', revision: '350cf60', time: '2016-10-13 10:48:57 -0700' System info: host: '■■■■', ip: '■■■■', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_102' Driver info: driver.version: FirefoxDriver at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:259) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:238) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127) at App.main(App.java:11) ```
post123456

2017/03/14 10:55

画像は上記に張り付けています。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問