2009-04-22 4 views
0

テストクラスから動的URLを取得する必要があります。テストからの動的リンクを処理するために、このデザインパターンをフォーマットする際に助けてくれる人がいますか?定数HomePageURLではなく汎用クラスで動的URLを持つにはどうすればいいですか

Namespace TestDesign 
Public Class HomePage 
    Inherits IE 
    Public Const HomePageURL As String = "testlink" 

    Public Sub New() 
     MyBase.New(HomePageURL) 
    End Sub 

    Public Sub New(ByVal instance As IE) 
     MyBase.New(instance.InternetExplorer) 
    End Sub 

    Public ReadOnly Property UserIDField() As TextField 
     Get 
      Return TextField(Find.ById(New Regex("txtuserName"))) 
     End Get 
    End Property 
    Public ReadOnly Property PasswordField() As TextField 
     Get 
      Return TextField(Find.ById(New Regex("txtPassword"))) 
     End Get 
    End Property 
    Public ReadOnly Property ContinueButton() As Button 
     Get 
      Return Button(Find.ById(New Regex("Submit"))) 
     End Get 
    End Property 
    Public ReadOnly Property LogoutLink() As Link 
     Get 
      Return Link(Find.ById(New Regex("lnkLogout"))) 
     End Get 
    End Property 

    Friend Sub Login(ByVal username As String, ByVal password As String) 
     UserIDField.TypeText(username) 
     PasswordField.TypeText(password) 
     ContinueButton.Click() 
    End Sub 

    Friend Sub Logout() 
     LogoutLink.Click() 
    End Sub 

End Class  

エンド名前空間

答えて

0

私は、これはapplicaitonの設定にベースURLを配置し、ここでそれらを構築するためのURLクラスを構築することですアプローチの例であるだろうか。

アプリの設定

でクラスファイル内

<appSettings> <add key="TestServerUri" value="http://www.apple.com"/> </appSettings>

public static Uri AppleHome 

    { 
     get 
     { 
      return new Uri(ConfigurationManager.AppSettings["TestServerUri"]); 
     } 
    } 

    public static Uri Iphone = new Uri(AppleHome, @"/iphone/"); 
関連する問題