Skip to content

[Bug]: ExpectDownload timeout:Timeout #579

@githubzhaoqian

Description

@githubzhaoqian

Environments

  • playwright-go Version: v0.5200.1
  • Browser: Chromium
  • OS and version: macOS
    Bug description
    ExpectDownload timeout:Timeout
func TestExpectDownload(t *testing.T) {
	pw, err := playwright.Run()
	if err != nil {
		log.Fatalf("could not start playwright: %v", err)
	}
	defer pw.Stop()
	browser, err := pw.Chromium.Launch()
	if err != nil {
		log.Fatalf("could not launch browser: %v", err)
	}
	defer browser.Close()
	device := pw.Devices["iPad Mini"]

	context, err := browser.NewContext(playwright.BrowserNewContextOptions{
		Permissions:       []string{"geolocation"},
		Viewport:          device.Viewport,
		UserAgent:         playwright.String(device.UserAgent),
		DeviceScaleFactor: playwright.Float(device.DeviceScaleFactor),
		IsMobile:          playwright.Bool(device.IsMobile),
		HasTouch:          playwright.Bool(device.HasTouch),
	})
	if err != nil {
		t.Fatalf("could not create context: %v", err)
	}
	page, err := context.NewPage()
	if err != nil {
		t.Fatalf("could not create page: %v", err)
	}

	defer page.Close()

	var videoTimeout float64 = 5000
        // xxxxxxxxxx.jpg Change to a valid image address 😂
	page.SetContent(`<a href="xxxxxxxxxx.jpg">download</a>`)
	pDownload, err := page.ExpectDownload(func() error {
		t.Log("href")
		t.Log(page.Locator("a").First().GetAttribute("href"))
		err := page.Locator("a").Click(playwright.LocatorClickOptions{
			Timeout: &videoTimeout,
		})
		if err != nil {
			return fmt.Errorf("click: %v", err)
		}
		return nil
	}, playwright.PageExpectDownloadOptions{
		Timeout: &videoTimeout,
	})
	if err != nil {
		log.Fatalf("ExpectDownload err: %v", err)
	}
	t.Log("Download.URL:", pDownload.URL())
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions