每次尝试将文本插入网页上的 CodeMirror 时,我都会收到以下错误消息。有谁知道如何使用selenium成功编辑codemirror?
WebDriverException: Message: unknown error: Cannot read property 'setValue' of undefined
Run Code Online (Sandbox Code Playgroud)
这是我的 Selenium-Python 代码
def click_component_script_editor(self):
driver = self.driver
line18Edit = self.driver.find_element(By.XPATH, "//html//div[@class='CodeMirror-line']//div[18]/pre[1]")
driver.execute_script("arguments[0].CodeMirror.setValue(arguments[1]);",
line18Edit,
"foo.bar")
Run Code Online (Sandbox Code Playgroud)