2016-08-26 38 views
0

這是html代碼,id是動態的。如何自動化TextField ExtJs? C#Selenium

<td id="ext-gen2730" class="x-grid-cell x-grid-td x-grid-cell-headerId-gridcolumn-1246 x-grid-cell-last g-cell-edit x-grid-cell-selected"> 
<div id="ext-gen2726" class="x-grid-cell-inner " style="text-align: left ! important;">&nbps</div> 

我的代碼

[FindsBy(How = How.XPath, Using = "//tbody/tr/td[4]/div")] 
private IWebElement NroInscripcion; 
NroInscripcion.Click();` // this work 
NroInscripcion.SendKeys("20"); // not work -> An exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll but was not handled in user code` 

還我試圖

var action = new Actions(); 
action.SendKeys("21"); //not work 
action.Clik(NroInscripcion).SendKeys("21"); //not work 
+0

該div是否可以作爲文本框? –

回答

1

您只能使用的SendKeys用於輸入HTML元素。沒有div,span等

你有一個文本框或文本區域內的div?如果是這樣搜索該webelement,然後使用sendkeys

+0

感謝您的回覆。我發現textarea的名稱是'name'。所以我可以使用發送鍵。再次感謝你。 –