我正在使用selenium更改WordPress中帖子的Yoast SEO元描述。然而,我不能让它工作
这是文本框的代码,其中没有任何文本:
<div class="DraftEditor-editorContainer">
<div aria-autocomplete="list" aria-describedby="placeholder-3oen9" aria-expanded="false" aria-labelledby="3" class="notranslate public-DraftEditor-content" contenteditable="true" role="combobox" spellcheck="false" id="snippet-editor-field-description" 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="3oen9" data-offset-key="9otfs-0-0">
<div data-offset-key="9otfs-0-0" class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr">
<span data-offset-key="9otfs-0-0">
<br data-text="true">
</span>
</div>
</div>
</div>
</div>
</div>
如果文本框中有文本,则文本框的代码将更改。 这是包含文本的框:
<div class="DraftEditor-editorContainer">
<div aria-autocomplete="list" aria-describedby="placeholder-3oen9" aria-expanded="false" aria-labelledby="3" class="notranslate public-DraftEditor-content" contenteditable="true" role="combobox" spellcheck="false" id="snippet-editor-field-description" 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="3oen9" data-offset-key="9otfs-0-0">
<div data-offset-key="9otfs-0-0" class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr">
<span data-offset-key="9otfs-0-0">
<span data-text="true">EXAMPLE TEXT</span>
</span>
</div>
</div>
</div>
</div>
</div>
如您所见<br data-text="true">
变为<span data-text="true">EXAMPLE TEXT</span>
我怎样才能使用selenium插入文本
请尝试以下内容:
注意:请将以下导入添加到您的解决方案中
请尝试以下代码: