Running Selenium/PhantomJS inside a Vagrant box - selenium

I'm trying to set up testing for a Web app using behaving, which runs on top of behave and splinter - the latter of which in turn uses Selenium to drive PhantomJS. All of this is inside a VirtualBox-provided Vagrant box running CentOS 6.4. I've installed Selenium via pip, and I've installed PhantomJS from the Nux Dextop repo.
Trying to run my tests freezes Behave for 30 seconds, then raises:
selenium.common.exceptions.WebDriverException: Message: 'Can not connect to GhostDriver'
I think I've nailed it down to not being able to open a socket, and indeed, when I try to do this from the Python interactive shell, I can't open any socket to localhost at all. How do I get my tests to run?

I just had the same problem with the Can not connect to GhostDriver error. When trying phantomjs --help, I got the error
[WARNING] Unable to load library icui18n "Cannot load library icui18n: (libicui18n.so.48: cannot open shared object file: No such file or directory)"
After installing libicu48 (Ubuntu package), phantomjs --help gave me
[WARNING] phantomjs: cannot connect to X server
This made sense, since I didn't have an X server installed. Then, I discovered that phantomjs <= 1.4 requires an X server, but >= 1.5 is pure headless. So, instead of relying on my distro's phantomjs package, I installed it using npm, and now everything works fine.

I have installed the package of libicu48 and gnome-session-fallback for the bug.
$ sudo apt-get install libicu48 gnome-session-fallback

Related

Failed to open connection to "session" message bus: /usr/bin/dbus-launch terminated abnormally without any error message [duplicate]

I am using a very complex setup to test various non-public webpages. I use jenkins to run the python-selenium tests within a dockerimage. That way, I am completely independent of the jenkins environment and can create my own environment. In this environment I have the following software installed:
Ubuntu 16.04.3
Firefox: Mozilla Firefox 57.0.1
geckodriver: 0.18.0
nosetests: 1.3.7
selenium: 3.8.0
When running the tests, which mostly succeed, I see in the geckodriver.log output messages like
(firefox:55): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message
My questions:
What does this message mean?
Could that be an indication of the reason why sometimes the tests are failing?
If so, how to fix it?
The error you are seeing is :
(firefox:55): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message
So it is clear Firefox attempts to connect to D-BUS daemon and fails as dbus-launch gets terminated abnormally.
dbus-launch
dbus-launch is basically the utility to start a message bus by firefox through a shell script. It would normally be called from a user's login scripts. dbus-launch launches a session bus instance and print the address and pid of that instance to standard output.
You can read more about dbus-launch from the Linux man page
Root Cause
This error can arise if you use su (root), sudo, suedit, gksu. The main reason is DBUS_SESSION_BUS_ADDRESS retains its value when you su instead of picking up the value in /root/.dbus/session-bus.
Here you will find a detailed discussion on GConf Error: No D-BUS daemon running?! How to reinstall or fix?.
Another possible reason may be the base Firefox Browser version may be an older version on which updates were taken to reach the current version.
Solution :
There are a couple of solutions available to address this ubuntu related issue as follows :
Before you start Firefox you have to type export $(dbus-launch)
However this may result into another error with NSS_USE_SHARED_DB. So you have to use export NSS_USE_SHARED_DB=ENABLED as well.
The most convenient way would be to put all the configuration with in .bashrc file :
export $(dbus-launch)
export NSS_USE_SHARED_DB=ENABLED
firefox &
This discussion speaks about the solution in details.
If dbus-launch is not installed on your system you have to install dbus-x11 package which contains the dbus-launch program.
An effective solution would be to uninstall the older base version of Firefox Browser and install a recent released GA version of Firefox Browser.
Best Approach
The issue with dbus-launch was addressed properly by both Ubuntu and Mozila. To overcome this error you need to follow the below mentioned steps :
Keep your Ubuntu os updated with the Latest Patch Releases and updates.
Always use the latest released version of Selenium-Python client, WebDriver variant e.g. GeckoDriver and Web Browser, e.g. Firefox Browser.
Clean and Build the Project Workspace afresh through your IDE before and after executing your Test Suite.
Clear the Browser Cache before and after the execution of your Tests.
If you have to uninstall any of the Web Client variants (e.g. Mozilla Firefox) you can use Revo Uninstallar with Moderate Memory Scan so that the stale registry settings are discarded.
Use CCleaner tool regularly to wipe away the OS chores including the stale rust_mozprofile directories.
What does this message mean?
DBus is a message bus system for interprocess commutation. There is an open geckodriver issue on a similar if not the same subject:
request to geckodriver fails with no meaningful log entry when there is no access to $HOME/.mozilla or $HOME/.cache
Could that be an indication of the reason why sometimes the tests are failing?
The warning should not really affect the tests but it's difficult to speculate about your intermittent test failures without seeing what is actually happening in your tests.
If so, how to fix it?
Here are some things to try:
upgrade geckodriver to the latest stable version (currently 0.19.1)
update Firefox to the latest nightly version (currently 58)
try this answer
try this answer
For me the solution was to install dbus-x11
apt install dbus-x11

GNOME Shell integration extension is running, native host connector is not detected?

I have followed these steps while installing the gnome extension of chromium in Ubuntu 20.04.
Installed the GNOME Shell integration extension on chromium.
As per their documentation ran a command to install chrome-gnome-shell
sudo apt-get install chrome-gnome-shell
Still while loading the gnome-extensions page, it is showing error that "Although GNOME Shell integration extension is running, native host connector is not detected. Refer documentation for instructions about installing connector."
Can anyone tell me how to resolve this issue in steps?
FYI: starting from Ubuntu 21.10 Firefox comes as a default browser and as a snap, as well as Chromium. And has the same problem: GNOME Shell integration shows the same error.
Other ways to install the extensions are:
gnome-extensions install --force your_downloaded_extension.zip
unzip your_downloaded_extension.zip ~/.local/share/gnome-shell/extensions/
Probably this is because you are running Chromium as a Snap. There is an open bug in Launchpad about this, that appears to still be happening in Ubuntu 20.04 (still happening in Ubuntu 22.04):
https://bugs.launchpad.net/ubuntu/+source/chromium-browser/+bug/1741074
The easiest solution would probably be to use another web browser, not in a Snap.
I experienced this issue when upgrading from Ubuntu 21.04 to Ubuntu 22.04 (Jammy Jellyfish), where Firefox was installed via snap - supposedly the sandboxing made it unable to detect.
My resolution (which brought back gnome extensions connector being seen) was to install firefox manually by debian package via the directions in https://balintreczey.hu/blog/firefox-on-ubuntu-22-04-from-deb-not-from-snap/ . You may also be able to install the direct tarball following directions in https://fostips.com/install-latest-firefox-non-esr-debian/
Another option is to use a native extension manager as suggested in https://haydenjames.io/ubuntu-22-04-install-gnome-extensions-manager-workaround/
I solved using Chrome and not more Firefox for extensions.gnome.
(I use Chrome just for manage this extension)
If you still got problems, you could simply do this:
sudo apt-get reinstall chrome-gnome-shell
For me it did work after all, but just by using another browser - Firefox
I'm using Ubuntu 20.10 and I also had this issue. I was using Chromium but I found that Chromium dropped support for this, therefore I installed Firefox from the software. This did not work either.
The fix was to uninstall Firefox from software and install Firefox from ubuntu software with the source: ubuntu-groovy-updates-main
I installed the browser extension on there and it worked perfectly.
Aevin J He gave the answer if you're on ubuntu 21.10. it really matters whom you install it from. don't use the default one, use the one with most reviews

install weblogic on VM with Solaris OS

I stuck in install weblogic on my vm solaris. i try that
java -d64 -jar fmw_12.2.1.3.0_wls.jar
and i got an error
Checking monitor: must be configured to display at least 256 colors. DISPLAY environment variable not set. Failed <<<<
Any solution for these error?
This happens if you want to do an graphical install of the system without having a X11 running. The error message is quite normal for such an situation.
You could:
Not running the installer in the graphical mode by doing a silent install (please refer to https://docs.oracle.com/cd/E24329_01/doc.1211/e24492/silent.htm#WLSIG131 for information)
Install the nescessary package to have an X11 and stuff running in your VM with pkg install solaris-desktop. Then execute the java command again from the GUI . This obviously only works if you can get a the graphical output of the VM for example via VNC or other tools.
You could set the DISPLAY variable to an installed X11 implementation. For example i use Xquartz on my Apple notebook. Then configure DISPLAY and XAUTHORITY correctly. Or you could simply log into the Solaris system with ssh -X . I prefer the second one, as it does everything automatically.

Does Chromium headless work on Windows Server Core 2016?

Background
I am tasked with replacing our IE based printing logic with Chromium so that we can eventually support running our current server software on Windows Server Core or potentially other operating systems that support .Net Core. My current thought is to either use Chromium embedded framework or to make use of Puppeteer. I am leaning towards the later because I feel it would be easier to port between operating systems.
Issue
Originally it failed to start with an error about sandboxing so I added the no-sandbox flag. Now when I try to load Chromium it fails to start with the exception below stating that it cannot load chrome.dll
PS C:\Program Files (x86)\Google\Chrome\Application>> .\chrome --headless --enable-logging --disable-gpu --screenshot="C:\screen.png" "https://www.chromestatus.com/"
Which yields the following error in the debug.log file:
[0813/133208.016:ERROR:main_dll_loader_win.cc(134)] Failed to load Chrome DLL from c:\Program Files (x86)\Google\Chrome\Application\68.0.3440.106\chrome.dll: The specified module could not be found. (0x7E)
I have checked around the internet and found a few mentions of this error but the suggested fixes don't seem to fix the issue.
I was able to download Chromium 72.0.3592.0 via Chocolatey and the issue is resolved in that version. I tested using Server Core 2016 LTSB.
choco install chromium --pre -y
chrome --headless --disable-gpu --dump-dom --enable-logging https://www.chromestatus.com/ --no-first-run
Edit:
If you are attempting to run Selenium Tests using Docker windowsservercore and chromium: The command line tests of chromium chrome.exe appear to never work from the container command line.
However when you run dotnet test app.csproj or dotnet vstest app.dll inside the container the webdriver successfully starts and drives the browser
This has been reported to the Chromium team. It appears that Chromium 68+ might have issues with Windows Server 2016.
https://bugs.chromium.org/p/chromium/issues/detail?id=873097

DalekJS: tests are not running, at all

Here's my set up on Ubuntu
dalek and dalek-cli installed as instructed in the website, the version is displayed correctly
phantomjs was installed via npm install but the phantomjs command could not be run
installed phantomjs via apt-get ... now I have version 1.4
in the folder /var/www/first_tests/ I have the package.json file provided in the website along with a subfolder tests containing first.js with the google example provided
I am in my homedirectory since that's the only place I can call dalek (I'm guessing because that where I was when I installed it) so I'm doing
dalekjs /var/www/first_tests/tests/*.js
The console shows "Running tests" but nothing happens. Trying to run
phantomjs /var/www/first_tests/tests/first.js
gives me "undefined:0 ReferenceError: Can't find variable: module"
Dalek expects the PhantomJS binary in the:
node_modules/dalekjs/node_modules/dalek-browser-phantomjs/node_modules/phantomjs/bin
Folder. Also, it definitely needs version 1.9.0 or higher.
You could try to download the binary from the PhantomJS homepage & manually copy it to the folder mentioned above.
It would be awesome, if you could send me (dalekjs#asciidisco.com) the npm debug log,
so that I can check why this happened in the first place.