Selenium 1 の　バッチ実行時のテンプレート

# いまさら
作ってもすぐといえばすぐですが、環境動作確認用に使うことがあるのでコピペできるようにテンプレートを貼り付けておく

## テストケース

```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://www.yahoo.co.jp/" />
<title>testcase</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">testcase</td></tr>
</thead><tbody>
<tr>
	<td>open</td>
	<td>/</td>
	<td></td>
</tr>
<tr>
	<td>type</td>
	<td>id=srchtxt</td>
	<td>selenium</td>
</tr>
<tr>
	<td>clickAndWait</td>
	<td>id=srchbtn</td>
	<td></td>
</tr>
<tr>
	<td>assertTitle</td>
	<td>「selenium」の検索結果 - Yahoo!検索</td>
	<td></td>
</tr>
<tr>
	<td>captureEntirePageScreenshot</td>
	<td>c:\temp\ss01.png</td>
	<td>#CCFFDD</td>
</tr>

</tbody></table>
</body>
</html>
```
ポイントはスクリーンショットを撮る点と、日本語が混じっている点
保存する際には utf-8で。

## テストスイート

```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
  <title>Test Suite</title>
</head>
<body>
<table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium"><tbody>
<tr><td><b>Test Suite</b></td></tr>
<tr><td><a href="testcase.html">testcase</a></td></tr>
</tbody></table>
</body>
</html>
```

同じディレクトリに作成しているテストケースを呼び出すだけ

## 起動バッチ

```
java  -Dfile.encoding=8859_1 -jar selenium-server-standalone-2.45.0.jar -debug -logLongForm -htmlSuite "*firefox" http://www.yahoo.co.jp testsuite.html result.html > log.txt 2>&1
```
jarファイルも同一ディレクトリに保存している前提。
ポイントは日本語が文字化けしないように　エンコーディング指定

result.html は　スクリプトの実行結果
log.txt　は　デバックログが出力される

## デバックログ

