2013-12-11 77 views
0

我一直在按照關於Hand-Coding a Coded UI Test的分步說明學習'編碼UI'。但是,當我輸入代碼時,Visual Studio不識別HtmlProperties。 下面是一些代碼:.NET Framework 4.5不支持'HtmlProperties'嗎?

UITestControl qEdit = new UITestControl(browserWindow); 
qEdit.TechnologyName = "Web"; 
qEdit.SearchProperties.Add(HtmlProperties.Edit.ControlType, ControlType.Edit.Name, 
HtmlProperties.Edit.Id, "sb_form_q"); 
qEdit.SetProperty(HtmlProperties.Edit.Text, "MSFT"); 

順便說一句,我使用的Visual Studio 2012,.NET框架4.5。 希望我的問題有道理。謝謝!

---實習生在這裏!

回答

3

該代碼示例在多次發佈後不推薦使用。以下是更新的同一個代碼:

UITestControl qEdit = new UITestControl(browserWindow); 
qEdit.TechnologyName = "Web"; 
qEdit.SearchProperties.Add("ControlType", "Name", 
"Id", "sb_form_q"); 
qEdit.SetProperty("Text", "MSFT"); 

編輯補充: 我知道有更多,但是這是我能找到的唯一參考。在編寫原代碼的代碼被破壞後的某個時候,有一次VS2010的更新。 MSDN hand coding thread

Found it!

+0

不幸的是,它沒有奏效。運行測試時發生異常。但感謝您的幫助:)我已經找到了解決方案。 – Stackeroo

+0

我仍然認爲這是答案,因爲它真的回答了我的問題。謝謝! :) – Stackeroo

+0

@yonidtm您可以提供一個鏈接,指出討論棄用的位置和現在的首選樣式嗎? – AdrianHHH

0

我已經找到了解決辦法。這是我做的:

UITestControl qEdit = new UITestControl(browserWindow); 
qEdit.TechnologyName = "Web"; 
qEdit.SearchProperties.Add(HtmlControl.PropertyNames.Id, "sb_form_q"); 
qEdit.SetProperty(HtmlEdit.PropertyNames.Text, "MSFT"); 
相關問題