Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screenshot from remote browser #1452

Open
itzikiusa opened this issue Mar 21, 2024 · 0 comments
Open

Screenshot from remote browser #1452

itzikiusa opened this issue Mar 21, 2024 · 0 comments

Comments

@itzikiusa
Copy link

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.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant