WebDriverException: Message: phantomjs executable may have incorrect permissions

Launch selenium locally on the flask. I am using the PhantomJS driver. I previously had a path error:

selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH. 

But after asking from another StackOverflow question, I found out that I need to pass the environment path as a parameter to PhantomJS. The path that I have below is the path to the phantomJS folder in my virtual environment folder.

 driver = webdriver.PhantomJS(executable_path='/Users/MyAcc/Documents/MYWEBAPP/venv/lib/python3.5/site-packages/selenium/webdriver/phantomjs') 

However, now I get a new error code:

 selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable may have wrong permissions. 

This is what I get when I check the permissions of the path file.

 total 40 drwxr-xr-x 7 USER staff 238 Nov 6 00:07 . drwxr-xr-x 17 USER staff 578 Nov 6 00:03 .. -rw-r--r--@ 1 USER staff 6148 Nov 6 00:07 .DS_Store -rw-r--r-- 1 USER staff 787 Oct 31 12:27 __init__.py drwxr-xr-x 5 USER staff 170 Oct 31 12:27 __pycache__ -rw-r--r-- 1 USER staff 2587 Oct 31 12:27 service.py -rw-r--r-- 1 USER staff 2934 Oct 31 12:27 webdriver.py 
+7
source share
7 answers

I put the phantomjs file in /usr/local/bin and it worked fine.

+2
source

Well, I figured this out with the following code:

 browser = webdriver.PhantomJS(executable_path = "/usr/local/Cellar/phantomjs/2.1.1/bin/phantomjs") 
+2
source

I met this problem before about python + phanomjs. Decision:

Linux

putting phantoms in /usr/local/share

Window

put phantoms in /python/scripts

+1
source

I think the true reason for your problem is that: the phantoms that webdrive needs are not the one that is under selenium/webdriver fold . When you use anaconda to install this package, it is really confusing (at least for me).

  • First install it with conda install -c conda-forge phantomjs , test it with phantomjs --version .
  • Then you can find the real phantomjs.exe in this folder: "path = /${home_path}/anaconda3/envs/${env_name}/bin/phantomjs" . To check if this is the true path, check with /${home_path}/anaconda3/envs/${env_name}/bin/phantomjs --version . It should correctly display __version__ information.
  • Pause this path to webdriver.PhantomJS(executable_path=path) and it will be fixed.

Therefore, there is no need to use chmod or put it in /usr/local/bin (thus, the only advantage is that you can skip the executable parameter)

+1
source
 executable_path = './phantomjs-2.1.1-linux-x86_64/bin/phantomjs' service_log_path = './log/ghostdriver.log' driver = webdriver.PhantomJS(executable_path=executable_path, service_log_path=service_log_path) 

You can use both relative and absolute paths.

0
source

selenium.common.exceptions.WebDriverException: Message: phantomjs executable may have incorrect permissions.

This error, because phantomjs did not execute permissions, if for phantomjs - 2.1.1 - Linux - x86_64 / bin / phantomjs add execution permissions, chmod u + x phantomjs

hope you can help you.

0
source

Strange, this was fixed for me by adding phantomjs to /usr/local/share and adding some symbolic links. I have completed the following steps :

  • move the phantomjs folder to /usr/local/share/ :
    • sudo mv phantomjs-2.1.1-linux-x86_64.tar.bz2 /usr/local/share/.
  • create symbolic links:
    • sudo ln -s /usr/local/share/phantomjs-1.8.1-linux-x86_64 /usr/local/share/phantomjs
    • sudo ln -s /usr/local/share/phantomjs-1.8.1-linux-x86_64 /usr/local/share/phantomjs

I am not a Linux expert, so I do not know why this matters. If someone wants to step in, feel free to.

-1
source

Source: https://habr.com/ru/post/1259353/


All Articles