LingDong- / wechit

WeChat in Terminal (微信终端版)
MIT License
89 stars 21 forks source link

no such element {"method" : "class name", "selector" : "give_me"} #2

Open egg-west opened 5 years ago

egg-west commented 5 years ago

This Error is probably sensitive to the version of chrome or the platform.

Happened when I scanned the QR and press a key.

press a key after scanning...1
Traceback (most recent call last):
  File "wechit.py", line 500, in <module>
    main()
  File "wechit.py", line 453, in main
    print("logged in as \""+get_username(driver)+"\"! loading chats...")
  File "wechit.py", line 299, in get_username
    driver.find_element_by_class_name("give_me").find_element_by_class_name("display_name").get_attribute("innerHTML")
  File "/root/anaconda3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 564, in find_element_by_class_name
    return self.find_element(by=By.CLASS_NAME, value=name)
  File "/root/anaconda3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element
    'value': value})['value']
  File "/root/anaconda3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/root/anaconda3/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"class name","selector":"give_me"}
  (Session info: headless chrome=70.0.3538.110)
  (Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 3.10.0-693.2.2.el7.x86_64 x86_64)
LingDong- commented 5 years ago

Hi,

From this error, and your last error in the other issue, it seems that you've not logged in successfully. The two errors both indicate that the WeChat web interface did not load at all.

Just wanted to double confirm, did you scan the QR code with your phone when it appeared in the Terminal?

After you scan the QR code with WeChat on your phone, you will see something like the screenshot below, and you need to tap "Log In". After that (and waiting for 2-5 seconds depending on your network connection), wechit will load your chats automatically (or after you press ENTER, in case you're using the patch code I gave you in the other issue).

_

If you really already did the above and it's still not working, then it sounds really confusing and give me some time to think about what could possibly go wrong.

UPDATE:

My code is looking for these specific elements in the HTML.

snip20181205_2

Could you please add the following line right before it threw the error:

print driver.find_element_by_class_name("main").get_attribute("innerHTML")

And check if the elements I circled in the screenshot are there? Or if it's more convenient for you just dump the output here and l can take a look (but your friends names will also be in the HTML, so better redact them when copy-pasting!)

Thanks.

zhaoxuyan commented 4 years ago

python 2.7.15 macOS 10.15.1 chrome : 版本 79.0.3945.88(正式版本) (64 位) ChromeDriver 79.0.3945.36 Happened when I scanned the QR and press a key. Please help. @LingDong-

press a key after scanning...
Traceback (most recent call last):
  File "wechit.py", line 495, in <module>
    main()
  File "wechit.py", line 448, in main
    print("logged in as \""+get_username(driver)+"\"! loading chats...")
  File "wechit.py", line 294, in get_username
    driver.find_element_by_class_name("give_me").find_element_by_class_name("display_name").get_attribute("innerHTML")
  File "/Users/zhaoxuyan/anaconda/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 564, in find_element_by_class_name
    return self.find_element(by=By.CLASS_NAME, value=name)
  File "/Users/zhaoxuyan/anaconda/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element
    'value': value})['value']
  File "/Users/zhaoxuyan/anaconda/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/Users/zhaoxuyan/anaconda/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".give_me"}
  (Session info: headless chrome=79.0.3945.88)
ChenDanCMU commented 4 years ago

Same issue here. OS: Debian 10 buster chrome: 79 python: 3.77 Traceback (most recent call last): File "wechit.py", line 488, in main() File "wechit.py", line 441, in main print("logged in as \""+get_username(driver)+"\"! loading chats...") File "wechit.py", line 287, in get_username driver.find_element_by_class_name("give_me").find_element_by_class_name("display_name").get_attribute("innerHTML") File "/home/chen/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 564, in find_element_by_class_name return self.find_element(by=By.CLASS_NAME, value=name) File "/home/chen/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element 'value': value})['value'] File "/home/chen/.local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/chen/.local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".give_me"} (Session info: headless chrome=79.0.3945.130)