読者です 読者をやめる 読者になる 読者になる

鈍足ランナーのIT日記

走るのが好きな5流のITエンジニアのブログ。

趣味の範囲は広いけど、どれも中途半端なクソブロガー楽しめるWebアプリを作ってあっと言わせたい。サーバーサイドPerl(Mojolicious)、クライアントサイドVue.js。Arduinoにも触手を伸ばす予定。

Windows7のSeleniumサーバでchromeを使いたいのにfirefoxが起動する

状況

seleniumサーバの起動方法
(chromedriver.exeへはパスを通してある)

java  -jar ./selenium-server-standalone-2.53.0.jar -Dwebdriver.chrome.driver="chromedriver.exe" -debug

perlから使用する方法

#!perl

use strict;
use warnings;

use Test::WWW::Selenium;

  my $sel = Test::WWW::Selenium->new(browser => '*chrome', browser_url => 'http://localhost:3000');

seleniumサーバのログ

C:\seleniumserver>java  -jar ./selenium-server-standalone-2.53.0.jar -Dwebdriver
.chrome.driver="chromedriver.exe" -debug
07:40:28.743 INFO - Launching a standalone Selenium Server
Setting system property webdriver.chrome.driver to chromedriver.exe
07:40:29.200 INFO - Java: Oracle Corporation 23.25-b01
07:40:29.200 INFO - OS: Windows 7 6.1 amd64
07:40:29.220 INFO - v2.53.0, with Core v2.53.0. Built from revision 35ae25b
07:40:29.221 INFO - Selenium server running in debug mode.
07:40:29.335 INFO - Driver class not found: com.opera.core.systems.OperaDriver
07:40:29.335 INFO - Driver provider com.opera.core.systems.OperaDriver is not re
gistered
07:40:29.350 INFO - Driver provider org.openqa.selenium.safari.SafariDriver regi
stration is skipped:
registration capabilities Capabilities [{platform=MAC, browserName=safari, versi
on=}] does not match the current platform VISTA
07:40:29.351 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUni
tDriver
07:40:29.352 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver
is not registered
07:40:29.551 INFO - RemoteWebDriver instances should connect to: http://127.0.0.
1:4444/wd/hub
07:40:29.551 INFO - Selenium Server is up and running
07:41:19.429 DEBUG - req: POST /selenium-server/driver/ HTTP/1.1
TE: deflate,gzip;q=0.3
keep-alive: 300
Connection: Keep-Alive, TE
Host: localhost:4444
User-Agent: libwww-perl/6.04
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Content-Length: 68


07:41:19.431 INFO - Command request: getNewBrowserSession[*chrome, http://localh
ost:3000] on session null
07:41:19.436 INFO - creating new remote session
07:41:19.446 DEBUG - Requested browser string '*chrome' matches *chrome
07:41:19.453 DEBUG - Discovering Firefox 3...
07:41:19.453 DEBUG - Discovering Firefox...
07:41:19.464 DEBUG - Checking whether Firefox launcher at :'C:\Program Files\Fir
efox-3\firefox.exe' is valid...
07:41:19.465 DEBUG - Checking whether Firefox launcher at :'C:\Program Files (x8
6)\Firefox-3\firefox.exe' is valid...
07:41:19.466 DEBUG - Checking whether Firefox launcher at :'C:\Program Files\Moz
illa Firefox\firefox.exe' is valid...
07:41:19.467 DEBUG - Checking whether Firefox launcher at :'C:\Program Files (x8
6)\Mozilla Firefox\firefox.exe' is valid...
07:41:19.470 DEBUG - Discovered valid Firefox launcher  : 'C:\Program Files (x86
)\Mozilla Firefox\firefox.exe'
07:41:19.472 INFO - Allocated session 9421d726998c41f894415e42f6585611 for http:
//localhost:3000, launching...
jar:file:/C:/seleniumserver/selenium-server-standalone-2.53.0.jar!/customProfile
DirCUSTFFCHROME
07:41:19.487 DEBUG - Extracting /customProfileDirCUSTFFCHROME to C:\Users\user\A
ppData\Local\Temp\customProfileDir9421d726998c41f894415e42f6585611
07:41:19.655 INFO - Launching Firefox...
07:41:19.683 DEBUG - waiting for window 'null' local frame 'null' for 1800 more
secs
07:41:19.696 DEBUG - waiting for condition for 1000 more ms
07:41:20.708 DEBUG - got condition? : false
07:41:20.709 DEBUG - waiting for window 'null' local frame 'null' for 1799 more
secs
07:41:20.710 DEBUG - waiting for condition for 1000 more ms
07:41:21.713 DEBUG - got condition? : false
07:41:21.713 DEBUG - waiting for window 'null' local frame 'null' for 1798 more
secs
07:41:21.714 DEBUG - waiting for condition for 1000 more ms
07:41:22.725 DEBUG - got condition? : false
07:41:22.729 DEBUG - waiting for window 'null' local frame 'null' for 1797 more
secs
07:41:22.731 DEBUG - waiting for condition for 1000 more ms
07:41:23.735 DEBUG - got condition? : false
07:41:23.736 DEBUG - waiting for window 'null' local frame 'null' for 1796 more
secs
07:41:23.737 DEBUG - waiting for condition for 1000 more ms
07:41:24.688 DEBUG - req: POST /selenium-server/driver/?seleniumStart=true&local
FrameAddress=top&seleniumWindowName=&uniqueId=sel_92053&sessionId=9421d726998c41
f894415e42f6585611&counterToMakeURsUniqueAndSoStopPageCachingInTheBrowser=146067
3684555&sequenceNumber=0 HTTP/1.1
Host: localhost:4444
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko/20100101 Firefox/
44.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ja,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 16
Content-Type: text/plain;charset=UTF-8


