[英]Selenium Python send_keys to a code block
我試圖獲取塊並單擊它。 那個有效!
code_box = driver.find_element_by_xpath('//*[@id="prog-div-py3"]/div/div[6]')
code_box.click()
但是,當我嘗試使用 send_keys 時,出現了一些錯誤。
selenium.common.exceptions.ElementNotInteractableException: Message: element
not interactable
示例python代碼:
def hello:
print("Hi")
如何解決?
這里的 Webelement 是 CodeMirror。 以下代碼對我有用,請嘗試使用它:
WebElement codeMirror = driver.findElement(By.className("CodeMirror"));
WebElement codeLine = codeMirror.findElements(By.className("CodeMirror-line")).get(0);
codeLine.click();
WebElement txtbx = codeMirror.findElement(By.cssSelector("textarea"));
txtbx.sendKeys(text);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.