I have selenium installed and chrome driver in a python project, when i create a new project is says it can't recognize the selenium module.
Does this mean with each project I'll need to install selenium again?
I have selenium installed and chrome driver in a python project, when i create a new project is says it can't recognize the selenium module.
Does this mean with each project I'll need to install selenium again?
No, you don't need to install Selenium for each project. The installation procedure is only once in a lifetime using either of the following commands through command line interface:
Using pip:
pip install selenium
Using pip3:
pip3 install selenium
However, you would need to keep on upgrading pip periodically:
pip install -U pip
On windows:
python -m pip install -U pip
Or
C:\Users\username>python -m pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)
100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 1.3MB 544kB/s
Installing collected packages: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
Successfully installed pip-18.0
As a mandatory measure you need to upgrade the Selenium bindings to keep in sync with the release of each stable version as follows:
C:\Users\username>pip install -U selenium
Collecting selenium
Downloading https://files.pythonhosted.org/packages/b8/53/9cafbb616d20c7624ff31bcabd82e5cc9823206267664e68aa8acdde4629/selenium-3.14.0-py2.py3-none-any.whl (898kB)
100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 901kB 380kB/s
Requirement not upgraded as not directly required: urllib3 in c:\python\lib\site-packages (from selenium) (1.22)
Installing collected packages: selenium
Found existing installation: selenium 3.12.0
Uninstalling selenium-3.12.0:
Successfully uninstalled selenium-3.12.0
Successfully installed selenium-3.14.0
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
You can find a detailed relevant discussion in:
You need to initialize browser in selenium each time when you are trying to run your automation test.
driver = webdriver.Chrome('./chromedriver')
driver.get("https://www.python.org")
print(driver.title)
You dont need to install selenium everytime you just need to initialize browser session wwhen you are trying to run your test from differnt project.
Also use pip to install
the selenium package.
Try below command to install selenium using pip command after installing python
pip install selenium
You will find your dependancies under Python\Lib\site-packages
You don't need every time , you need use by giving path and locate to folder in your machine
yes you need to. In cases where you create virtual environment for each projects. It is better to have it install into the project virtual environment. This will save you a lot of stress debugging your code later in future.