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

Add plugins option into kw "New Browser" #3972

Open
12jakubpavel opened this issue Dec 20, 2024 · 10 comments
Open

Add plugins option into kw "New Browser" #3972

12jakubpavel opened this issue Dec 20, 2024 · 10 comments
Labels
closeable? This issue should be closed?

Comments

@12jakubpavel
Copy link

I'm currently using the complex New Persistent Context kw to set up only plugins to automatically download PDF files for me. I have these 2 KW, which first sets up the given plugin and then I have to return everything to its original state.
Furthermore, New Persistent Context do not work well with New Context, which we often use.
obrazek

This is in Precerences:
obrazek

@aaltat
Copy link
Member

aaltat commented Dec 20, 2024

I do not understand your request. I could not find plugin argument form Playwright API documentation. Also it looks like you have file somewhere, but your example does not show how that file is used. Could you explain what your need is and not the solution you are currently yousing?

@aaltat aaltat added the closeable? This issue should be closed? label Jan 2, 2025
@12jakubpavel
Copy link
Author

I have problem, because I need 1 specific argument for auto dowload files (I have problem with blob: file), but I found only 1 solution what I sent into this ticket. So is it possible add option into New Browser KW for custom plugins? Selenium have something similary.

@aaltat
Copy link
Member

aaltat commented Jan 17, 2025

Browser library uses Playwriting for controlling browsers. It’s not the same technology as selenium. Therefore you would find something similar from the Playwright API documentation.

If you are referring to SeleniumLibrary plugin, then Browser library has the same functionality, with the difference that Browser library uses Playwright and not selenium.

But your request is still hard to understand, could you please elaborate it more. Example what is the argument, what it’s supposed to do, if you are using similar things in selenium or SeleniumLibrary side, can you show it and anything else what could help us to understand your problem better.

@hutbazku
Copy link

I have the same problem when using Browser and also solved it in a similar way by modifying the 'Preferences'-file.

When using SeleniumLibrary the same could be achieved by passing an instance of ChromeOptions to the 'Create Webdriver'-kw as options.

Image

Didn't find a way to do that with the Browser Library without a workaround. I'm guessing the 'firefoxUserPrefs'-parameter that can be passed to the 'New Browser'-kw, can be used to change those settings but for the Firefox browser.

@aaltat
Copy link
Member

aaltat commented Jan 26, 2025

And what was the problem? In @hutbazku case it looks like custom download directory was set for some reason, but I could be also wrong.

@keef78
Copy link

keef78 commented Jan 26, 2025

i was struggling with file downloads as well a bit ( in my case due to remote browser where I am running tests), but I always found a solution in playwright or browser lib documentation or I was pointed on the option how to do it on slack. Seems like you guys are looking for a way to 1) automatically download a file/pdf file in browser lib? - i do it with: Browser.New Context acceptDownloads=True 2) download pdf which gets opened in a new tab instead of being offered to be downloaded ? in one case, where I got no option to use Download saveAs=path , I used download from url from the new tab of a browser where file/pdf got opened , also documented in Browser Lib (but I got helped here by Tatu, I missed that option.)

    ${pdfurl}    Browser.Get Url
    Download   url=${pdfurl}   saveAs=${file_path}

sorry if I didnt get the point, just thought it may help.

@hutbazku
Copy link

The problem is that I didn't find a way to change the chromium browser preference setting 'plugins.always_open_pdf_externally'. In SeleniumLibrary you could pass the value with ChromeOptions. The setting changes whether PDFs open in a new tab in the browsers integrated pdf viewer, or the PDFs are just downloaded.

If I'm not wrong it seems that browser or playwright changes this setting when ran in headless mode. Is there a way to change the 'plugins.always_open_pdf_externally' setting without running in headless mode?

Thanks @keef78 that snippet may be a better workaround than the one I came up with.

@12jakubpavel
Copy link
Author

@aaltat I have exactly the same problem that @hutbazku has. I don't have a way to easily change the 'plugins.always_open_pdf_externally'.. Only the complicated way I sent.

@aaltat
Copy link
Member

aaltat commented Jan 28, 2025

Well, does the solution in #3972 (comment) work for you?

@keef78
Copy link

keef78 commented Jan 28, 2025

If I understood this correctly, this is the playwrights option: https://playwright.dev/docs/chrome-extensions
But I think you can also combine chrome user profile with custom settings (like always_open_pdf_externally) and just call this user profile if needed for certain test. By this it looks like playwright it self does not have a direct solution microsoft/playwright#7822

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closeable? This issue should be closed?
Projects
None yet
Development

No branches or pull requests

4 participants