07:41:24.692 DEBUG - ---------allocating new CommandQueue for sel_92053
07:41:24.703 DEBUG - Browser 9421d726998c41f894415e42f6585611/:top sel_92053 pos
ted START NEW
07:41:24.704 DEBUG - ---------retrieving CommandQueue for sel_92053
07:41:24.707 DEBUG - sel_92053 marked as just loaded
07:41:24.708 DEBUG - got condition? : true
07:41:24.708 DEBUG -    sel_92053 commandHolder sel_92053 getCommand() called
07:41:24.711 DEBUG - waiting for data for at most 10 more s
07:41:24.710 DEBUG - waiting for window 'null' local frame 'null' for 1795 more
secs
07:41:24.714 DEBUG -    sel_92053 commandHolder sel_92053 getCommand()
07:41:24.715 DEBUG - putting command: json={command:"getTitle",target:"",value:"
"}
07:41:24.717 DEBUG - ..command put?: true
07:41:24.718 DEBUG -    sel_92053 commandResultHolder sel_92053 getResult() call
ed
07:41:24.720 DEBUG - waiting for data for at most 1800 more s
07:41:24.721 DEBUG - data from polling: json={command:"getTitle",target:"",value
:""}
07:41:24.723 DEBUG -    sel_92053 commandHolder sel_92053 getCommand() -> json={
command:"getTitle",target:"",value:""}
07:41:24.726 DEBUG - res to sel_92053: json={command:"getTitle",target:"",value:
""}
07:41:24.842 DEBUG - req: POST /selenium-server/driver/?&localFrameAddress=top&s
eleniumWindowName=&uniqueId=sel_92053&sessionId=9421d726998c41f894415e42f6585611
&counterToMakeURsUniqueAndSoStopPageCachingInTheBrowser=1460673684825&sequenceNu
mber=1 HTTP/1.1
Host: localhost:4444
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko/20100101 Firefox/
44.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ja,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 16
Content-Type: text/plain;charset=UTF-8


07:41:24.845 DEBUG - ---------retrieving CommandQueue for sel_92053
07:41:24.846 DEBUG - Browser 9421d726998c41f894415e42f6585611/:top sel_92053 pos
ted OK,
07:41:24.850 DEBUG - ---------retrieving CommandQueue for sel_92053
07:41:24.851 DEBUG - putting command: OK,
07:41:24.852 DEBUG - ..command put?: true
07:41:24.853 DEBUG -    sel_92053 commandHolder sel_92053 getCommand() called
07:41:24.855 DEBUG - waiting for data for at most 10 more s
07:41:24.852 DEBUG - data from polling: OK,
07:41:24.857 DEBUG -    sel_92053 commandResultHolder sel_92053 getResult() -> O
K,
07:41:24.859 DEBUG - wait is over: window 'null' was seen at last (sel_92053)
07:41:24.860 DEBUG - sel_92053 marked as NOT just loaded
07:41:24.861 DEBUG - Current uniqueId set to sel_92053, frameAddress = :top
07:41:24.863 DEBUG - ---------retrieving CommandQueue for sel_92053
07:41:24.864 DEBUG -    sel_92053 commandHolder sel_92053 getCommand()
07:41:24.865 DEBUG - putting command: json={command:"setContext",target:"9421d72
6998c41f894415e42f6585611",value:""}
07:41:24.868 DEBUG - ..command put?: true
07:41:24.869 DEBUG -    sel_92053 commandResultHolder sel_92053 getResult() call
ed
07:41:24.871 DEBUG - waiting for data for at most 1800 more s
07:41:24.870 DEBUG - data from polling: json={command:"setContext",target:"9421d
726998c41f894415e42f6585611",value:""}
07:41:24.872 DEBUG -    sel_92053 commandHolder sel_92053 getCommand() -> json={
command:"setContext",target:"9421d726998c41f894415e42f6585611",value:""}
07:41:24.876 DEBUG - res to sel_92053: json={command:"setContext",target:"9421d7
26998c41f894415e42f6585611",value:""}
07:41:24.943 DEBUG - req: POST /selenium-server/driver/?&localFrameAddress=top&s
eleniumWindowName=&uniqueId=sel_92053&sessionId=9421d726998c41f894415e42f6585611
&counterToMakeURsUniqueAndSoStopPageCachingInTheBrowser=1460673684923&sequenceNu
mber=2 HTTP/1.1
Host: localhost:4444
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko/20100101 Firefox/
44.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ja,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 13
Content-Type: text/plain;charset=UTF-8


07:41:24.965 DEBUG - ---------retrieving CommandQueue for sel_92053
07:41:24.967 DEBUG - Browser 9421d726998c41f894415e42f6585611/:top sel_92053 pos
ted OK
07:41:24.969 DEBUG - ---------retrieving CommandQueue for sel_92053
07:41:24.971 DEBUG - putting command: OK
07:41:24.972 DEBUG - ..command put?: true
07:41:24.973 DEBUG -    sel_92053 commandHolder sel_92053 getCommand() called
07:41:24.974 DEBUG - waiting for data for at most 10 more s
07:41:24.972 DEBUG - data from polling: OK
07:41:24.976 DEBUG -    sel_92053 commandResultHolder sel_92053 getResult() -> O
K
07:41:24.981 INFO - Got result: OK,9421d726998c41f894415e42f6585611 on session 9
421d726998c41f894415e42f6585611
07:41:24.988 DEBUG - req: POST /selenium-server/driver/ HTTP/1.1
TE: deflate,gzip;q=0.3
Connection: TE
Host: localhost:4444
User-Agent: libwww-perl/6.04
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Content-Length: 59


07:41:24.990 INFO - Command request: testComplete[, ] on session 9421d726998c41f
894415e42f6585611
07:41:24.992 INFO - Killing Firefox...
07:41:25.482 DEBUG - clearing queue set
07:41:25.483 DEBUG - putting command: CommandResultHolder.POISON
07:41:25.483 DEBUG - ..command put?: true
07:41:25.487 DEBUG -    sel_92053 commandHolder sel_92053 getCommand()  poisonin
g pollers
07:41:25.488 DEBUG - putting command: json={command:"CommandHolder.POISON",targe
t:"",value:""}
07:41:25.488 DEBUG - ..command put?: true
07:41:25.488 DEBUG - data from polling: json={command:"CommandHolder.POISON",tar
get:"",value:""}
07:41:25.489 INFO - Got result: OK on session 9421d726998c41f894415e42f6585611
07:41:25.489 DEBUG -    sel_92053 commandHolder sel_92053 getCommand() -> null


これだと起動できた。

#!/bin/perl
use Selenium::Remote::Driver;

my $d = Selenium::Remote::Driver->new( 'browser_name' => 'chrome' );

http://sleepingcatsyndrome.com/post/69870734713
sleepingcatsyndrome.com

もしかして、こういうことか。

Selenium RC WebDriver
WWW::Selenium Selenium::Remote::Driver
Test::WWW::Selenium Test::Selenium::Remote::Driver

Test::Selenium::Remote::Driverを使うのがナウいのかな。(死語)