예제 #1
0
func launchVideoRecording() {
	dr := agouti.ChromeDriver()
	failOnError(dr.Start())

	page, err := dr.NewPage()
	if err != nil {
		log.Fatalln("couldn't get Page")
	}

	failOnError(page.Size(videoSize.W+chrome.Left+chrome.Right, videoSize.H+chrome.Top+chrome.Bottom))

	failOnError(page.Navigate("http://localhost:7777/"))

	var screenOffset point
	failOnError(page.RunScript(`
window.loadVideoAutomation();
return {x: window.screenX, y: window.screenY};
`, nil, &screenOffset))

	for i := 0; i < 10; i++ {

		// Wait for .capture to appear
		for {
			found, err := page.All(".capture").Count()
			failOnError(err)
			if found == 1 {
				break
			}
		}

		doneCh := launchFFMPEG(screenOffset.X+chrome.Left, screenOffset.Y+chrome.Top, videoSize.W, videoSize.H, fmt.Sprintf("/tmp/video-automation-%02d.mp4", i+1))

		// Wait for .capture to disappear
		for {
			found, _ := page.All(".capture").Count()
			if found == 0 {
				break
			}
		}

		doneCh <- true

		time.Sleep(1 * time.Second)

	}

	dr.Stop()
}
예제 #2
0
func TestMain(m *testing.M) {
	var t *testing.T
	var err error

	driver = agouti.ChromeDriver()
	driver.Start()

	go Start(PORT)

	page, err = driver.NewPage()
	if err != nil {
		t.Error("Failed to open page.")
	}

	RegisterTestingT(t)
	test := m.Run()

	driver.Stop()
	os.Exit(test)
}
예제 #3
0
func TestMain(m *testing.M) {
	var t *testing.T
	var err error

	driver = agouti.ChromeDriver() // choose browser driver
	driver.Start()

	go Start(PORT) // start our program

	page, err = driver.NewPage() // get page object from driver, this is what we will use to perform browser testing
	if err != nil {
		t.Error("Failed to open page.")
	}

	RegisterTestingT(t)
	test := m.Run() // start test

	driver.Stop() // close driver after test
	os.Exit(test)
}
예제 #4
0
package integration_test

import (
	"os"
	"testing"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/sclevine/agouti"
)

var (
	phantomDriver    = agouti.PhantomJS()
	chromeDriver     = agouti.ChromeDriver()
	seleniumDriver   = agouti.Selenium(agouti.Browser("firefox"))
	selendroidDriver = agouti.Selendroid("selendroid-standalone-0.15.0-with-dependencies.jar")

	headlessOnly = os.Getenv("HEADLESS_ONLY") == "true"
	mobile       = os.Getenv("MOBILE") == "true"
)

func TestIntegration(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Integration Suite")
}

var _ = BeforeSuite(func() {
	Expect(phantomDriver.Start()).To(Succeed())
	if !headlessOnly {
		Expect(chromeDriver.Start()).To(Succeed())
		Expect(seleniumDriver.Start()).To(Succeed())