daijro / camoufox

🦊 Anti-detect browser
https://camoufox.com
Mozilla Public License 2.0
150 stars 14 forks source link

Regression on input[type=file] #52

Open mathisspark912 opened 4 days ago

mathisspark912 commented 4 days ago

Describe the bug:

This existing code was working using Playwright or undetected_browser :

    upload_button = page.query_selector('input[type="file"]')
    upload_button.set_input_files(pdf_path)

Using Camoufox() raises now an exception, like if Camoufox() was changing the default behavior of Playwright and especially the way input[type=file] are managed.

The exception is ::

ElementHandle.set_input_files: Protocol error (Page.describeNode): error in channel "content::10/16/4": exception while running method "describeNode" in namespace "page": frame.domWindow() is undefined _describeNode@chrome://juggler/content/content/PageAgent.js:418:30 _onMessageInternal@chrome://juggler/content/SimpleChannel.js:237:37 _onMessage@chrome://juggler/content/SimpleChannel.js:194:12 bindToActor/actor.receiveMessage@chrome://juggler/content/SimpleChannel.js:39:44

Version:

Pip package: v0.3.2 Camoufox: v130.0.1-beta.13 (Up to date!)

daijro commented 4 days ago

Thanks for reporting. The root issue is related to #48 :+1::

In Camoufox, all of Playwright's JavaScript runs in an isolated context. This prevents Playwright from running JavaScript that writes to the main world/context of the page.

While this is helpful with preventing detection of the Playwright page agent, it causes some issues with native Playwright functions like setting file inputs, executing JavaScript, adding page init scripts, etc. These features might need to be implemented separately.

mathisspark912 commented 4 days ago

Ok but what do you mean by implemented separately ?

That you need to implement them in future version of your lib ?

Or during my test case i need to instanciate a regular Playwright object to do what Camoufox does not manage to do ?

daijro commented 4 days ago

Ok but what do you mean by implemented separately ?

That you need to implement them in future version of your lib ?

Or during my test case i need to instanciate a regular Playwright object to do what Camoufox does not manage to do ?

I'll need to implement them in a future version of Camoufox to support it.

At the moment, it's not possible to set file inputs in the browser through Playwright or the Camoufox library.

mathisspark912 commented 2 days ago

Or if it is easier to implement, maybe a feature to temporarily disable isloation then reactivate it (i do not know if this make sense on a technical point of view, i did not studied your source code and i am not an expert on browser like implementation).

But for sure, for people not simply using your solution for web scraping but running automated scenarios, filling forms, uploading files or even executing javascript natively with playwright, we need a way to run JS, otherwise it will not be possible to use your solution in production in the future.

This is the only limitation i found on the moment, i tested your solution on specific websites where other open source or even commercial anti-detect browsers failed and your solution gives better results.