2014-01-28 38 views
0

我有一些使用MTM執行的硒測試用例。我必須在不同的操作系統和瀏覽器上執行測試,以設置這些我使用的配置文件。我想要的是從我們在MTM中設置的配置中獲取瀏覽器和操作系統的價值,即如果我使用操作系統和瀏覽器值分別設置爲Windows 7和Chrome的配置執行測試,它應該自動設置操作系統到Windows 7和瀏覽器到Chrome爲特定的測試運行。接下來,如果我選擇一些具有不同值的其他配置,它應該使用OS和瀏覽器的這些值運行。在運行時從TFS獲取MTM中設置的配置值

如何在我的代碼中獲取這些值?

+1

我記得馬塞爾德弗里斯博客關於那...這是你在追求什麼? http://blogs.infosupport.com/switching-browser-in-codedui-or-selenium-tests-based-on-mtm-configuration/ – jessehouwing

+0

謝謝@jessehouwing,我想從配置名稱的配置值,在這裏,我們可以得到配置,但如何獲得內部的值,因爲我必須同時設置操作系統和瀏覽器。 –

回答

1
using (TfsTeamProjectCollection collection = new TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName("<YourTFSServerURL>"))) 
{ 
    ITestManagementService tcmService = collection.GetService<ITestManagementService>(); 
    ITestManagementTeamProject project = tcmService.GetTeamProject("<YourTFSProject>"); 

    //Get configuration, which contains configuration values 
    ITestConfiguration testConfiguration = project.TestConfigurations.Query("Select * from TestConfiguration WHERE Name='" + yourConfigurationName + "'")[0]; 
    IDictionary<string, string> testConfigValues = testConfiguration.Values; 

    string browser = testConfigValues["Browser"]; 
    string operatingSystem = testConfigValues["Operating System"]; 
}