[🐛 Bug]: PySelenium doesn't support a named pipe as a log file
What happened?
As part of OpenWPM we use Selenium to drive multiple Firefox browsers in parallel.
To capture, enrich and redirect the browser's logging output, we use named pipes that look like normal log files to Selenium.
However pipes don't support seeking so the need to be opened with w and not with a+ as the firefox.Service currently does. We have previously monkeypatched this but that approach has led to us breaking every time a new Selenium release comes out. A newer approach that tries to call firefox.Service.__init__ and open the log_file afterwards doesn't work at all, so I wanted to check if there was an appetite to address this issue upstream.
How can we reproduce the issue?
import os
from selenium.webdriver import Firefox
from selenium.webdriver.firefox.service import Service
pipe_name = "selenium_pipe.log"
os.mkfifo(pipe_name, 0o600)
service=Service(executable_path="firefox",log_path=pipe_name)
driver = Firefox(
service=service
)
driver.get("https://example.com")
Relevant log output
File "/home/vringar/selenium_mvp/demo.py", line 9, in <module>
service=Service(executable_path="firefox",log_path=pipe_name)
File "/home/stefan/.conda/envs/openwpm/lib/python3.10/site-packages/selenium/webdriver/firefox/service.py", line 50, in __init__
log_file = open(log_path, "a+") if log_path else None
io.UnsupportedOperation: File or stream is not seekable.
Operating System
Linux
Selenium version
Python 4.1.0
What are the browser(s) and version(s) where you see this issue?
Firefox 100
What are the browser driver(s) and version(s) where you see this issue?
GeckoDriver 0.30.0
Are you using Selenium Grid?
No response
@vringar, thank you for creating this issue. We will troubleshoot it as soon as we can.
Info for maintainers
Triage this issue by using labels.
If information is missing, add a helpful comment and then I-issue-template label.
If the issue is a question, add the I-question label.
If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable G-* label, and it will provide the correct link and auto-close the
issue.
After troubleshooting the issue, please add the R-awaiting answer label.
Thank you!
Looks like you already have the code; please PR your proposed changes and discuss whatever impact it might have on existing users. We have a *lot of work planned in Python for 4.3.
Also, conceptually, is this a bug, or effectively a feature request to support another type of output?
Also, conceptually, is this a bug, or effectively a feature request to support another type of output?
Hmm, I was unsure about that as well. I just picked the bug report because it allowed me to show that the desired behavior is currently not supported.
Looks like you already have the code; please PR your proposed changes
Done
and discuss whatever impact it might have on existing users. We have a *lot of work planned in Python for 4.3.
I have done that in the PR. Should I do it here as well?
Thanks @vringar seems ok to me, we could expose the mode to the user too to simplify the solution but your proposal seems ok to me too
This issue is stale because it has been open 280 days with no activity. Remove stale label or comment or this will be closed in 14 days.
This issue was closed because it has been stalled for 14 days with no activity.
I think I have a solution for this one that I'm working on.
This PR ^^ will let you create the file ahead of time and pass it in rather than having to mess with tuples. sorry it took us so long for me to dig into this code.
Looks great! Is there any way I can contribute to #12103 or #12030? Or should I just wait?
I'm hoping to merge #12030 today Whether #12103 is in 4.10 or 4.11 depends on when we release 4.10 (end of the week?) and when I can get someone else to review it. 😁
I just added docs for all the languages to show which languages support what logging options — https://www.selenium.dev/documentation/webdriver/drivers/service/#console-output
So we can prioritize fixing things
Implemented via #12103
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.