#NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div/div[2]/input"}
(Session info: chrome=100.0.4896.127))
在这里插入图片描述
检查所在位置是否隶属于iframe标签
iframe 元素会创建包含另外一个文档的内联框架(即行内框架)。selenium无法定位到内联框架,所以报错没有这个元素
使用switch_to.frame()切换到内联框架
driver.switch_to.frame('HSP_SERVICE_CATA') # 获取当前窗口
time.sleep(2)
# 输入服务名
button1 =driver.find_element_by_xpath('/html/body/div/div[2]/input')
time.sleep(4)
button1.send_keys(str(content(0)))