I’m using selenium to change the Yoast SEO meta description of a post in WordPress. However I cannot get this to work.
This is the code of the text box without any text in it:
<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>
The code of the text box changes if there is text in the box.
This is the box with text in it:
<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>
As you can see <br data-text="true">
gets changed to <span data-text="true">EXAMPLE TEXT</span>
How would I be able to insert text with this using selenium
2
Answers
Try below:
Note : please add below imports to your solution
Try the following code: