使用 xvfb 在 运行 时在 linux 中聚焦 chrome window

Focus chrome window in linux when running using xvfb

我正在使用以下 shell 脚本来获得对特定 chrome window 的关注:

#!/bin/sh

WIDId=`xdotool search "Test page"`
xdotool windowactivate --sync $WIDId
sleep 2
xdotool windowactivate $WIDId
xdotool key --clearmodifiers ctrl+a

它在 运行 时正常工作,但在 运行 chrome 使用 xvfb 时失败。 在 xvfb 中无法找到 windowID。 我需要它才能开始使用 xvfb。

即使不使用 windowactivate 也能正常工作,因为我只打开了一个需要焦点的 window。