python - How to know changes in color with selenium (python)
问题描述
Am working on this website : here , when u insert a text in the text-area, and click on play button
it gonna take a while then you hear the audio, what i did notice is when the audio is playing the
border around the text-area turns to blue.
what i want to know: is there any way to detect that using selenium on python.
解决方案
Yes, you can. This is actually the CSS property "outline".
The code below clicks the button and prints the outline, which is "rgb(15, 97, 254) solid 2px".
import time
from selenium import webdriver
from bs4 import BeautifulSoup
from webdriver_manager.chrome import ChromeDriverManager
def scrape_products():
options = webdriver.ChromeOptions()
options.add_argument('start-maximized')
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option("useAutomationExtension", False)
browser = webdriver.Chrome(ChromeDriverManager().install(), options=options)
browser.get("https://www.ibm.com/demos/live/tts-demo/self-service/home")
time.sleep(2)
play = browser.find_element_by_id('btn')
play.click()
time.sleep(10)
textarea = browser.find_element_by_id('text-area')
outline = textarea.value_of_css_property('outline')
print(outline)
if __name__ == "__main__":
scrape_products()
推荐阅读
- stomp - 如果 TCP 已经保证了帧的传递,为什么 STOMP 协议有 ACK 和 NACK?
- c# - 如何阻止用户切换桌面
- python - AES OCB 加密无法正常工作的示例
- c++ - 有人可以解释特殊的 std::function 模板参数列表语法(这个奇怪的 Type(Types...))吗?
- javascript - Python vs Javascript MD5 对于大数字不同
- datagrid - Jboss JDG节点未加入集群
- sorting - react-bootstrap-table2 sortFunc 从未调用过
- javascript - 需要帮助消除滚动菜单上的不透明度
- javascript - 从 Node.js + Vue.js 中的远程 SFTP 服务器下载文件?
- image - 图片上的贴纸(可拖动、可缩放和可旋转)