Python Selenium chrome驱动程序send_keys()不允许在消息中键入/(斜杠)。我尝试使用WhatsApp发送网址,但send_keys()会跳过网址中的所有斜杠。
我尝试过
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
driver = webdriver.Chrome("/usr/bin/chromedriver")
driver.get('https://web.whatsapp.com/')
while True:
try:
msg_box = driver.find_element(By.CLASS_NAME,'CLASS_NAME')
msg_box.send_keys("https://image.shutterstock.com/z/stock-photo-colorful-flower-on-dark-tropical-foliage-nature-background-721703848$703848.jpg")
driver.find_element_by_class_name('class name').click()
except Exception as e:
print("Exception")
print(e)
time.sleep(5)
driver.close()
输出:https:image.shutterstock.comzstock-photo-colorful-flower-on-dark-tropical-foliage-nature-background-721703848 $ 703848.jpg