Getting WebDriver.jl to work - what could cause init_chrome to throw an error?

I am following a clip on using Selenium:

Selenium

I have:

  • Installed the latest version of Python
  • pip install selenium
  • added WebDriver.jl (I use Atom).
  • added PyCall.jl (again, via Atom)
  • installed chromedriver

Now, the following creates an error:

using PyCall
using WebDriver

browser = init_chrome()

I get the error:

UndefVarError: init_chrome not defined

What am I doing wrong? What have I missed?

UPDATE:
I tried re-installing Python using Conda (I manually installed the latest version of Python prior to that). I also used Conda to add selenium. But, I still get the same problem.

This video seems outdated (it refers to an older version of WebDriver.jl).
I don’t think init_chrome is a method/function of WebDriver.jl.
Consider the manual here
https://nosferican.github.io/WebDriver.jl/dev/manual/

It seems you need to run selenium on docker (or similar) for this to work.

If you want a solution via PyCall (without WebDriver.jl), you may consider the following snippet:
I note that WebDriver.jl likely has limited functionality compared to, e.g., the python library for selenium

using Pkg
tmpd = mktempdir()
Pkg.activate(tmpd)
Pkg.add("PyCall")
#Pkg.add("WebDriver")

#using WebDriver
using PyCall

using Conda 
Conda.add("selenium")

webdriver = pyimport("selenium.webdriver")
#webdriver.Edge(),webdriver.Chrome(),webdriver.Firefox() ,webdriver.Ie(),webdriver.Opera(),webdriver.PhantomJS(),webdriver.Safari(),webdriver.Android() 

#you will need to download chromdriver for the next call to work
#also chromedriver.exe needs to be in PATH (windows environment variable) for this to work 
#also the chrome version you have needs to match the chromedriver version
driver = webdriver.Chrome() 
3 Likes