Wednesday, February 6, 2019

py0006 : selenium.common.exceptions.WebDriverException: Message: Failed to find firefox binary. You can set it by specifying the path to 'firefox_binary':

I have reinstalled the Firefox earlier it was working fine, suddenly it started giving this error. If you read error carefully it is going to search firefox.exe (binary file) which is unable to find.

Locate your firefox.exe file and set in a variable and add below lines in your code

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary('C:/Users/****/AppData/Local/Mozilla Firefox/firefox.exe')
driver = selenium.webdriver.Firefox( firefox_binary=binary)

py0005 : selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities

Error : selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities

I am using latest Selenium 3.8.0 and GeckoDriver and Firefox version 64.0.2.
Below Firefox version 64.0.2 you might have set capability marionette to False using DesiredCapabilities

Solution
Add below code
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities().FIREFOX
cap["marionette"] = False

Tuesday, February 5, 2019

py0004 : Begginner error, Open Firefox

I have written the code and getting two type error from 3 rows of code that is ridiculous:
First error belongs to the Firefox driver which was not found and gives error like  "File "C:/Users/*****/Desktop/python/example/0001.py", line 3, in "

Second type of error is "NameError: name 'selenium' is not defined" as name showcase something not found related to selenium

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = selenium.webdriver.Firefox()

Error on execution of code 
C:\Users\*****\AppData\Local\Programs\Python\Python37-32\python.exe C:/Users/*****/Desktop/python/example/0001.py
Traceback (most recent call last):
  File "C:/Users/*****/Desktop/python/example/0001.py", line 3, in
    driver = selenium.webdriver.Firefox()
NameError: name 'selenium' is not defined

Process finished with exit code 1


SOLUTION:
Add path for Firefox driver that you have downloaded from internet and add "Import selenium" at first line

import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = selenium.webdriver.Firefox(executable_path= r'C:\\Users\\*****\\Desktop\\python\\geckodriver-v0.24.0-win64\\geckodriver.exe')

Run the Code, Firefox will open automatically

py0003 : pip install selenium SyntaxError: invalid syntax, while install selenium

I was trying to install python-selenium binding, somebody told me to execute below command but i was not aware where to execute, so while executing below command i was getting this error

>>> pip install selenium
  File "", line 1
    pip install selenium
              ^
SyntaxError: invalid syntax
>>> pip
Traceback (most recent call last):
  File "", line 1, in
NameError: name 'pip' is not defined

However i tried to search pip jar, but not found however able to find pip.exe file in installation folder of PYTHON. It was found at "C:\Users\*****\AppData\Local\Programs\Python\Python37-32\Scripts"

So now open CMD, move to above directory ( using cd batch command ) upto script (* it could be different in your case) and execute below command:


C:\Users\*****\AppData\Local\Programs\Python\Python37-32\Scripts>pip install selenium
Collecting selenium
  Downloading https://files.pythonhosted.org/packages/80/d6/4294f0b4bce4de0abf13e17190289f9d0613b0a44e5dd6a7f5ca98459853/selenium-3.141.0-py2.py3-none-any.whl (904kB)
    100% |████████████████████████████████| 911kB 3.9MB/s
Collecting urllib3 (from selenium)
  Downloading https://files.pythonhosted.org/packages/62/00/ee1d7de624db8ba7090d1226aebefab96a2c71cd5cfa7629d6ad3f61b79e/urllib3-1.24.1-py2.py3-none-any.whl (118kB)
    100% |████████████████████████████████| 122kB 3.6MB/s
Installing collected packages: urllib3, selenium
Successfully installed selenium-3.141.0 urllib3-1.24.1
You are using pip version 18.1, however version 19.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Friday, February 1, 2019

py0002 : No Python interpreter is selected

Error is too simple to understand.

This error generally come when you install some of the Python interface like Pycharm or Anaconda only and Python not have installed on your system.

Information for Starters - Python is command based language you need to open cmd and enter in python prompt.

But if you want to work more beautifully there are several interpreter in market to work on UI.

Solution for this problem - install Python.exe on your machine, use default installation process and any latest version of python, in my case i have installed "python-3.7.2.exe"

and launch PyCharm > after click on new project > Select interpreter and select "python.exe"
web stats