私がやったことを分かち合うと思いました。私はSpring.netを使ってこのようなSeleniumSettingsクラスに設定を注入しました。
<objects xmlns="http://www.springframework.net" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd" >
<object id="Settings" type="Sample.SeleniumSettings, Sample" singleton="true">
<property name="Server" value="localhost"/>
<property name="Port" value="4444"/>
<property name="Browser" value="*firefox" />
<property name="Url" value="http://website.com"/>
<property name="Email" value="[email protected]"/>
</object>
</objects>
これは、Testクラスでの設定と呼ばれるプロパティにSeleniumSettingsを注入します。テストはAbstractDependencyInjectionSpringContextTestsから継承し、実装する必要があります。
protected override string[] ConfigLocations
設定クラスは次のようになります。
public class SeleniumSettings
{
public const string DefaultEmailAddress = "[email protected]";
public const string DefaultServerAddress = "localhost";
public const string DefaultProtocol = "http://";
public const string DefaultEndPoint = "/";
public string Server = DefaultServerAddress;
public int Port = 4444;
public string Browser = "*firefox";
public string Url = "http://localhost";
public string Email = DefaultEmailAddress;
public ISelenium factory()
{
return new DefaultSelenium(Server, Port, Browser, Url);
}
}
次に、SeleniumSettings.factory()を使用して、テストを実行するDefaultSeleniumオブジェクトを取得します。
Seleniumのドキュメントにはこれに関するいくつかの情報がありますが、あまりにも速すぎますので、この情報を設定するのに必要な基本情報はスキップします。
私はDefaultSeleniumオブジェクトを元々クラスに注入しようとしましたが、内部的にSeleniumがクラッシュする問題がありました。 Spring.netのインジェクションによって作成されたのが好きではないようです。
私はこれが誰かを助けてくれることを願っています。