4

Link to the original code I'm trying to implement into my code.

Running Selenium WebDriver using Python with extensions (.crx files)

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chop = webdriver.ChromeOptions()
chop.add_extension('Adblock-Plus_v1.4.1.crx')
driver = webdriver.Chrome(chrome_options = chop)

I tried incorporating the code, but the 2nd line,

from selenium.webdriver.chrome.options import Options

is tossing out an error

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    from selenium.webdriver.chrome.options import Options
ImportError: No module named options

I updated selenium, updated chromedriver, and this problem doesn't go away. I checked stackoverflow and nothing seems to be related to my problem where the module is found.

Community
  • 1
  • 1
beeeliu
  • 99
  • 1
  • 1
  • 6

4 Answers4

5

Seems like there is an issue with below statement:-

chop = webdriver.ChromeOptions()

Try:-

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chop = Options()
chop.add_extension('Adblock-Plus_v1.4.1.crx')
driver = webdriver.Chrome(chrome_options=chop)
Paras
  • 3,197
  • 2
  • 20
  • 30
1

I fixed the problem, there was no options.py in the selenium2.7 version for some unusual reason.

All I did was update using terminal for mac osx, but you can't just update it, you have to delete all the pre existing paths first. So go find where your selenium is installed using

import sys
print sys.path

Find your selenium path, cd into the path using terminal and delete every folder or file with selenium attached to it.

In your terminal, type

sudo easy_install selenium

The problem I had where this problem didn't go away was I called sudo easy_install without deleting the folder. For some reason, the hickup was gone after I deleted everything and did a fresh install.

beeeliu
  • 99
  • 1
  • 1
  • 6
0

Most probably you may have installed different version selenium 2.X do not have the options module. Your code works fine with selenium 3.x

Try installing pip install selenium in virtual environment and run you code

Madhusudan chowdary
  • 543
  • 1
  • 12
  • 20
0

I got a similar error once because I was using "options" instead of "Options". There are both "Options" & "options" available in in "from selenium.webdriver.chrome.options import " so don't get confused.

shabd89
  • 1
  • 2