Raspberry Pi raspberry 3B install selenium and iceweasel (firefox)

The purpose is to intend to control the browser with python. Documenting the whole process, I hope it will save everyone time.

The most frustrating thing is the versions of various software.
First the last software version:
Raspberry Pi 3B
iceweasel 52+selenium 3.3 +geckodriver 15.0
python2.7

firefox In the Raspberry Pi, the name is iceweasel. iceweasel, selenium, and geckodriver all have version correspondences. If one of them is wrong, it is likely to report an error.

Process

Before installation

You have to apt-get update first

sudo apt-get update

 

Install iceweasel (firefox) 

sudo apt-get install iceweasel


Check the version of iceweasel, make sure it is 52

iceweasel -version


Mine is 52.7.3

 

Download driver geckodriver

For iceweasel of 52.7.3, Jianghu legend has to be equipped with geckodriver of version 0.15.0: Download address 
Here, pay attention to select the compiled version of arm and


 download it, decompress it, get the geckodriver file, and set the permission of this file to 777

sudo chmod -R 777 geckodriver

Move the geckodeiver file to the environment variable /usr/local/bin directory
 

install selenium

The version of Selenium is 3.3 or above. Let's just use 3.3 to prevent anything from happening

sudo pip install selenium==3.3

 

prepare code

This installation is complete, let's prepare the code for the python test:

from selenium import webdriver

browser = webdriver.FireFox()

browser.get('http://www.baidu.com')
browser.get('http://www.qq.com')

The function is to visit Baidu first, and then visit QQ's website. After python runs, firefox can be successfully opened, and the process is completed, indicating that the environment installation is successful.
 

 

postscript

Record two points
1. Many blog posts on the Internet do not explain where to put the geckodriver file. I tried it myself, if I put it in a directory. For example ~ directory. Then in the browser = webdriver.FireFox() of the python code, the path of the geckodriver should be passed in as a parameter. But I found that specifying the full path of geckodriver in webdriver.FireFox() will report a very strange error. Says that the specified path is not a directory... I checked a lot of tutorials and they all say that the path name of the file is specified here, not the name of the folder. So it's kind of weird. Also hope to know the advice of friends.

2. About the chromium browser
Originally, I planned to use selennium to control the chromium, after all, the chreomium that comes with the Raspberry Pi 3B. Performance feels better too. But at the end of the attempt, an error with a status code of 127 was reported. After searching on the Internet, it may still be a problem with the driver version. There is a blog on the Internet that is more detailed: In the linked   article, pay special attention to the version of chromium on your Raspberry Pi. According to the tips of the article, the version on my Raspberry Pi did not find the corresponding driver. Chromium and chrome use the same set of drivers. Other articles also mention the version correspondence between chrome and driver: link . However, with the maintenance of the version, the newer version no longer supports the Linux of arm. There is relatively little information about successful experiences on the Internet, and most of them have encountered various problems.



3. If you consider installing under Windows, please refer to this article. Temporarily found, put it here, memo. Links

Special thanks for this article, I took a big detour: https://blog.csdn.net/DDQ_DQ/article/details/77367739


  •  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324394075&siteId=291194637