xvfb-run --listen-tcp --server-num 44 -s "-ac -screen 0 1920x1080x24" mvn clean test &
export DISPLAY=:44
ffmpeg -f x11grab -video_size 1920x1080 -i :44 -codec:v libx264 -r 12 video.mp4
This is the bash script i am using to run the selenium test cases(in headless mode) with maven as the build tool in port 44 and capture it. But when i execute it i only get a black screen. What to do?
Solution - Even though i run the maven program in the port 44,the firefox driver opens up in any random port so, we have to add
System.setProperty("webdriver.gecko.driver","/home/saran/Downloads/geckodriver");
Map<String, String> environment = new HashMap<>();
environment.put("DISPLAY", ":44");
GeckoDriverService service = new GeckoDriverService.Builder()
.usingAnyFreePort()
.withEnvironment(environment)
.build();
driver = new FirefoxDriver(service);