小编yar*_*inc的帖子

选择器无效:使用Webdriver和Python的find_element_by_class_name不允许使用复合类名

我正在尝试通过webWhatsapp从聊天中打印我的消息之一。

我可以通过“控制台”选项卡中的Javascript完成此操作

recived_msg = document.getElementsByClassName('XELVh selectable-text invisible-space copyable-text') // returns an array of the chat
recived_msg[5].innerText // shows me the 4th message content
Run Code Online (Sandbox Code Playgroud)

问题是我试图在python上做同样的事情,但对我不起作用。

这是我尝试过的:

from selenium import webdriver
recived_msg = driver.find_element_by_class_name('XELVh selectable-text invisible-space copyable-text')
final = recived_msg[5].innerText #doesnt work for some reason
Run Code Online (Sandbox Code Playgroud)

我遇到的错误是:消息:无效的选择器:不允许使用复合类名

我对javascript有点陌生,所以很抱歉造成误会,并感谢您的帮助!:)

xpath webdriver css-selectors python-3.x selenium-webdriver

1
推荐指数
1
解决办法
815
查看次数