python - WebDriver claiming editable element is not editable -
i'm running simple test selenium webdriver , python send/verify receipt of email.
once switch iframe containing message body , locate editable body element , try clear out, following exception thrown:
traceback (most recent call last): driver.find_element_by_xpath("//body[@role='textbox']").clear() selenium.common.exceptions.webdriverexception: message: 'element must user-editable in order clear it.'
here script used create email:
driver.find_element_by_name("to").clear() driver.find_element_by_name("to").send_keys("toemailaddy@gmail.com") localtime = time.asctime( time.localtime(time.time()) ) subj = ("test - " + localtime) print(subj) driver.find_element_by_name("subjectbox").clear() driver.find_element_by_name("subjectbox").send_keys(subj) body = ("test") bodyframe = driver.find_element_by_xpath("//td[@class='ap']//iframe") driver.switch_to_frame(bodyframe) driver.find_element_by_xpath("//body[@role='textbox']").clear() driver.find_element_by_xpath("//body[@role='textbox']").send_keys(body) driver.find_element_by_xpath("/div[@role='button' , contains(text(), 'send')]").click() driver.find_element_by_link_text("inbox (1)").click()
however, message body explicitly user-editable. below i've included snippet of message body html have webdriver directed within iframe nested in td class "ap" explicitly shows it's editable.
<body id=":3" class="editable lw-avf" style="min-width: 0px; width: 437px; border: 0px none; margin: 0px; background: none repeat scroll 0% 0% transparent; height: 100%; overflow: hidden; direction: ltr; min-height: 121px;" hidefocus="true" g_editable="true" role="textbox">
ide able access of elements, keeping webdriver accessing them?
edit
well, found out causing exception:
i found removing following line script allowed webdriver write in textbox.
driver.find_element_by_xpath("//body[@role='textbox']").clear()
though wonder why throw exception element must editable, allows send_keys element without issue?
have tried action chains?
from selenium.webdriver import actionchains selenium.webdriver.common.keys import keys driver.switch_to_frame(bodyframe) actionchains(driver).send_keys(keys.control, "a").perform() actionchains(driver).send_keys("test").perform() # alternative: # body_ele = driver.find_element_by_xpath("//body[@role='textbox']") # body_ele.send_keys(keys.control, 'a') # body_ele.send_keys("test")
in c#, iwebelement.clear
says "if element text entry element, clear() method clear value. has no effect on other elements. text entry elements defined elements input or textarea tags.". similarly, in python source code, says "clears text if it's text entry element.", while in case, body
not text entry element.
Comments
Post a Comment