Python selenium cant post to textfield

时间:2013-07-27 06:12:36

标签: python selenium

您好我正在尝试使用selenium和python制作桌面tumblr程序,但我不能让selenium发布到文本字段。

<body id="tinymce" class="mceContentBody " contenteditable="true" onload="window.parent.tinyMCE.get('post_two').onLoad.dispatch();" style="overflow-y: hidden; padding-bottom: 50px;" dir="ltr">
<p>
<br data-mce-bogus="1">
</p>
</body>
</html>
</iframe>
<div id="source_editor" data-mode="http://assets.tumblr.com/javascript/ace-0.2.1a/src/mode-html.js" data-ace="http://assets.tumblr.com/javascript/ace-0.2.1a/src/ace.js">
<div class="plexi active show" data-token="source-editor-plexi"></div>
<div id="ace_source_editor" class="ace-tm ace_editor" data-mode="ace/mode/html" style="height: 80px; opacity: 1;">
<div class="ace_gutter" style="display: none;">
<div class="ace_layer ace_gutter-layer" style="margin-top: 0px;"></div>
</div>
<div class="ace_scroller" style="height: 80px; left: 0px; width: 481px;">
<div class="ace_content" style="margin-top: 0px; width: 481px; height: 114px;">
<div class="ace_layer ace_marker-layer"></div>
<div class="ace_print_margin_layer">
<div class="ace_print_margin" style="left: 596px; visibility: visible;"></div>
</div>
<div class="ace_layer ace_text-layer" style="width: auto; padding: 0px 10px;">
<div class="ace_line_group">
<div class="ace_line" style="height:17px"></div>
</div>
</div>
<div class="ace_layer ace_marker-layer"></div>
<div class="ace_layer ace_cursor-layer">
<div class="ace_cursor ace_hidden" style="left: 10px; top: 0px; width: 7.2px; height: 17px; visibility: visible;"></div>
</div>
</div>
</div>
<div class="ace_sb" style="width: 22px; height: 80px;">
<div style="height: 17px;"></div>
</div>
<textarea style="left: -9359px; top: -9772.6px;"></textarea>
</div>
</div>

这是代码的屏幕

http://puu.sh/3MNZA.png

我需要的只是发布到这个文本字段,但它使用某种JS编辑器。 Xpath应该是id('ace_source_editor')/ x:div [2] / x:div但仍然无效。感谢任何帮助

1 个答案:

答案 0 :(得分:0)

您必须在xpath中包含/ textarea。获取元素后,您可以发送键进入文本字段。