如何将coledable =“ true”发送到DIV元素=使用硒和C#
有一个我不知道如何在其中键入文本的元素。
<div class="floatstart gridcell grideditablefield" colname="Items" coltype="string" coleditable="true" val="" style="width: 107px; overflow: hidden; cursor: text; height: 100%;"> </div>
没有代码(手动)以将文本放入其中,我需要单击两次,因此,在代码中,如果我单击元素一次,则类似乎会更改为:
<div class="floatstart gridcell grideditablefield activecell"...> </div>
当我再次单击该元素时,它一次更改一次无论如何
<div class="floatstart gridcell grideditablefield activecell NDColEditableInEdit"...> </div>
,一旦我尝试将密钥发送到它,我会收到一个错误:
OpenQA.Selenium.ElementNotVisibleException: 'element not interactable
(Session info: chrome=//doesn't matter)
(Driver info: chromedriver=//doesn't matter (6a5d10861ce8de5fce22564658033b43cb7de047-refs/branch-heads/4896@{#875}),platform=Windows NT 10.0.19042 x86_64)'
代码:
// It does find the right element
var element = driverReUse.FindElementByXPath("//*[@id='CalcOfAmmountsData']/div/div[2]/div/div[1]/div[2]");
element.Click();
element.Click();
element.SendKeys("keys");
请帮助
There is an element I can't figure out how to type text into it.
<div class="floatstart gridcell grideditablefield" colname="Items" coltype="string" coleditable="true" val="" style="width: 107px; overflow: hidden; cursor: text; height: 100%;"> </div>
Without code (manually) in order to put text in it I need to click on it twice, so in the code If I click on the element once, the class seems to change to:
<div class="floatstart gridcell grideditablefield activecell"...> </div>
And when I click on the element again it changes once more to
<div class="floatstart gridcell grideditablefield activecell NDColEditableInEdit"...> </div>
Anyway, once I try to send keys to it I get an Error:
OpenQA.Selenium.ElementNotVisibleException: 'element not interactable
(Session info: chrome=//doesn't matter)
(Driver info: chromedriver=//doesn't matter (6a5d10861ce8de5fce22564658033b43cb7de047-refs/branch-heads/4896@{#875}),platform=Windows NT 10.0.19042 x86_64)'
Code:
// It does find the right element
var element = driverReUse.FindElementByXPath("//*[@id='CalcOfAmmountsData']/div/div[2]/div/div[1]/div[2]");
element.Click();
element.Click();
element.SendKeys("keys");
Please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试以下操作,
请在上面的
c#
上进行更改。希望这个回答您的问题。
Try the below,
Please make the changed if any required for
c#
, in above.Hope this answer your question.
通常,除非它包含属性
contentedialitable =“ true”
。正如您提到的,深度潜水
最初是
&lt; div&gt;
元素是:第一次单击之后:
第二次单击后:
按照 this 和
&lt; input&gt;
/&lt; textarea&gt;
被添加,需要如下发送字符序列:Generally
<div>
tags are not interactable unless it contains the attributecontenteditable="true"
.Deep Dive
As you mentioned, initially the
<div>
element is:After first click:
After second click:
As per this and this discussion either after the first or second click an
<input>
/<textarea>
gets added, where you need to send the character sequence as follows: