-
Notifications
You must be signed in to change notification settings - Fork 11
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
How can i use Selenium Webdriver inside flatpak Eclipse? #30
Comments
Just to clarify the issue happens with Firefox/Chromium installed via flatpak ? Have you tried whether it works with system installed firefox via apt-get ? Eclipse has a special process shim to enable running applications available on the host PATH. |
Yes, i have Firefox flatpak version installed, also i have firefox Debian local installation, when i run my code using Flatpak Eclipse version it does not run at all (because the flatpak Eclipse version cannot execute the firefox binnaries), but when i run my code with loocal debian Eclipse installation it works perfectly fine (because my local installation of Eclipse can execute the firefox binnaries to run the selenium automation test).. this is the minimal code example that i am tryng to run: System.setProperty("webdriver.gecko.driver", "/home/cesar/workspace/CucumberFramework/src/test/java/Resources/geckodriver"); There is no integration betwen flatpak Eclipse and flatpak Firefox. |
So there's still no fix? |
But it's the geckodriver that is trying to invoke firefox, and not Eclipse, right? And the geckodriver is not sandbox-aware. You can probably trick it into launching the firefox process on the host system, outside of the sandbox, like this: First create a script called "ff-host" with the following content:
And make it executable:
Then tell the geckodriver to use this script as the firefox binary:
This trivial test seems to work for me, but full disclaimer: I have never used Selenium, or webdrivers, before! IMHO geckodriver should be enhanced to be sandbox-aware, since Eclipse cannot control what it is doing. Consider filing a ticket against geckodriver. |
@mbooth101 Not working for me. I just switched to the Oomph installer, fixed my issue. |
Which part? |
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:561)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:230)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:151)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:198)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:164)
at MercuryTours.main(MercuryTours.java:14)
Caused by: org.openqa.selenium.WebDriverException: Driver server process died prematurely.
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: 'fedora', ip: '192.168.0.103', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.13-200.fc35.x86_64', java.version: '16.0.2'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:226)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:98)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
... 6 more
|
@Ashvith Can you provide a sample project to illustrate? |
@mbooth101 I've made another sample program that has the same issue Code import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Sample {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "/home/ashvith/eclipse-workspace/Selenium/external_module/geckodriver");
System.setProperty("webdriver.firefox.bin", "/home/ashvith/eclipse-workspace/Selenium/external_module/ffhost");
WebDriver driver = new FirefoxDriver();
driver.get("https://selenium.dev");
driver.quit();
}
} Log Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:561)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:230)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:151)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:198)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:164)
at Sample.main(Sample.java:8)
Caused by: org.openqa.selenium.WebDriverException: Driver server process died prematurely.
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: 'fedora', ip: '192.168.0.103', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.13-200.fc35.x86_64', java.version: '16.0.2'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:226)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:98)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
... 6 more |
I don't know about Eclipse, but I was having trouble even getting chromedriver to talk to a Flatpak release of Ungoogled Chromium when only the browser was sandboxed, so I decided that, since you connect to it over a TCP socket anyway, why not just run it inside the sandbox? # Put your chromedriver binary somewhere it won't collide
mv $HOME/bin/chromedriver $HOME/bin/chromedriver.real
# Expose your chromedriver binary to the sandbox:
flatpak override --user com.github.Eloston.UngoogledChromium --filesystem=$HOME/bin/chromedriver.real:ro
# Write a wrapper script in your `PATH` to launch it INSIDE the sandbox
cat <<EOF > $HOME/bin/chromedriver
#!/bin/sh
exec flatpak run --command=$HOME/bin/chromedriver.real com.github.Eloston.UngoogledChromium "\$@"
EOF
chmod +x $HOME/bin/chromedriver Tested working with a simple chromedriver &
SELENIUM_BROWSER=chrome SELENIUM_REMOTE_URL="http://localhost:9515/" npm test I also got the same success with geckodriver, though they warn you that they pass custom profiles via temporary directory, so you'll need to follow their instructions to produce something like this instead:
Make sure you Before I got that working, I also found two other options: First, you could take advantage of Mozilla's convenient self-contained tarballs to install a special copy of Firefox just for webdriver: mkdir -p ~/opt
cd ~/opt
wget 'https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=en-US' -Ofirefox.tar.bz2
tar xvaf firefox.tar.bz2
cat <<EOF >| $HOME/bin/geckodriver
#!/bin/sh
exec ~/.cargo/bin/geckodriver --binary $HOME/opt/firefox/firefox "\$@"
EOF
chmod +x $HOME/bin/geckodriver Second, though I couldn't get them to work for unrelated reasons, SeleniumHQ does offer Docker containers for Firefox, Chrome, and Edge with the relevant drivers set up to auto-start. In theory, any of those should work with a Flatpak'd IDE as long as both Flatpaks have network access, read-write access to the |
Hi guys im trying to run chromedriver and geckodriver for firefox inside an Eclipse project, but flatpak Eclipse app cant open Firefox or Chromium because Eclipse does not have access to the binaries of the system, i have tried to give access to the binaries using flatseal but nothing works:
PATH=/app/bin:/app/openjdk-11/bin:/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin:
This is the Eclipse error log:
Scenario: Login in to account with correct details # src/test/java/FeatureFiles/Login.feature:47
org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: LINUX
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'debian', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.19.0-11-amd64', java.version: '11.0.8'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:100)
at java.base/java.util.Optional.orElseGet(Optional.java:369)
at org.openqa.selenium.firefox.FirefoxOptions.getBinary(FirefoxOptions.java:216)
at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:187)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:147)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:125)
at StepFiles.Login.setup(Login.java:29)
When i try to execute my code with a local Eclipse installation everything works fine.
Is there a way to give flatpak Eclipse access to the flatpak Firefox or chormium binaries?
The text was updated successfully, but these errors were encountered: