• <legend id='8IZNg'><style id='8IZNg'><dir id='8IZNg'><q id='8IZNg'></q></dir></style></legend>
      <bdo id='8IZNg'></bdo><ul id='8IZNg'></ul>
  • <small id='8IZNg'></small><noframes id='8IZNg'>

    1. <tfoot id='8IZNg'></tfoot>
        <i id='8IZNg'><tr id='8IZNg'><dt id='8IZNg'><q id='8IZNg'><span id='8IZNg'><b id='8IZNg'><form id='8IZNg'><ins id='8IZNg'></ins><ul id='8IZNg'></ul><sub id='8IZNg'></sub></form><legend id='8IZNg'></legend><bdo id='8IZNg'><pre id='8IZNg'><center id='8IZNg'></center></pre></bdo></b><th id='8IZNg'></th></span></q></dt></tr></i><div id='8IZNg'><tfoot id='8IZNg'></tfoot><dl id='8IZNg'><fieldset id='8IZNg'></fieldset></dl></div>

      1. 使用 Python 向联系人发送 whatsapp 消息但收到错误:InvalidSelectorException:

        时间:2023-07-05

        1. <tfoot id='HRE2F'></tfoot>

            <tbody id='HRE2F'></tbody>

          1. <i id='HRE2F'><tr id='HRE2F'><dt id='HRE2F'><q id='HRE2F'><span id='HRE2F'><b id='HRE2F'><form id='HRE2F'><ins id='HRE2F'></ins><ul id='HRE2F'></ul><sub id='HRE2F'></sub></form><legend id='HRE2F'></legend><bdo id='HRE2F'><pre id='HRE2F'><center id='HRE2F'></center></pre></bdo></b><th id='HRE2F'></th></span></q></dt></tr></i><div id='HRE2F'><tfoot id='HRE2F'></tfoot><dl id='HRE2F'><fieldset id='HRE2F'></fieldset></dl></div>
              <bdo id='HRE2F'></bdo><ul id='HRE2F'></ul>
              • <legend id='HRE2F'><style id='HRE2F'><dir id='HRE2F'><q id='HRE2F'></q></dir></style></legend>
              • <small id='HRE2F'></small><noframes id='HRE2F'>

                  本文介绍了使用 Python 向联系人发送 whatsapp 消息但收到错误:InvalidSelectorException: Message: invalid selector: Unable to locate an element的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 Python 向联系人发送 whatsapp 消息,但出现错误:InvalidSelectorException:消息:无效选择器:无法使用 xpath 表达式定位元素//span[@title = "Me Postpaid"]"}(会话信息:chrome=73.0.3683.103)(驱动信息:chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Windows NT 6.1.7601 SP1 x86_64)

                  I am trying to send whatsapp message to contacts using Python but getting an error: InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //span[@title = "Me Postpaid"]"} (Session info: chrome=73.0.3683.103) (Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Windows NT 6.1.7601 SP1 x86_64)

                  我为此使用了 selenium,代码如下:

                  I have used selenium for this and the code is mentioned below:

                  from selenium import webdriver
                  
                  driver = webdriver.Chrome('C:/Users/....../chromedriver_win32/chromedriver.exe') 
                  driver.get('https://web.whatsapp.com/')
                  
                  name = input('Enter the name of person or group you want to message: ')
                  msg = input('Enter your Message: ')
                  count = int(input('Enter how many times you want to send this message: '))
                  
                  
                  input('Enter any key after scanning QR code')
                  
                  user = driver.find_element_by_xpath('//span[@title = "        {}"]'.format(name)).click()
                  #user.click()
                  
                  msg_box = driver.find_element_by_class_name('_1Plpp')
                  
                  for i in range(count):
                  
                      msg_box.send_keys(msg)
                      button = driver.find_element_by_class_name('_35EW6')
                      button.click()
                  

                  我怎样才能做到这一点???

                  How can I make this work ???

                  推荐答案

                  click() 不返回任何内容.因此,您需要删除分配并正确替换代码行的格式:

                  click() doesn't returns anything. So you need to remove the assignment and format the line of code properly replacing:

                  user = driver.find_element_by_xpath('//span[@title = "        {}"]'.format(name)).click()
                  

                  与:

                  driver.find_element_by_xpath('//span[@title= "{}"]'.format(name)).click()
                  

                  这篇关于使用 Python 向联系人发送 whatsapp 消息但收到错误:InvalidSelectorException: Message: invalid selector: Unable to locate an element的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:弃用警告:在 Windows 上使用带有 Python Selenium 和 Chromedriver 的 Brave 下一篇:使用 Selenium Python ChromeDriver 从弹出窗口/表单下载 PDF

                  相关文章

                    <bdo id='DIrqp'></bdo><ul id='DIrqp'></ul>
                  1. <small id='DIrqp'></small><noframes id='DIrqp'>

                    <legend id='DIrqp'><style id='DIrqp'><dir id='DIrqp'><q id='DIrqp'></q></dir></style></legend>
                      <i id='DIrqp'><tr id='DIrqp'><dt id='DIrqp'><q id='DIrqp'><span id='DIrqp'><b id='DIrqp'><form id='DIrqp'><ins id='DIrqp'></ins><ul id='DIrqp'></ul><sub id='DIrqp'></sub></form><legend id='DIrqp'></legend><bdo id='DIrqp'><pre id='DIrqp'><center id='DIrqp'></center></pre></bdo></b><th id='DIrqp'></th></span></q></dt></tr></i><div id='DIrqp'><tfoot id='DIrqp'></tfoot><dl id='DIrqp'><fieldset id='DIrqp'></fieldset></dl></div>
                      <tfoot id='DIrqp'></tfoot>