मुझे एक विनफॉर्म एप्लिकेशन में एक ग्रिड (फ्लेक्सग्रिड, कंपोनेंटऑन से) मिला है और मैं सेल के कॉलम इंडेक्स और उसके मान को देखते हुए उस ग्रिड में एक सेल ढूंढने की कोशिश कर रहा हूं।कोडेडयूआई: सेल इतनी धीमी क्यों खोज रही है?
मैंने ग्रिड के माध्यम से लूप को नीचे विस्तार विधि लिखा है और उस सेल को ढूंढ लिया है।
मैं उस विधि को उस ग्रिड पर परीक्षण कर रहा हूं जिसमें 6 कॉलम और 64 पंक्तियां हैं। मेरे कोड के लिए सही सेल (जो अंतिम पंक्ति पर था) को खोजने में 10 मिनट लग गए।
क्या कोई तरीका है कि मैं अपना एल्गोरिदम बढ़ा सकता हूं?
नोट: मैं भी TopLevelWindow को PlayBack.PlayBackSetting.SmartMatchOption स्थापित करने की कोशिश की है, लेकिन यह कुछ भी बदलने नहीं लगता है ...
धन्यवाद!
public static WinCell FindCellByColumnAndValue(this WinTable table, int colIndex, string strCellValue)
{
int count = table.GetChildren().Count;
for (int rowIndex = 0; rowIndex < count; rowIndex++)
{
WinRow row = new WinRow(table);
WinCell cell = new WinCell(row);
row.SearchProperties.Add(WinRow.PropertyNames.RowIndex, rowIndex.ToString());
cell.SearchProperties.Add(WinCell.PropertyNames.ColumnIndex, colIndex.ToString());
cell.SearchProperties.Add(WinCell.PropertyNames.Value, strCellValue);
if (cell.Exists)
return cell;
}
return new WinCell();
}
संपादित
मैं नीचे की तरह बनना मेरी विधि (उदा। मैं winrow अब और का उपयोग नहीं करते) को संशोधित किया, इस तेजी से 3x चारों ओर हो रहा है। इसे अभी भी 3 पंक्तियों और 6 कॉलम वाली तालिका में सेल खोजने के लिए 7 सेकंड की आवश्यकता है, इसलिए यह अभी भी धीमा है ...
मैं इस उत्तर को अन्य लोगों को सुझाव देने के लिए समय के बाद स्वीकार कर दूंगा कुछ बेहतर
public static WinCell FindCellByColumnAndValue(this WinTable table, int colIndex, string strCellValue, bool searchHeader = false)
{
Playback.PlaybackSettings.SmartMatchOptions = Microsoft.VisualStudio.TestTools.UITest.Extension.SmartMatchOptions.None;
int count = table.GetChildren().Count;
for (int rowIndex = 0; rowIndex < count; rowIndex++)
{
WinCell cell = new WinCell(table);
cell.SearchProperties.Add(WinRow.PropertyNames.RowIndex, rowIndex.ToString());
cell.SearchProperties.Add(WinCell.PropertyNames.ColumnIndex, colIndex.ToString());
cell.SearchProperties.Add(WinCell.PropertyNames.Value, strCellValue);
if (cell.Exists)
return cell;
}
return new WinCell();
}
संपादित # 2: मैं अनुसार @ एंड्री के सुझाव FindMatchingControls उपयोग करने की कोशिश की है, और मैं लगभग वहाँ (c.ColumnIndex) कर रहा हूँ, कि सेल के स्तंभ अनुक्रमणिका नीचे कोड को छोड़कर गलत मूल्य है ..
public static WinCell FindCellByColumnAndValue2(this WinTable table, int colIndex, string strCellValue, bool searchHeader = false)
{
WinRow row = new WinRow(table);
//Filter rows containing the wanted value
row.SearchProperties.Add(new PropertyExpression(WinRow.PropertyNames.Value, strCellValue, PropertyExpressionOperator.Contains));
var rows = row.FindMatchingControls();
foreach (var r in rows)
{
WinCell cell = new WinCell(r);
cell.SearchProperties.Add(WinCell.PropertyNames.Value, strCellValue);
//Filter cells with the wanted value in the current row
var controls = cell.FindMatchingControls();
foreach (var ctl in controls)
{
var c = ctl as WinCell;
if (c.ColumnIndex == colIndex)//ERROR: The only cell in my table with the correct value returns a column index of 2, instead of 0 (being in the first cell)
return c;
}
}
return new WinCell();
}
विक्रेता से संपर्क करें। – leppie
मैं सहमत हूं कि [यूआई ऑटोमेशन परीक्षण] (http://social.msdn.microsoft.com/Forums/da/vsautotest/threads) एमएसडीएन मंचों के अनुभाग में वे आमतौर पर कोडित यूआई प्रश्नों के लिए काफी व्यापक उत्तर प्रदान करते हैं। –
@leppie: हाँ, मैंने अपने मंच पर एक संदेश पोस्ट किया है, मैं बस उत्तर देने का इंतजार कर रहा हूं – David