chromedp / chromedp

A faster, simpler way to drive browsers supporting the Chrome DevTools Protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Screenshot from remote browser

itzikiusa opened this issue · comments

What versions are you running?

v0.9.5

What did you do? Include clear steps.

i'm trying to capture screenshot in remote browser(using https://github.com/Zenika/alpine-chrome image)
actions:

  1. navigate to page
  2. wait for X seconds
  3. capture screenshot

getting error:
open page: Internal error (-32603)

	actions := make([]chromedp.Action, 0)
	if platformToRun != "desktop" {
		actions = append(actions, chromedp.Emulate(device.GalaxyS9landscape))
	}

	var screenShot []byte
	actions = append(actions, chromedp.Navigate(gameToRun.StartGameRequest),
		// wait for the page to load
		chromedp.Sleep(30*time.Second),
	)

	if viper.GetBool("ENABLE_SCREENSHOT") {
		actions = append(actions, chromedp.FullScreenshot(&screenShot, 50))
	}

	if viper.GetBool("ENABLE_SCREENSHOT") {
		reader := bytes.NewReader(screenShot)

		s3Session, err := session.NewSession(&aws.Config{
			Region: aws.String(viper.GetString("awsRegion")),
			Credentials: credentials.NewStaticCredentials(
				viper.GetString("accessKey"),
				viper.GetString("secretKey"),
				"",
			),
		})

		if err != nil {
			logger.LOGGER.Errorf("could not create s3 session: %v", err)
			return
		}

		s3SVC := s3.New(s3Session)
		_, err = s3SVC.PutObject(&s3.PutObjectInput{
			Bucket:             aws.String(viper.GetString("bucketName")),
			Key:                aws.String(filePath),
			Body:               reader,
			ContentDisposition: aws.String("inline"),
			ContentType:        aws.String("image/jpeg"),
		})
		if err != nil {
			logger.LOGGER.Errorf("could not upload image to s3: %v", err)
			return
		}
}

What did you expect to see?

i expected to see the image itself, when i run without remote, it works as expected

What did you see instead?

error.....