Python 3.x 如何在Selenium中选择textarea?
我一直在从事一个项目,并在使用Python 3.x 如何在Selenium中选择textarea?,python-3.x,selenium,selenium-webdriver,Python 3.x,Selenium,Selenium Webdriver,我一直在从事一个项目,并在使用.get\u attribute('value')和.get\u attribute('text')选择web元素方面取得了很大成功 我试图从下面截图中的web元素中选择文本,但不知道如何选择文本 我尝试了以下方法: operation_instructions = driver.find_element_by_id('txtOperationDescription').get_attribute('value') operation_instructions =
.get\u attribute('value')
和.get\u attribute('text')
选择web元素方面取得了很大成功
我试图从下面截图中的web元素中选择文本,但不知道如何选择文本
我尝试了以下方法:
operation_instructions = driver.find_element_by_id('txtOperationDescription').get_attribute('value')
operation_instructions = driver.find_element_by_id('txtOperationDescription').get_attribute('text')
print(WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.ID,"txtOperationDescription"))).get_attribute('text'))
根据注释,我尝试了以下操作,但它们print
a空行:
print(WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.ID,"txtOperationDescription"))).get_attribute('value'))
print(WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.ID,"txtOperationDescription"))).get_attribute('innerHTML'))
有趣的是,当我尝试以下操作时得到None
:
operation_instructions = driver.find_element_by_id('txtOperationDescription').get_attribute('value')
operation_instructions = driver.find_element_by_id('txtOperationDescription').get_attribute('text')
print(WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.ID,"txtOperationDescription"))).get_attribute('text'))
在发布问题之前,我尝试了我认为可能有效的所有不同元素,例如:
operation_instructions = driver.find_element_by_id('txtOperationDescription').get_attribute('value')
operation_instructions = driver.find_element_by_id('txtOperationDescription').get_attribute('text')
print(WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.ID,"txtOperationDescription"))).get_attribute('text'))
operation\u instructions=驱动程序。通过\u id('txtOperationDescription')查找\u元素。获取\u属性('textarea')
但是我不知道如何在这个字段中选择文本
元素应该使用
get\u属性(“value”)
来检索值。您是否提供了足够的时间来加载并获取值?请明确尝试打印:print(WebDriverWait(driver,10)。直到(EC.visibility\u元素的位置((By.ID,“txtOperationDescription”))。get\u属性(“value”))
try:get\u attribute('innerHTML')您是否尝试过operation\u instructions\u text=driver。通过\u id('txtOperationDescription')查找\u元素。text
?您可以尝试一下:print(WebDriverWait(driver,10)。直到(EC.presence\u元素的位置((by.id,“txtOperationDescription”)))。get\u attribute('textContent'))
或print(WebDriverWait(driver,10)。直到(EC.presence\u of_element\u located((By.ID,“hndUpdateDescription”))。获取属性('value'))
或打印(WebDriverWait(driver,10)。直到(EC.presence\u of_element\u located((By.ID,“hndUpdateDescription”)))。获取属性('textContent'))