python-selenium元素定位不到这个窗口不晓得怎么回事使用xpath都定位不到这个元素

python-selenium元素定位不到这个窗口不晓得怎么回事使用xpath都定位不到这个元素

问题描述:

img
不晓得怎么定位过去,我用xpath 都不行,所有元素方法都试过了都不行,不知道为何就是每次都报错,都试因为元素找不到问题。

因为有iframe这个标签了,这个要切换过去,参考一下:https://blog.csdn.net/huilan_same/article/details/52200586

如果对你有帮助,可以点击我这个回答右上方的【采纳】按钮,给我个采纳吗,谢谢

from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get("https://x5.qq.com/act/4145/a20201023zxzhm/index.html#/")
time.sleep(5)
driver.switch_to_frame(0)
driver.switch_to_frame('switcher_plogin').click()
time.sleep(3)
这切不进去啊,是我写的不对么?想输入账号密码的。

from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get("https://x5.qq.com/act/4145/a20201023zxzhm/index.html#/")
time.sleep(5)
driver.switch_to.frame(driver.find_element_by_class_name("loginframe")) #切入
time.sleep(2)
driver.find_element_by_id('switcher_plogin').click()
time.sleep(3)
driver.switch_to.default_content() # 切出