How to mute all sounds in chrome webdriver with selenium

后端 未结 3 1277
时光取名叫无心
时光取名叫无心 2021-02-07 00:12

I want to write a script in which I use selenium package like this:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get(\"https://www.youtube.         


        
3条回答
  •  南笙
    南笙 (楼主)
    2021-02-07 00:20

    use javascript to mute sounds like this

    code py

    watch_video_js= """
               let video = document.querySelector('video')
               video.muted = true
               video.play()
          """
    driver.execute_script(watch_video_js)
    

提交回复
热议问题