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
相关产品推荐
相关产品推荐

