Selenium Python (Import Error) Python-Selenium-Eclipse - python

After Running the below Command:
from selenium import webdriver
I get the Following error:
Traceback (most recent call last):
File "C:\Users\tempjatop\workspace\TestPython\Sample.py", line 1, in <module>
from selenium import webdriver
File "C:\Python\lib\site-packages\selenium-3.0.0b2-py3.5.egg\selenium\webdriver\__init__.py", line 25, in <module>
from .safari.webdriver import WebDriver as Safari # noqa
File "C:\Python\lib\site-packages\selenium-3.0.0b2-py3.5.egg\selenium\webdriver\safari\webdriver.py", line 49
executable_path = os.environ.get("SELENIUM_SERVER_JAR")
^
TabError: inconsistent use of tabs and spaces in indentation
I don't know why it is redirecting it to safari webdriver.
Please suggest any fixes or am i doing anything wrong?

As the error says:
TabError: inconsistent use of tabs and spaces in indentation
Check for indentations in your code and correct the inconsistent ones.

Related

Selenium, chromedriver and python difficulties

I have this written down in my code but this keeps happening and I'm unsure what to do. I followed this video but don't know where to go as I followed the steps
https://www.youtube.com/watch?v=7R5n0sNSza8
from selenium import webdriver
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
from selenium import webdriver
ModuleNotFoundError: No module named 'selenium'

chrome driver install with selenium

I have properly install selenium and chromedriver and wanted to execute this below code at python
import selenium
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r"C:\Users\SM.Nibir\Desktop\Python\chromedriver_win32\chromedriver.exe")
but I am getting these errors on my output panel
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:/Users/SM. Nibir/Desktop/Python/import os.py", line 3, in <module>
driver = webdriver.Chrome()
File "C:\python\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\python\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Who can I solve this problem and make this code work properly?
first of all, your first mistake is that you wrote "import selenium from.."
so the order has to be that way:
from selenium import webdriver
driver=webdriver.Chrome(executable_path=r"C:\Users\...chromedriver.exe")
ofcourse that you need to change the path for the correct location of your chromedriver.exe file.
let me know if it helps.

Import Error Symbol not found: __PySlice_AdjustIndices

I am doing some beginner Selenium to automate a task in the browser. I have installed Selenium using pip install selenium and I know it installed successfully because I saw the following message: Successfully installed selenium-3.9.0.
Okay so that's clear Selenium is up and working.
I want to run this python file:
from selenium import webdriver
browser = webdriver.Firefox()
type(browser)
browser.get('http://inventwithpython.com')
However, when I run this using the terminal, I get the following error:
mustafas-mbp:PlayDivya mustafahoda$ python playDivya.py
Traceback (most recent call last):
File "playDivya.py", line 4, in <module>
from selenium import webdriver
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox # noqa
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 22, in <module>
import httplib as http_client
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 69, in <module>
from array import array
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/array.so, 2): Symbol not found: __PySlice_AdjustIndices
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/array.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/array.so
Any help would be super helpful. This is a very simple script and I have no idea why this is happening!
Thanks in advance!
The error says it all :
Traceback (most recent call last):
File "playDivya.py", line 4, in <module>
from selenium import webdriver
.
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/array.so, 2): Symbol not found: __PySlice_AdjustIndices
Reasons and Solution
This issue can arise when you install a new version of python. In those cases you may need to run hash -r python to tell bash to reset the cached location to the python executable.
If hash -r python says too many args then you can use rehash command.
As per the discussion Symbol not found: __PyCodecInfo_GetIncrementalDecoder the issue occurs when Python is updated from Python 2.7.10 to 2.7.11.
If you are using conda package you need to run conda install python=2.7.10 which will solve this problem.
Even downgrading Python to 2.7.10 will also work.
The best solution would be Re-Installing Selenium.

pyCharm Selenium Python eol while scanning string

I have installed selenium and I can run it on Python.
When I try and run int on pyCharm I keep getting the errors below. I believe it may have to do with how and where I installed pyCharm, but I can't seem to get it to work.
I am looking for help on how I should be configuring pyCharm so I can run my automation script using Python, Selenium, ChromeDriver, and set it up to be triggered every 24 hours and 5 minutes.
script:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser= webdriver.Chrome("D:/Projects/chromedriver.exe")
browser.get("https://url.com/")
formElem= browser.find_element_by_name('email')
formElem.send_keys('ucsb#gmail.com')
zipElem=browser.find_element_by_name('zipcode')
zipElem.send_keys('93101')
EnterNowElem=browser.find_element_by_xpath('//input[#value="Enter Now"]')
#EnterTagElem=browser.find_element_by_class_name("")
EnterNowElem.click()
I get the errors below.
"C:\Program Files (x86)\Python36-32\python.exe"
C:/Users/rxper/Desktop/PycharmProjects/Automation/formsubmit.py
Traceback (most recent call last):
File "C:/Users/rxper/Desktop/PycharmProjects/Automation/formsubmit.py", line 1, in <module>
from selenium import webdriver
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox # noqa
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 19, in <module>
import http.client as http_client
File "C:\Program Files (x86)\Python36-32\lib\http\client.py", line 71, in <module>
import email.parser
File "C:\Users\rxper\Desktop\PycharmProjects\Automation\email.py", line 31
'Subject: So long.\nDear Alice, so long and thanks for all the fish. Sincerely,
^
SyntaxError: EOL while scanning string literal
Process finished with exit code 1
You problem is below
File "C:\Users\rxper\Desktop\PycharmProjects\Automation\email.py"
and
File "C:\Program Files (x86)\Python36-32\lib\http\client.py", line 71, in <module>
import email.parser
Python has a internal module email and your Automation\email.py is overshadowing the same. Rename the file and it should work

Splinter: DriverNotFoundError for zope.testbrowser

I am using Python Splinter to automate a website and to scrape data from it. When I use the default browser mode which is keeping blank in Browser() it opens firefox and completes the written task but, when I use the headless browser 'zope.testbrowser', I get the following error. What should I need to do here?
Traceback (most recent call last):
File "pysplinter.py", line 4, in <module>
browser = Browser('zope.testbrowser')
File "/usr/local/lib/python2.7/dist-packages/splinter/browser.py", line 62, in Browser
raise DriverNotFoundError("No driver for %s" % driver_name)
splinter.exceptions.DriverNotFoundError: No driver for zope.testbrowser
I don't know if this is still relevant, but will post anyway for the benefit of others.
I faced the same issue and my problem was that mechanize module was not installed.
Fix:
pip install mechanize
However, I faced another issue after this.
Explanation
That's the line of code that is failing in browser.py of splinter, but due to except: pass, it is being silently ignored. If executed manually, the root of the problem can be observed:
>>> from splinter.driver.zopetestbrowser import ZopeTestBrowser
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/rustam/.virtualenvs/python2/lib/python2.7/site-packages/splinter/driver/zopetestbrowser.py", line 19, in <module>
import mechanize
ImportError: No module named mechanize

Categories

Resources