microsoft / playwright-python

Python version of the Playwright testing and automation library.
https://playwright.dev/python/
Apache License 2.0
11.41k stars 867 forks source link

How do I set imagesEnabled=false in playwright like in selenium? #482

Closed SansLang closed 3 years ago

SansLang commented 3 years ago

in selenium, I dont need page image full loading and I can use option.add_argument('blink-settings=imagesEnabled=false'). now in playwright I want achieve the same effect,but the playwright documentation not mention about this ,how can I do for this,thank you

pavelfeldman commented 3 years ago

https://playwright.dev/python/docs/network/#abort-requests

You can use route (prefferrably on context) to not load images.

SansLang commented 3 years ago

https://playwright.dev/python/docs/network/#abort-requests

You can use route (prefferrably on context) to not load images.

thanks for your reply.but if I set abort all image request in context then loading page with launch browser headful,the page broken because can not load something must, cause I can not get page object 1

SansLang commented 3 years ago

https://playwright.dev/python/docs/network/#abort-requests

您可以使用路由(最好在上下文中)不加载图像。

Thanks for your reply again,and I find other way to achieve this by launch browser with args,the args are ["--blink-settings=imagesEnabled=false"]

mandras73 commented 11 months ago

I'm creating a class for Browser and calling:

Browser.running_context = chromium.launch(headless=False, timeout=160_000, args=["--blink-settings=imagesEnabled=false"])