In the code below, textarea's string is extracted using xpath and the body variable's string is used The JavaScript code that you assign to the value of the element.
And you want to run it with drv.execute_script(textarea).
Is this code I wrote grammatically correct?
I actually ran the error message "selenium.common.exception.WebDriverException: Message: unknown error: Runtime.valid or unexpected exception: SyntaxError: SyntaxError: Invalid or unexpected token"
It's coming out.
Where is the problem?
Can drv.execute_script execute only one statement?
Or is it executed even if I enter multiple JavaScript statements?
textarea = 'function getElementByXpath(path) {\
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;}\n
getElementByXpath("//*[@id=\'smart_editor2_content\']/div[4]/textarea[1]").value = "' + body + '"'
drv.execute_script(textarea)
An error message is a grammar error that occurs because there are characters that cannot be used in js.
Python supports multiline strings by default. Please modify the JavaScript part in the form below and try it.
temp = '''
function showMsg(s) {
alert(s);
}
showMsg("abcd");
'''
...
...
driver.execute_script(temp)
925 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
615 GDB gets version error when attempting to debug with the Presense SDK (IDE)
579 Understanding How to Configure Google API Key
574 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
577 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.