I have a problem running selenium sesion with Xvfb to record video file with sesion. Below is my session and wrapper
from selenium import webdriver
from xvfbwrapper import Xvfb
class TestPages(unittest.TestCase):
def setUp(self):
self.xvfb = Xvfb(width=1280, height=720)
self.addCleanup(self.xvfb.stop)
self.xvfb.start()
self.browser = webdriver.Chrome()
self.addCleanup(self.browser.quit)
def testUbuntuHomepage(self):
self.browser.get('http://www.ubuntu.com')
self.assertIn('Ubuntu', self.browser.title)
def testGoogleHomepage(self):
self.browser.get('http://www.google.com')
self.assertIn('Google', self.browser.title)
if __name__ == '__main__':
unittest.main()
Sesions exit with no errors and
The problem is dosent create any kind of files in main directory or /temp directory
where are the files ?
After very long research of multiple way to run this on AWS came to few concussions:
Here is my final solution, how to record video of what is happening inside Selenium on AWS EC Ubuntu.
from selenium import webdriver
import time
import os
import subprocess
from pyvirtualdisplay.smartdisplay import SmartDisplay
with SmartDisplay() as disp:
print(os.environ.get("DISPLAY"))
print ("before webdriver")
driver = webdriver.Firefox()
subprocess.call(['ffmpeg -y -video_size 1024x768 -rtbufsize 500M -framerate 24 -f x11grab -i :0.0 -preset ultrafast output.mp4 &'], shell=True)
driver.get("YOUR WEBSITE URL")
# YOUR SELENIUM CODE HERE
subprocess.call(["echo q"], shell=True)
disp.stop()