【发布时间】:2021-01-08 04:27:55
【问题描述】:
<div class="_5yk2" tabindex="-1"><div class="_5rp7"><div class="_1p1t" style=""><div class="_1p1v" id="placeholder-7mj5h" style="white-space: pre-wrap;">Write a post...</div></div><div class="_5rpb"><div aria-autocomplete="list" aria-controls="js_fe" aria-describedby="placeholder-7mj5h" aria-label="Write a post..." aria-multiline="true" class="notranslate _5rpu" contenteditable="true" role="textbox" spellcheck="true" style="outline: none; user-select: text; white-space: pre-wrap; overflow-wrap: break-word;"><div data-contents="true"><div class="" data-block="true" data-editor="7mj5h" data-offset-key="6o271-0-0"><div data-offset-key="6o271-0-0" class="_1mf _1mj"><span data-offset-key="6o271-0-0"><br data-text="true"></span></div></div></div></div></div></div></div>
我在 Chrome 驱动程序中使用 XPath 来查找文本区域。这是我的代码行。
ele = driver.FindElement(By.XPath("//div[@aria-autocomplete='list']"));
Chrome 驱动程序抛出 NoSuchElementException。如何获取此元素以便向其发送文本?
【问题讨论】:
-
确保它不在 iframe 中。
标签: c# selenium xpath css-selectors webdriverwait