Browser Automation using Bash On Ubuntu On Windows - selenium-chromedriver

We have a strong regression automation suite developed with Watir for Web Apps and Calabash for IOS and Android and so far our executions are happening on Mac OS.
We want to use RVM on Windows 10 so enabled bash feature on Windows 10 and installed RVM using Bash On Ubuntu On Windows. Using this installed RVM I would like to trigger the browsers installed on my Windows. I would like to know whether I am trying something that is possible ?
Just to check, I tried to trigger chrome browser in irb.
I placed my chrome driver below.
I have set my path and find the same below
On triggering chrome browser in irb I am getting the below error even though the path is set correct.
Selenium::WebDriver::Error::WebDriverError: Unable to find chromedriver.
I would like to know whether trying to trigger the browser installed on my windows environment through the Bash On Ubuntu On Windows terminal is practically possible attempt or not ? If so, please let me know where the disconnect had happened in my setup.
Below are the versions I am installed with .
rvm 1.29.3 (latest)
ruby-2.2.7
watir (6.8.4)

The error you are getting generally indicates that you have installed the chromedriver.exe file into a directory that is not on your path. Either move the file to a directory that is in the default path, or modify the path to add the directory with chromedriver.exe to the path.
Generally it's best to do that with the default path set by Windows on boot-up lest you have to have some batchfile that is run to alter the path before running IRB or a script that runs your tests.

Use the webdrivers gem. It ensures you always have the latest chromedriver.exe in your ~/.webdrivers directory, by downloading the newest version as necessary. It directs the Ruby code to use that driver regardless of what other chromedriver is on your system and whether it is or isn't on PATH.

Related

How can I download Appropriate Chromedriver in Protractor using Webdriver-Manager

I have designed a cucumber-protractor based automation framework where everything is working fine except for the Webdriver-manager. I need to update the binaries manually each time the IT Department updates google chrome version.
When i use command "webdriver-manager update --proxy=http://someproxy.com:PORT#", webdriver-manager always downloads the latest chromdriver binaries instead of a compatible version as per the current Chrome Version.
Please help me if there is a way to determine the chrome version automatically and download the corresponding Chrome binaries.
I have tried to search for similar behavior and forums elsewhere but none of the commands work. Instead it always downloads the latest version of chromedriver binaries instead of a compatible one.
Please help with some sample code in-case you come through a solution to this.
You could run a sh prior to starting your tests that will determine wether the chromedriver needs to be updated:
#!/bin/bash
# get existing chromedriver version
EXISTING_CD_VERSION=$(node_modules/.bin/chromedriver -version | egrep -o '(\d+)\.(\d+)\.(\d+)')
# get installed Google Chrome version
CHROME_VERSION=$(/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version | egrep -o '(\d+)\.(\d+)\.(\d+)')
if [ "$EXISTING_CD_VERSION" = "$CHROME_VERSION" ]; then
echo "ChromeDriver version matches the Google Chrome version"
else
NEW_CD_VERSION=$(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION)
node_modules/.bin/webdriver-manager update --versions.chrome $NEW_CD_VERSION
fi
NOTE: The script above is getting the Google Chrome version from a MacOS system. If you're on Linux, you need to change that to google-chrome --version
https://github.com/angular/webdriver-manager/blob/legacy/docs/versions.md
webdriver-manager start --versions.chrome 87.0.4280.88
you can use --versions.chrome to specify the driver version
what you actually need to do is to match a version of your local chrome to the version of chromedriver. So
First, find out what your version of chrome is. From example it is 86.0.4240.111
Then, find out what chromedriver version can be used. Take the major version of the browser (first 3 numbers, 86.0.4240 in our case) and find the corresponding version of the driver by going to this url https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION} (put the major browser version instead of ${CHROME_VERSION}). You'll see the chromedriver you're looking for is 86.0.4240.22
then just update webdriver specifying the desired version of chromedriver
webdriver-manager update --gecko=false --versions.chrome $VERSION
Make sure to put 86.0.4240.22 instead of $VERSION
But it maybe tricky here because there are 2 installation of protractor usually:
local
global
and each has it's own webdriver-manager. So make sure you're updating the right one
Thus you may need to go to it's folder and from that folder run npm i webdriver-manager#latest and then node ./bin/webdriver-manager update --gecko=false
when you updated the right webdriver, install the right chromedriver like so
node ./bin/webdriver-manager update --gecko=false --versions.chrome $VERSION

