J'ai fait un script pour remplir un manuel dans une page web interne, mais les développeurs de ma société ont changé le code et mon code ci-dessous ne fonctionne plus.
tell application "Safari" to tell window id theWINID to do JavaScript "document.getElementsByClassName('text-entry')[0].value=" & quoted form of myCaseNote in tab 1
Voici le code du champ de texte de la page
J'ai essayé plusieurs choses mais je n'arrive pas à changer le texte (dans la démo de l'image "texte que je dois passer").
Toute aide serait très appréciée
<div lobid="##" data="[object Object]" casenotedata="[object Object]" caseid="5sd4sd-sd55sd-5sds5-sds5-sdsd55s" class="css-bzgzwc"><div class="note-input css-1d9ma27" data-cy="note-input"><div class="textarea-container"><div class="form-textarea-container css-9db1eh"><div class="form-textbox"><div class="form-textarea focused"><textarea aria-invalid="false" id="form-textarea-123" name="note-input-224" aria-labelledby="form-textarea-123_label" aria-describedby=""></textarea></div><span id="form-textarea-123_label" class="form-textbox-label" aria-hidden="true">Note</span></div></div></div></div><div class="note-toolbar css-o3el1q" data-cy="note-toolbar"><div class="buttons-container"><button class="add-note-button" type="button">Apply</button></div></div></div>
<div class="note-input css-1d9ma27" data-cy="note-input"><div class="textarea-container"><div class="form-textarea-container css-9db1eh"><div class="form-textbox"><div class="form-textarea focused"><textarea aria-invalid="false" id="form-textarea-123" name="note-input-224" aria-labelledby="form-textarea-123_label" aria-describedby=""></textarea></div><span id="form-textarea-123_label" class="form-textbox-label" aria-hidden="true">Note</span></div></div></div></div>
<div class="form-textarea-container css-9db1eh"><div class="form-textbox"><div class="form-textarea focused"><textarea aria-invalid="false" id="form-textarea-123" name="note-input-224" aria-labelledby="form-textarea-123_label" aria-describedby=""></textarea></div><span id="form-textarea-123_label" class="form-textbox-label" aria-hidden="true">Note</span></div></div>
<div class="textarea-container"><div class="form-textarea-container css-9db1eh"><div class="form-textbox"><div class="form-textarea focused"><textarea aria-invalid="false" id="form-textarea-123" name="note-input-224" aria-labelledby="form-textarea-123_label" aria-describedby=""></textarea></div><span id="form-textarea-123_label" class="form-textbox-label" aria-hidden="true">Note</span></div></div></div>
<div class="form-textarea focused"><textarea aria-invalid="false" id="form-textarea-123" name="note-input-224" aria-labelledby="form-textarea-123_label" aria-describedby=""></textarea></div>
<div class="form-textbox"><div class="form-textarea focused"><textarea aria-invalid="false" id="form-textarea-123" name="note-input-224" aria-labelledby="form-textarea-123_label" aria-describedby=""></textarea></div><span id="form-textarea-123_label" class="form-textbox-label" aria-hidden="true">Note</span></div>
<textarea aria-invalid="false" id="form-textarea-123" name="note-input-224" aria-labelledby="form-textarea-123_label" aria-describedby=""></textarea>
<div class="form-textarea focused"><textarea aria-invalid="false" id="form-textarea-123" name="note-input-224" aria-labelledby="form-textarea-123_label" aria-describedby=""></textarea></div>
<span id="form-textarea-123_label" class="form-textbox-label" aria-hidden="true">Note</span>
<div class="form-textbox"><div class="form-textarea focused"><textarea aria-invalid="false" id="form-textarea-123" name="note-input-224" aria-labelledby="form-textarea-123_label" aria-describedby=""></textarea></div><span id="form-textarea-123_label" class="form-textbox-label" aria-hidden="true">Note</span></div>
<div class="form-textarea-container css-9db1eh"><div class="form-textbox"><div class="form-textarea focused"><textarea aria-invalid="false" id="form-textarea-123" name="note-input-224" aria-labelledby="form-textarea-123_label" aria-describedby=""></textarea></div><span id="form-textarea-123_label" class="form-textbox-label" aria-hidden="true">Note</span></div></div>
<div class="textarea-container"><div class="form-textarea-container css-9db1eh"><div class="form-textbox"><div class="form-textarea focused"><textarea aria-invalid="false" id="form-textarea-123" name="note-input-224" aria-labelledby="form-textarea-123_label" aria-describedby=""></textarea></div><span id="form-textarea-123_label" class="form-textbox-label" aria-hidden="true">Note</span></div></div></div>
<div class="note-input css-1d9ma27" data-cy="note-input"><div class="textarea-container"><div class="form-textarea-container css-9db1eh"><div class="form-textbox"><div class="form-textarea focused"><textarea aria-invalid="false" id="form-textarea-123" name="note-input-224" aria-labelledby="form-textarea-123_label" aria-describedby=""></textarea></div><span id="form-textarea-123_label" class="form-textbox-label" aria-hidden="true">Note</span></div></div></div></div>
<div class="note-toolbar css-o3el1q" data-cy="note-toolbar"><div class="buttons-container"><button class="add-note-button" type="button">Apply</button></div></div>
<div lobid="iTunes" data="[object Object]" casenotedata="[object Object]" caseid="bf4ecda0-113e-11ec-944e-9bd3d18184e9" class="css-bzgzwc"><div class="note-input css-1d9ma27" data-cy="note-input"><div class="textarea-container"><div class="form-textarea-container css-9db1eh"><div class="form-textbox"><div class="form-textarea focused"><textarea aria-invalid="false" id="form-textarea-123" name="note-input-224" aria-labelledby="form-textarea-123_label" aria-describedby=""></textarea></div><span id="form-textarea-123_label" class="form-textbox-label" aria-hidden="true">Note</span></div></div></div></div><div class="note-toolbar css-o3el1q" data-cy="note-toolbar"><div class="buttons-container"><button class="add-note-button" type="button">Apply</button></div></div></div>
cela fonctionne mais il semble que form-textarea-123 change tout le temps (les chiffres)
tell application "Safari"
do JavaScript "document.getElementById('form-textarea-123').value = 'demo'" in current tab of window 1
end tell
le code actuel
<textarea aria-invalid="false" id="form-textarea-123" name="note-input-224" aria-labelledby="form-textarea-123_label" aria-describedby=""></textarea>
Cela ne fonctionne pas non plus :
do JavaScript "document.getElementById('form-textarea').innerText;" in current tab of window 1