【问题标题】:Getting text from Selenium + Python从 Selenium + Python 获取文本
【发布时间】:2018-09-17 21:33:56
【问题描述】:

无法收到“您无法加入此群组,因为它已满。”作为文本。请帮我。 也请告诉我使用 Beautiful Soup 的代码。

【问题讨论】:

  • 分享你的代码
  • 你将不得不重新回答这个问题。

标签: python html selenium element whatsapp


【解决方案1】:

使用 XPath

//div[contains(@class,'_31LzD')]/div[text()='You can't join this group because it is full']
//div[contains(@class,'_3QNwO')]//precding::div[text()='You can't join this group because it is full']

【讨论】:

    【解决方案2】:

    假设类名不变,你可以使用:

    browser.find_elements_by_xpath("//div[contains(@class,'_31LzD')]/div")
    

    如果类确实发生了变化,你总是可以从像.copyable-area这样的“固定”元素开始工作:

    browser.find_elements_by_xpath("//div[contains(@class,'copyable-area')]/div/div/div/div/div")
    

    如果知道文本本身不会改变,可以根据文本内容查询:

    driver.find_elements_by_xpath("//div[contains(text(), 'You can't join this group because it is full')]")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-10
      • 1970-01-01
      • 2022-11-16
      • 1970-01-01
      • 2021-11-19
      • 1970-01-01
      相关资源
      最近更新 更多