How to close tab with selenium on macos with chrome driver? - macos

My code
from selenium import webdriver
dr = webdriver.Chrome()
dr.close()
I got this error
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

The error is telling you what is wrong: the chromedriver program is not found in your executable path (stored in the environment as $PATH).
You can tell what the current path is using something like this:
import os
print os.environ['PATH']
Once you know the path, you can install chromedriver into one of the directories in the path.

The correct solution would be to just add the path of your chrome driver. The best way to do that is just have the chrome driver in the same directory as you are probably going to be updating it a lot since google is still working on it.

Related

Unable to find the chromedriver executable. Ruby. Webdriver. Mac

Please help!
I am trying to run my testing script using Ruby and Selenium Web driver.
require "selenium-webdriver"
driver = Selenium::WebDriver.for :chrome
driver.navigate.to "google.com"
driver.quit
but it gives me an error
Unable to find the chromedriver executable. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. (Selenium::WebDriver::Error::WebDriverError)
I have installed the chromedriver and unzipped it in the directory ~/webdrivers. And added the path to the chromedriver to the PATH.
Then I tried to move the chromedriver to ~/bin directory and have it in PATH.
Nothing worked. I still get the error.
Thank you.
1 - Download the ChromeDriver executable.
2 - Either create your own PATH to a unique folder on your mac or copy the file to an existing PATH directory. To do this:
a - Open up Terminal
b - Run sudo nano /etc/paths
c - Enter your password
d - Go to the bottom of the file and enter the path you wish to add
e - My PATH looks like: /Users//Documents/WebDriver
f - Control-x to quit
g - Y to save
To double check, quit Terminal and relaunch it. Run echo $PATH. You should see your newly added path in the stream of other paths already there.
Finally, update your tests to run using ChromeDriver (include code snippet) and run your tests!
Another tip: if you use brew on Mac I would recommend brew install chromedriver.
re-run "selenium-standalone install" after re-installing

How can I download ChromeDriver to NitrousIO Box Path?

I'm trying to use the watir-webdriver to build a webscraper but I'm getting an error message about being unable to find the firefox binary. Well, I'm not using firefox, I'm using Chrome.
So now I need to install the ChromeDriver binary and put in my PATH. Problem is, I have know idea how to do that in the NitrousIO IDE.
UPDATE: I downloaded and unzipped the 64bit binary. Now I'm trying to put it in my path. Eventually I got echo $PATH to read the binary, but I'm still getting an 'unable to find webdriver executable' error.
I tried mving the file into usr/bin but I got a permission denied error. Does anyone know a solution to this?

Mathematica won't find SerialIO package

I'm following a guide from The Mathematica Journal that describes how to use Mathematica with the Lego Mindstorms NXT. I have some trouble getting started and got stuck with the SerialIO package.
I use Mac OSX and I have installed the package to:
/Applications/Mathematica.app/AddOns/ExtraPackages/SerialIO/
The command Needs["SerialIO`"] gives me the following error message:
LinkOpen::linke: Could not find MathLink executable.
And trying
SetDirectory[FileNameJoin[{$InstallationDirectory, "AddOns", "ExtraPackages", "SerialIO", $SystemID}]];
Does not help either, it gives:
SetDirectory::cdir: Cannot set current directory to /Applications/Mathematica.app/AddOns/ExtraPackages/SerialIO/MacOSX-x86-64.
There seem to be some problem with the alias/symbolic link in the SerialIO folder. By default they pointed to an absolute directory on the machine that this library was built on:
MacOSX-x86-64 -> /Files/schofield/Packages/SerialIO/Build/Mac/build/Deployment/Package/SerialIO/MacOSX
I tried deleting the alias and creating a symbolic link in the terminal:
ln -s MacOSX MacOSX-x86-64
Running the SetDirectory command again result in... no result, so I guess thats good. The commands seem to have been loaded as when typing Serial it want to autocomplete to SerialOpen etc.
However, using the command mybrick = SerialOpen["name of serial port"] does not put the NXT in connected mode (<> on NXT display). Does anyone else got it to work?
There was a problem in SerialIO in combination with Mathematica9. After some correspondence in may 2013, Wolfram Support find the problem and updated SerialIO for me. It seems logical that they also update SerialIO on their site. Please have a try and download SerialIO again and update. My OS is MaxOSX.

