Recently got a mac and was able to run Mozilla without any issues but having trouble installing chrome extensions and running it for selenium. Can someone guide me through the process of installing the extension and running selenium on Mac chrome.
If you want to use Selenium WebDriver with Chrome, first download ChromeDriver - WebDriver for Chrome. This can be installed via Homebrew with brew install chromedriver, or manually by downloading, extracting, moving and setting the PATH as follows:
$ cd $HOME/Downloads
$ wget http://chromedriver.storage.googleapis.com/2.22/chromedriver_mac32.zip
$ unzip chromedriver_mac32.zip
$ mkdir -p $HOME/bin
$ mv chromedriver $HOME/bin
$ echo "export PATH=$PATH:$HOME/bin" >> $HOME/.bash_profile
Source: install and set path to chromedriver on mac or linux
You should then read Getting started with ChromeDriver on Desktop, in particular the sample code which shows how you map the path to the executable and instantiate ChromeDriver. If you have a reference to the driver in the PATH variable, you can omit the configuration line.
You can install both packed (.crx file) and unpacked (directory) extensions via ChromeDriver. See the code snippets for setting either up here.
If you were using Selenium IDE for FireFox instead, there is no version available for Chrome. The best alternative I know of is iMacros for Chrome.
Sometimes you will face a problem with the old version of chromedriver and when you try to install it using this command:
brew cask install chromedriver
It shows you the following:
Error: It seems there is already a Binary at '/usr/local/bin/chromedriver'; not linking.
However, you can the following step:
brew cask reinstall chromedriver
If it still shows you the same error, you can remove it with the following command
rm /usr/local/bin/chromedriver
and install it again
brew cask install chromedriver
You should have the last updated version of chrome driver
I think that the easy way for running mac osx, chrome and selenium together is like this on mac os terminal:
# download selenium jar
curl -L0 https://selenium-release.storage.googleapis.com/3.9/selenium-server-standalone-3.9.1.jar -o selenium-server-standalone.jar
# install chromedriver using cask
brew cask install chromedriver
# start chrome driver
brew services start chromedriver
#==> Successfully started `chromedriver` (label:homebrew.mxcl.chromedriver)
# start selenium server
java -jar selenium-server-standalone.jar
#14:38:20.684 INFO - Selenium build info: version: '3.9.1', revision: '63f7b50'
#14:38:20.685 INFO - Launching a standalone Selenium Server on port 4444
I guess you have a couple of options.
either manually downloading chrome driver and adding it to your PATH,
or using webdriver_manager package
Manually downloading chromedriver
The first option is to manually download chromedriver and add it your PATH:
Step 1: Download chromedriver
# You can find more recent/old versions at http://chromedriver.storage.googleapis.com/
wget http://chromedriver.storage.googleapis.com/81.0.4044.69/chromedriver_mac64.zip
Step 2: Add chromedriver to your PATH (e.g. /usr/local/bin)
unzip chromedriver_mac64.zip
cp chromedriver /usr/local/bin
You should now be able to run
from selenium import webdriver
browser = webdriver.Chrome()
browser.get('http://localhost:8000')
without any issues
Using webdriver_manager
Alternatively, you can use webdriver_manager that contains most web drivers.
First install it with pip:
pip install webdriver_manager
And for Chrome in particular, you should do
from webdriver_manager.chrome import ChromeDriverManager
browser = webdriver.Chrome(ChromeDriverManager().install())
browser.get('http://localhost:8000')
One way is if you have homebrew on your mac, then on terminal, use this command
brew install chromedriver
Then you need to download chromedriver on your machine, do it from
http://chromedriver.storage.googleapis.com/index.html
Download latest version
It will look like, "chromedriver_mac32.zip"
(doesn't matter if its 32 bit, it will work for 64 bit MAC as well)
Use this code for open Chrome if your chromedriver that you downloaded is inside your project folder and looks like this
..Project folder/Chrome/chromedriver
System.setProperty("webdriver.chrome.driver",
System.getProperty("user.dir")+"/Chrome/chromedriver");
driver=new ChromeDriver();
Use chrome driver, download from here
https://sites.google.com/chromium.org/driver/
Add the file in pycharm project, then use this cmd to disable permission pop up
xattr -d com.apple.quarantine chromedriver
Also in python program, use these lines, make sure chrome is installed in Applications
import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
options = webdriver.ChromeOptions()
options.binary_location = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
driver = webdriver.Chrome('/Users/<Username>/PycharmProjects/selenium_py/chromedriver')
driver.get('https://www.google.com')
Install chromedriver directly with brew install chromedriver.
The chrome driver is located in /usr/local/bin/chromedriver.
If you reload your terminal with source ~/.bashrc or source ~/.zshrc, depending on your setup or restart the terminal if should work.
If it does not work add the chrome driver to your PATH. You need to add /usr/local/bin/chromedriverto your ~/.bashrc or ~/.zshrc by adding the line: export PATH=$HOME/bin:/usr/local/bin:$PATH.
The easiest way to do this after downloading the right chromedriver is with the oneliner:
sudo chmod a+x chromedriver && sudo mv chromedriver /usr/local/bin/chromedriver
Related
I just made the jump from Ubuntu to MacBook Air M1.
I am trying to set-up the system in a way that I don't have to change scripts for both. i.e. I want to keep the scripts in such a way that editing on either system is ok.
In a script I use the following line of code:
driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver")
I used Homebrew to install chromium-browser but I can't find the file (so I can move it to this location?).
I have tried almost everything I could look up and can't figure it out. What can I try next?
Install webdriver-manager, it allows you install and store chromedrive automatically
pip install webdriver-manager
and use like this:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
The fastest way to to solve is using Home Brew:
brew install --cask chromedriver
Chromedriver will be installed in the correct path.
You can find the downloads for various versions of the Chrome driver here: https://chromedriver.chromium.org/downloads
For example, for v99 on Mac M1 you could download this archive: https://chromedriver.storage.googleapis.com/99.0.4844.51/chromedriver_mac64_m1.zip
Once downloaded just unzip & copy to whatever location you choose. After I installed I still needed to mark the application as "safe" in macOS, I followed the instructions here: https://stackoverflow.com/a/60362134/1371489
I am trying to install Firefox 59.0.2 on my linux server(OEL). But everytime I try to install firefox with command (yum install firefox) it installs 52.x version.
Could you please help me with the command to install firefox 59.0.2 in Oracle Enterprise Linux - 7.1
If possible, use yum to install Firefox on Oracle Linux. Using yum you can specify the Firefox version to install. Depending on your OL version, you may or may not be able to install Firefox 59.0.2.
To find which versions are available through the yum repositories on your machine, run:
sudo yum --showduplicates list firefox
You can choose a specific version that is shown in the list. So, on my OL7 VMs I currently have Firefox 60.3.0, and can install it like this:
sudo yum install firefox-60.3.0
Note that you may need to uninstall the existing version of Firefox before installing a new one:
sudo yum remove firefox
Since you're mentioning Enterprise, that's probably the reason why it downloads the 52.x version: it's the latest ESR (Extended Support Release). To install the latest version, you can:
Download the Linux archive from the official page.
Untar it with tar -xjvf firefox-59.02.tar.bz2 (current release).
Run the firefox executable from the unpacked directory.
I'm not able to install Firefox 45.0.2 on my Debian system. I have downloaded the .tar file and followed the steps. While checking the version, I'm getting the below error. I'm not able to launch Firefox with
firefox -v
Error: bash: /usr/bin/firefox: cannot execute binary file: Exec format error
I was able to install and use other Firefox versions without any issues.
try this
sudo apt-get install firefox=45.0.2+build1-0ubuntu1
I'm trying to update my version of Firefox on my Centos 6 machine.
I've downloaded the tar.bzip2 file from Mozilla website. Unpacked it in the /opt folder. I backed up my old firefox version:
mv /usr/bin/firefox /usr/bin/firefox-old
and created a new link for the new version
ln -s /opt/firefox45/firefox /usr/bin/firefox
When I run the firefox command from the terminal and check the version its still on Version 31
When I run firefox -V it returns Mozilla Firefox 45.0.1
How is this happening and why won't the browser of 45.0.1 version open?
Thanks,
Running
# whereis firefox
on my CentOS 7 returns:
firefox: /usr/bin/firefox /usr/lib64/firefox /usr/share/man/man1/firefox.1.gz
The library for Firefox is in /usr/lib64/firefox, so to fix it, I ran:
# mv /usr/lib64/firefox /usr/lib64/firefox38
# cp -r /home/derek/Downloads/firefox /usr/lib64/firefox
running
$ firefox
and checking the version gives me v. 45,
$ firefox -v
returns
Mozilla Firefox 45.0.1
Hope this helps!
EDIT: Note that the reference given in
/home/derek/Downloads/firefox
is referencing the unpacked archive downloaded from the Mozilla website. The rest of the commands should be similar.
Is there a binary out there for the current mac os x, python for PyGTK? I work with multiple desktop environments (mac, windows, gnome) and really consider python's lack of cross platform GUI's a problem. Does anyone know where I can find a built version of PyGTK and GTK for Mac?
I cant clone the git repository, it keeps timing out.
brew install pygtk worked for me (requires homebrew).
Confirmed to work with OS X 10.10 too, but by default it will install it into brew's Python distribution, so if you are still using the native python, it will not find it.
I don't use macports but it seems that jhbuild works for me. Below is the steps that I've done.
download gtk-osx-build-setup.sh from: https://raw.github.com/jralls/gtk-osx-build/master/gtk-osx-build-setup.sh and save it to your home directory.
fire up terminal and navigate to your home directory and run the command sh gtk-osx-build-setup.sh
the shell script will warn you that ~/.local/bin isn't added to your environment variable to do this, edit your .profile file located at your home directory and /Users/<username>/.local/bin to your environment variable. to know more on how to edit this file check out: http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable/
after that, do a ~/.local/bin/jhbuild bootstrap command. it will download and install some necessary utilities.
download and install the beta version of the gtk+ osx framework at: http://ftp.imendio.com/pub/imendio/gtk-osx/Gtk-Framework-2.14-LATEST.dmg
before installing the meta-gtk-osx-python, you need to build and install some other packages that jhbuild doesn't install automatically, so what i did was i installed libpng by doing the command: ~/.local/bin/jhbuild build libpng
you also need to install libtiff so do the command: ~/.local/bin/jhbuild build libtiff
and also gtk-doc is needed so: ~/.local/bin/jhbuild build gtk-doc
and finally you can now install meta-gtk-osx-python by doing a: ~/.local/bin/jhbuild build meta-gtk-osx-python
Let me know if it works.
There is an installer for PyGTK 2.24 in test here, announced on the PyGTK list.
UPDATE project has moved on macpkg's sourceforge page.
I couldn't make it work with meld (segmentation fault), but sample PyGTK programs work OK.
UPDATE 2 since then a new package Py3GTK3 appeared on the same sourceforge page. Haven't tested though.
There is now a mac package on sourceforge
Download the latest package from http://sourceforge.net/projects/macpkg/files/PyGTK/ and install.
If you're just trying to use the system python, this is all you'll have to do.
If you're not, the following is how to install it with pyenv, which can be installed with Homebrew. With brew installed, you can install version pyenv and Python 2.7.8 with:
brew install pyenv && pyenv install 2.7.8
After you've done that, you'll then have copy the gtk package and its dependencies into your python installation:
cd /opt/gtk/lib/python2.7/site-packages/ && \
cp * ~/.pyenv/versions/2.7.8/lib/python2.7/site-packages/
That's it. You can also similarly install the Py3GTK3 package which has packages for python 2.7 and 3.2 from http://sourceforge.net/projects/macpkg/files/Py3GTK3/.
Have you tried doing it using macports? This website shows how.