问题描述
在此代码中,我想输入ID为cke_1_contents的文本,输入字段为html / body。我尝试使用xpath和id,但是它不起作用。
如何在文本区域内编写文本?
[<div id="cke_1_contents" class="cke_contents cke_reset" role="presentation" style="height: 200px;"><span id="cke_86" class="cke_voice_label">Press ALT 0 for help</span>
<iframe src="" frameborder="0" class="cke_wysiwyg_frame cke_reset" style="width: 1010px; height: 100%;" title="Rich Text Editor,mailContent" aria-describedby="cke_86" tabindex="0" allowtransparency="true">
<html dir="ltr" lang="en">
<head>
<title data-cke-title="Rich Text Editor,mailContent">Rich Text Editor,mailContent</title>
<style data-cke-temp="1">html{cursor:text;*cursor:auto}img,input,textarea{cursor:default}</style>
</head>
<body contenteditable="true" class="cke_editable cke_editable_themed cke_contents_ltr cke_show_borders" spellcheck="false">
<p>Hi,this is test mail</p>
</body>
</html>
</iframe>
</div>
解决方法
要使用iframe,您首先需要driver.switchTo()。frame