【问题标题】:Python with selenium: unable to locate element xpath带有硒的Python:无法找到元素xpath
【发布时间】:2021-06-24 23:45:06
【问题描述】:
from selenium import webdriver


driver = webdriver.Chrome()
driver.get('https://www.twitch.tv/popout/gaules/chat?popout=')

driver.find_element_by_xpath('//*[@id="root"]/div/div[1]/div/div/div/div[2]/div/button').click()

name = driver.find_element_by_xpath('*//p[@class="sc-AxirZ bmRDsM"]')

driver.close()
print(name.text)

消息:没有这样的元素:无法找到元素: {"method":"xpath","selector":"*//p[@class="sc-AxirZ bmRDsM"]"}

为什么我没有收到“Gaules”这个名字作为回应?

【问题讨论】:

    标签: python-3.x selenium-webdriver web-scraping


    【解决方案1】:

    这可能是因为您已经关闭了驱动程序会话。 它应该工作:

    name = driver.find_element_by_xpath('*//p[@class="sc-AxirZ bmRDsM"]').text
    

    【讨论】:

      猜你喜欢
      • 2019-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-13
      • 1970-01-01
      • 1970-01-01
      • 2022-01-23
      • 1970-01-01
      相关资源
      最近更新 更多