You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python+Selenium无法定位Shelly网站搜索框元素求助

问题:无法定位登录后页面的搜索框元素
  • 我是Python结合Selenium的新手,现在需要定位一个需登录网站的搜索框XPath
  • 登录页可以用Selenium标准函数正常自动化操作,但进入带搜索框的页面后,元素定位的标准函数就失效了
  • 尝试过两个XPath都识别不了目标元素:
    • //*[@id="puik-search-bar"]
    • /html/body/shelly-app/main/div[1]/section/app-root/app-search-page/div/div/div/div/app-search-product/div/puik-card/div/puik-search-bar//div/div[2]/input//
  • 之前了解到有些情况定位XPath前需要切换iframe,但这个网站并没有使用iframe,我也尝试过以下切换frame的代码,同样无效:
    • driver.switch_to.frame(driver.find_element_by_class_name("shelly-app__page"))
    • driver.switch_to.frame(driver.find_element_by_tag_name("shelly-app"))
    • driver.switch_to.frame(1)
  • 我用来定位元素的代码如下:
    name = driver.find_element('xpath','//*[@id="puik-search-bar"]')
    name.send_keys(sname)
    
  • 现在想寻求有效的解决方法

内容的提问来源于stack exchange,提问作者fridgekido

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 00:55:57