У меня есть страница, как это:Селен Элемент в настоящее время не видно и поэтому не может быть взаимодействовали с
<div class="CodeMirror">
<div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 6.2px; left: 182.2px;">
\t <textarea autocapitalize="off" autocorrect="off" style="position: absolute; padding: 0px; width: 1px; height: 1em;" wrap="off"></textarea>
</div>
<div style="display: none; height: 106px;" class="CodeMirror-scrollbar"> <div style="height: 114px;" class="CodeMirror-scrollbar-inner"></div></div>
<div> ...
...
..
</div>
<pre style="top: 39px; left: 0px;" class="CodeMirror-cursor"> </pre>
<div style="">
<pre>asdf</pre>
<pre>asdfasdf</pre> It's weird the textarea content is here
<pre>asdfasdf</pre>
<pre> </pre>
</div>
...
...
и я использую селен, чтобы выбрать, но получить два элемента и я посылаю ключ к одной из них бросает Selenium::WebDriver::Error::ElementNotVisibleError: Element is not currently visible and so may not be interacted with
Вот моя команда операции:
browser.browser.public_send(:textareas, :xpath => "//div[@class='CodeMirror']//textarea[@wrap='off']")[0].html
=> "<textarea autocapitalize=\"off\" autocorrect=\"off\" style=\"position: absolute; padding: 0px; width: 1px; height: 1em;\" wrap=\"off\"></textarea>"
[58] pry(#<CucuShift::DefaultWorld>)> browser.browser.public_send(:textareas, :xpath => "//div[@class='CodeMirror']//textarea[@wrap='off']")[1].html
=> "<textarea autocapitalize=\"off\" autocorrect=\"off\" style=\"position: absolute; padding: 0px; width: 1px; height: 1em;\" wrap=\"off\"></textarea>"
browser.browser.public_send(:textareas, :xpath => "//div[@class='CodeMirror']/descendant::textarea[@autocorrect='off']")[1].click
Selenium::WebDriver::Error::ElementNotVisibleError: Element is not currently visible and so may not be interacted with
from [remote server] file:///tmp/webdriver-profile20160801-26332-bu7605/extensions/[email protected]/components/command-processor.js:10092:in `fxdriver.preconditions.visible'
browser.browser.public_send(:textareas, :xpath => "//div[@class='CodeMirror']/descendant::textarea[@autocorrect='off']")[1].send_keys '1234'
Selenium::WebDriver::Error::ElementNotVisibleError: Element is not currently visible and so may not be interacted with
from [remote server] file:///tmp/webdriver-profile20160801-26332-bu7605/extensions/[email protected]/components/command-processor.js:10092:in `fxdriver.preconditions.visible'
самая странная вещь есть те тоже элементы HTML одинаковы.
На самом деле, это проблема CodeMirror –