我如何在selenium中屏幕共享第二页

9gm1akwq  于 2023-06-23  发布在  其他
关注(0)|答案(1)|浏览(106)

我目前正在尝试使用Chrome中的屏幕共享弹出窗口来实现屏幕共享第二个页面我在pyautogui中使用了一种方法,但我正试图在selenium中使其完全自动化
我试过这些论点

options.add_argument("--use-fake-ui-for-media-stream")
options.add_argument("--enable-usermedia-screen-capturing")
options.add_argument("--allow-http-screen-capture")

但正如预期的那样,它screenshares整个屏幕,但不是第二页在 selenium

ax6ht2ek

ax6ht2ek1#

您可以在Chrome的getUserMedia约束中使用chromeMediaSource和chromeMediaSourceId选项

# Set the desired page/tab index to capture (0 for first, 1 for second, and so on)
page_index_to_capture = 1 

chrome_options.add_argument(f"--use-file-for-fake-video-capture={page_index_to_capture}")

driver = webdriver.Chrome(options=chrome_options)

相关问题