源码如图:
 
下拉选择框select元素的定位,报错:ElementNotInteractableException
直接使用Select类进行选择,selector(driver.find_element_by_id("Agency")) 会提示如下信息
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable: Element is not currently visible and may not be manipulated
# 下拉选择框随机选择
def selector(self,element):
    ele = Select(element)
    count_options = len(ele.options) - 1
    ele.select_by_index(random.randint(0, count_options))
 
display元素没有定义,直接通过js修改是无效的。必须通过修改元素的style样式的display属性才成功。
下拉选择框select元素的定位,报错:ElementNotInteractableException
 
下拉选择框select元素的定位,报错:ElementNotInteractableException
agency_ele = driver.find_element_by_id("Agency")
js = """ele = document.getElementById("Agency");
ele.style.display='block';
"""
driver.execute_script(js)
selector(agency_ele)

 

 

 

下拉选择框select元素的定位,报错:ElementNotInteractableException

相关文章:

  • 2022-12-23
  • 2022-03-01
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2021-11-17
  • 2022-02-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-27
  • 2021-09-21
  • 2021-08-17
  • 2022-12-23
  • 2021-12-01
  • 2021-11-29
相关资源
相似解决方案