Find latest available Chrome version (on Linux, eg from a shell script)

How can I find the latest version of Google Chrome from a shell script (e.g. bash) on Linux ?
For ChromeDriver, I can do this:
curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE
Can I do something similar for Chrome?
Background to question
T
his needs to be done in a pipeline and there is no local install of Chrome, no tools to inspect packages (rpm, deb, and the like). The reason I want this is so that I can download the latest version as a numbered package. I could do this
wget -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
but that results in a file called google-chrome-stable_current_amd64.deb rather than one that is version stamped such as google-chrome-stable_73.0.3683.103-1_amd64.deb.
If I know the version in advance, I can get a version-stamped file using this:
GOOGLE_CHROME_VERSION=73.0.3683.103-1
wget http://dl.google.com/linux/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${GOOGLE_CHROME_VERSION}_amd64.deb
So what I'm really looking for is either generic URL that always returns the latest version-stamped file or a way to set GOOGLE_CHROME_VERSION in the above.
If you are using Ubuntu Desktop like mine 16.04, here is the command
google-chrome --version
ref. https://askubuntu.com/a/505532/22308

Octave gets stuck on Busy... inside TeXmacs in Windows OS

I have TeXmacs and Octave installed, both working properly otherwise. I have also added the path to octave executable (i.e. C:\Octave\Octave-5.1.0.0\mingw64\bin) to the Windows environment variables and octave runs in cmd/PowerShell terminals and Jupyter with no hassle. However, when running Octave inside TeXmacs through Toolbar > insert > session > octave it gets stuck on Busy..., the same reaction for any other commands as well:
Octave gets stuk on Busy... inside TeXmacs.
This is my environment:
TeXmacs 1.99.9
Octave 5.1.0 (installed through Chocolatey)
Windows 10 version 1809
I would appreciate if you could help me know what is the problem and how I can solve it.
P.S. I have reported this issue in the TeXmacs repo.
#Foad. I wrote an updated Octave plugin for Texmacs. I tried it on Windows, OSX and Linux, works on the systems I have access to. If you are interested to test it, you can download the zipped archive from here https://lists.gnu.org/archive/html/texmacs-dev/2019-12/msg00005.html.
To install it, unzip the archive and copy the octaveX directory in the application plugins folder, alongside all the plugins that come with the standard Texmacs installation. Won’t work if installed in ~/.Texmacs/plugins. If everything goes fine, you should find a new Insert/Session/OctaveX menu (note: I changed the session name). If not, try to refresh the plugin system with the menu Tools/Update/Plugins. If you try it, please let me know, especially if you find troubles. In case I will do my best to fix them.
A fundamental prerequisite is a working octave-cli command in a operating system shell. Should be standard on Linux, may require some additional setup on Windows (environmental variables) or OSX (.bash_profile). You can find some help and more details under the menu Help/Plug-ins/OctaveX.
Concerning the error you found, as far I understand there are some issues with the standard distributed plugin: first, a .octaverc file is missing, so several variables are not initialized, in addition the Windows version calls a not existent file. Moreover the plotting functions are quite old and are not compatibile with Octave newer than version 2 (or maybe 3, anyway a quite old version).
You could try to run the command in
%TEXMACS_PATH%/plugins/octave/bin/tm_octave.bat
from the terminal to see what happens. There is a problem with this plugin and it does not work also on Mac but I do not know enough Octave to fix it. Somehow it does not manage to find the files which are in
%TEXMACS_PATH%/plugins/octave/octave
Please try to modify tm-start.m to look like
d=getenv("TEXMACS_PATH");
if (length(d) > 0)
addpath("tm:polynomial:plot")
tmrepl
endif
In windows, octave should be run using the scripts octave.bat (in the mingw64\bin directory of the octave install) or octave.vbs (in the install directory) for the GUI
You should not run octave.exe directly.

How can I downgrade to Chrome 42.0.2311.90?