Node.js - using socks5 module

I'm on a Mac running OSX 10.8.2. I'm learning Node.js and want to do requests using socks.
In the Terminal I used
git clone https://github.com/mattcg/socks5-http-client.git
to get the socks5 http client source.
In the downloaded source folder is an example called example-tor, so I ran
node example-tor.js
This gives me a message saying "Cannot find module 'socks5-client'".
This error is being thrown in a js file in the source folder called agent.js on a line that says var socksClient = require('socks5-client');
What am I doing wrong?
To be honest, I am just beginning Node.js. I'm not sure if I fully understand how modules work, where they are located on my Mac and how Node.js is supposed to know where they are.
I have been running through the documentation, "hello world" tutorials and tutorials to install things like "npm" package manager but the whole process of getting something working seems very messy and unclear.
Hope someone can point me in the right direction.
Try running npm install from the terminal in the socks5-http-client top folder (the same one with the package.json file)

Xlib.h not found when building graphviz on Mac OS X 10.8 (Mountain Lion)

When using homebrew to install graphviz, the script gets to the point of "Making install in tkstubs" and then throws the following fatal error:
In file included from tkStubLib.c:15:
/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>
I have installed XQuartz as X11 has been dropped in Mountain Lion, but I'm unsure if it is installed correctly. The location of Xlib.h is:
/opt/X11/include/X11/Xlib.h
There are also two symlinks to /opt/X11, they are:
/usr/X11
/usr/X11R6
Does this look like the correct setup to you? I've never dealt with X11 or XQuartz until yesterday.
Cheers.
After installing XQuartz you may add a symlink to your X11 installation folder by just entering
ln -s /opt/X11/include/X11 /usr/local/include/X11
in terminal. That will fix the problem as well without changing any ruby script.
You need to tell the tkstubs build (and possibly other bits in the package as well) to look for headers in /opt/X11/include; this is not on the standard include path.
Usually this is achieved by passing -I/opt/X11/include as an additional compiler flag, the method to do so is however dependent on the build system.
For reasonably modern configure scripts, the best approach is to pass it in the environment variable CPPFLAGS; if the package uses another build system or this doesn't work for another reason, then you need to look at the Makefile in the build directory.
You can enter in your shell before the compile/link (or brew) command:
export CPPFLAGS=-I/opt/X11/include
The export line will tell the compile/linker to look in /opt/X11/include for the X11 include files
Had the same issue and running this command on terminal
xcode-select --install
worked for me. Run this command after installing xQuartz.
If you need this to work in your CMake builds:
if(APPLE)
include_directories(AFTER "/opt/X11/include")
endif()
That worked well for me.
I got it to install by copying the x11 header file directory to the /opt/local/include directory. Probably not the best way to work around it but quick and easy.
I found this thread while trying to compile ffmpeg from source on OS X. I needed --enable-x11grab and the homebrew build does not support this option.
I had XQuartz installed already but I kept getting errors from ./configure: ERROR: Xlib not found. I thought the answers here would solve my problem, but they did not!
So, if anyone is ever in the same boat, my solution was this:
I opened up the generated config.log and found lots of errors referring to various includes and header files, including X11/Xlib.h - this is misleading. At the very bottom of the logfile was the key, pkg-config was complaining about looking for xbc.pc, and requested that it be put on the path. However, the error message that is displayed on the terminal says nothing about pkg-config or xbc!
The solution is to add to your PKG_CONFIG_PATH environment variable. Mine was nonexistent, so I just did export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ (the folder where I found xbc.pc).
I reran configure and everything worked like a charm!
TL;DR: check config.log - don't trust the terminal output!
Since the make file is looking for X11/xlib.h i.e., it is looking for X11 folder in the current directory, one way to solve this problem is to simply copy the /opt/X11/include/X11 directory to the directory that contains make file.

Resources