```
18:24:06.968 INFO [10] org.openqa.grid.selenium.GridLauncher - Launching a standalone server
18:24:07.015 INFO [10] org.openqa.selenium.server.SeleniumServer - Java: Sun Microsystems Inc. 11.2-b01
18:24:07.015 INFO [10] org.openqa.selenium.server.SeleniumServer - OS: Windows XP 5.1 x86
18:24:07.015 INFO [10] org.openqa.selenium.server.SeleniumServer - v2.45.0, with Core v2.45.0. Built from revision 5017cb8
18:24:07.015 INFO [10] org.openqa.selenium.server.SeleniumServer - Selenium server running in debug mode.
18:24:07.031 DEBUG [10] org.openqa.jetty.util.Container - add component: SocketListener0@0.0.0.0:4444
18:24:07.046 DEBUG [10] org.openqa.jetty.util.Container - add component: org.openqa.jetty.http.ResourceCache@1f630dc
18:24:07.046 DEBUG [10] org.openqa.jetty.util.Container - add component: org.openqa.selenium.server.ProxyHandler in HttpContext[/,/]
18:24:07.046 DEBUG [10] org.openqa.jetty.util.Container - add component: HttpContext[/,/]
18:24:07.046 DEBUG [10] org.openqa.jetty.http.HttpServer - Added HttpContext[/,/] for host *

(略)

18:24:15.890 DEBUG [16] org.openqa.jetty.http.HttpConnection - REQUEST from SocketListener0@0.0.0.0:4444:
POST /selenium-server/postResults HTTP/1.1
Host: localhost:4444
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:37.0) Gecko/20100101 Firefox/37.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-Type: application/x-www-form-urlencoded
Content-Length: 2817


18:24:15.890 DEBUG [16] org.openqa.jetty.http.HttpServer - Try HttpContext[/selenium-server,/selenium-server],0
18:24:15.890 DEBUG [16] org.openqa.jetty.http.HttpContext - RestishHandler org.openqa.jetty.http.handler.SecurityHandler in HttpContext[/selenium-server,/selenium-server]
18:24:15.890 DEBUG [16] org.openqa.jetty.http.HttpContext - RestishHandler org.openqa.selenium.server.StaticContentHandler in HttpContext[/selenium-server,/selenium-server]
18:24:15.890 INFO [16] org.openqa.jetty.util.Credential - Checking Resource aliases
18:24:15.890 DEBUG [16] org.openqa.jetty.http.handler.ResourceHandler - PATH=/postResults RESOURCE=file:/C:/Documents%20and%20Settings/y-norikane/My%20Documents/GIT/selenium/MISSING%20RESOURCE
18:24:15.890 DEBUG [16] org.openqa.jetty.http.handler.ResourceHandler - Looking for file:/C:/Documents%20and%20Settings/y-norikane/My%20Documents/GIT/selenium/MISSING%20RESOURCE
18:24:15.890 DEBUG [16] org.openqa.jetty.http.HttpContext - RestishHandler org.openqa.selenium.server.SessionExtensionJsHandler in HttpContext[/selenium-server,/selenium-server]
18:24:15.890 DEBUG [16] org.openqa.jetty.http.HttpContext - RestishHandler org.openqa.selenium.server.htmlrunner.SingleTestSuiteResourceHandler in HttpContext[/selenium-server,/selenium-server]
18:24:15.890 DEBUG [16] org.openqa.jetty.http.HttpContext - RestishHandler org.openqa.selenium.server.htmlrunner.SeleniumHTMLRunnerResultsHandler@4b222f
18:24:15.890 INFO [16] org.openqa.selenium.server.htmlrunner.SeleniumHTMLRunnerResultsHandler - Received posted results
testcase.html
<a href="testcase.html">testcase</a></td></tr>
</tbody></table>



18:24:15.953 DEBUG [16] org.openqa.jetty.http.HttpContext - Handled by org.openqa.selenium.server.htmlrunner.SeleniumHTMLRunnerResultsHandler@4b222f
18:24:15.953 DEBUG [16] org.openqa.jetty.http.HttpConnection - RESPONSE:
HTTP/1.1 200 OK
Date: Thu, 07 May 2015 09:24:15 GMT
Server: Jetty/5.1.x (Windows XP/5.1 x86 java/1.6.0_12
Cache-Control: no-cache
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/html
Transfer-Encoding: chunked


18:24:16.281 INFO [10] org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher - Killing Firefox...
18:24:16.390 DEBUG [14] org.openqa.jetty.http.HttpConnection - java.net.SocketException: Connection reset
18:24:16.390 DEBUG [15] org.openqa.jetty.http.HttpConnection - java.net.SocketException: Connection reset
18:24:16.390 DEBUG [16] org.openqa.jetty.http.HttpConnection - java.net.SocketException: Connection reset
18:24:16.390 DEBUG [17] org.openqa.jetty.http.HttpConnection - java.net.SocketException: Connection reset
18:24:16.390 DEBUG [12] org.openqa.jetty.http.HttpConnection - java.net.SocketException: Connection reset
18:24:16.390 DEBUG [13] org.openqa.jetty.http.HttpConnection - java.net.SocketException: Connection reset
18:24:16.500 INFO [18] org.openqa.selenium.server.SeleniumServer - Shutting down...
18:24:16.500 DEBUG [18] org.openqa.jetty.util.Container - Stopping org.openqa.jetty.jetty.Server@1bf52a5
18:24:16.500 DEBUG [18] org.openqa.jetty.util.ThreadedServer - closing ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=4444]
```




## 実行結果

```
Test suite results
result: 	passed
totalTime: 	8
numTestTotal: 	1
numTestPasses: 	1
numTestFailures: 	0
numCommandPasses: 	1
numCommandFailures: 	0
numCommandErrors: 	0
Selenium Version: 	2.45
Selenium Revision: 	.0
Test Suite
testcase
	 
testcase.html
testcase
open 	/ 	
type 	id=srchtxt 	selenium
clickAndWait 	id=srchbtn 	
assertTitle 	「selenium」の検索結果 - Yahoo!検索 	
captureEntirePageScreenshot 	c:\temp\ss01.png 	#CCFFDD
	 

info: Starting test /selenium-server/tests/testcase.html
info: Executing: |open | / |  |
info: Selenium 1.0 (Core, RC, etc) is no longer under active development. Please update to WebDriver ASAP
info: Executing: |type | id=srchtxt | selenium |
info: Executing: |clickAndWait | id=srchbtn |  |
info: Selenium 1.0 (Core, RC, etc) is no longer under active development. Please update to WebDriver ASAP
info: Executing: |assertTitle | 「selenium」の検索結果 - Yahoo!検索 |  |
info: Selenium 1.0 (Core, RC, etc) is no longer under active development. Please update to WebDriver ASAP
info: Executing: |captureEntirePageScreenshot | c:\temp\ss01.png | #CCFFDD |
```

## ちなみに
実行結果には　「とっととwebDriverに移行しなさいよ！」って出てます。