Google Chrome on my machine recently got updated to v44.
I'm working with Selenium WebDriver on Chrome and as soon as I updated Chrome, all my tests went dead. I use Chromedriver v2.16. My partner's PC has Chrome v42.0.2311.90 and Chromedriver v2.16. And tests run fine on his machine. Now, based on this I'm pretty sure the problem is probably not with Chromedriver.
So, how can I downgrade to Chrome 42.0.2311.90?
I've tried using an offline installer from here:
Google Chrome Alternate Offline Installer
But this always gives me the latest version to install i.e. v44.
The release that I need can be found here:
Google Chrome v42.0.2311.90 Stable Channel Update
Uninstall your current chrome version.
Remove all Chrome data for current version from: C:\Users\username\AppData\Local\Google\Chrome
Download your particular version from chrome_installer.
Disable chrome updates using instructions given on this link.
Following steps help you to install your desired google chrome version :
1 - Uninstall your current google chrome version.
2 - Download your desired google chrome version from here : Google Chrome Download
3 - Restart PC once so if any registry or temp file stored of previous google chrome then it will get refresh.
4 - Install your downloaded google chrome. And then turn off automatic chrome update.
I struggled with this same problem on Mac, trying to downgrade, and stay downgraded from Chrome 53 to 52 due to a serious bug affecting webaudio.
None of the other recommendation appear to apply any more (or on Mac OS X at least). The app attempts to upgrade itself and there doesn't be a way to configure that in a "Chrome-friendly" way.
Eventually I resorted to force...
Close and uninstall Chrome
Edit your /etc/hosts file to prevent update checks from working by overriding the DNS entry:
0.0.0.0 tools.google.com
Find and download an old release. This is left as an exercise, this was actually hard and fraught with fear of bad binaries. I was able to cross-reference MD5s from one site that didn't have downloads with another that had downloads.
Install and run the older version
Important: Check the "About" page, and point and laugh at Chrome's attempts to check in.
This is how you can use an older chrome version "in general":
Uninstall your current chrome
Install the chrome version you desire
DO NOT open chrome!! after installation
Instead disable auto-updates like here or here
Only then may you work with your desired chrome browser version
As for how to get a specific older version:
You need to google, search forums or try sites like this. It's just "grunt work" to find the version you are looking for. If you're extremely unlucky, the very version you need might even not be around any more.
If you are running on a windows machine you can leverage the package manager chocolatey, this is how we I'm doing it from Jenkins, we call a powershell that uninstalls a previous version and install a specific one: From a powershell ide script window, you need to have installed the modules for chocolatey that is a small price to pay for a lot of benefit:
choco install googlechrome --version 62.0.3202.94 -y
Then to prevent Chrome to self update I am performing this steps:
1. Verify Chrome's current version.
(Get-Item (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe').'(Default)').VersionInfo
Install the version I'm aiming for:
choco install googlechrome --version 62.0.3202.94 -y
You can look for available versions here:
https://chocolatey.org/packages/GoogleChrome
(Find Version History Section)
Kill GoogleCrashHandler.exe in any of its variants 32 or 64 bits or both.
Delete the Directories
C:\Program Files (x86)\Google\Update and
C:\Program Files (x86)\Google\CrashReporter
You will loose the ability to auto update (which is the whole purpose right) and
you will loose the ability to send crash reports and piggy back on that executable to update against your will whenever google deems convenient.
5.Disable Chrome Services

How to build a PyObjC project on Mac OS X 10.6, that runs 10.5?

I have a PyObjC project that I build on Mac OS X 10.6 with XCode 3.2 and I'm not able to run on 10.5.
All I'm using is the official PyObjC project templates to create an empty project (that simply opens a window). Then I build the app and copy it over to 10.5. But the app always crashes on 10.5:
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '/Users/hupf/Development/PyHelloWorld/main.m:44 main() PyRun_SimpleFile failed
with file '/Users/hupf/Desktop/PyHelloWorld.app/Contents/Resources/main.py'. See
console for errors.'
What can I do to make it run on 10.5 too? Why is there still this path /Users/hupf/Development/ I only have on my 10.6 machine?
Greetings,
hupf
P.S. I've also installed Python through MacPorts on my 10.6 machine... might this be a problem?
I don't know anything about PyObjC but your project is using Xcode then you just need to set your project's deployment target to the oldest OS version you want your app to run on. (FYI: The SDK version defines the newest version of the OS you app will run on.) Note also that any API's added after the deployment target version will be weak-linked meaning that if you're running on the older OS where those API's don't exist they will be nil; if you call them you will crash. (so you should always check them for != nil before calling them).
Again, this isn't necessarily an PyObjC answer; YMMV…