Python3.5.2,selenium 3.0.0b2,Firefox 48.0:使用缩进中的制表符和空格不一致 [英] Python3.5.2, selenium 3.0.0b2, Firefox 48.0: inconsistent use of tabs and spaces in indentation

查看:429
本文介绍了Python3.5.2,selenium 3.0.0b2,Firefox 48.0:使用缩进中的制表符和空格不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  Traceback(最近一次调用的最后一个):
文件C:/ Users / **** / PycharmProjects / ******** / load_all_params.py ,第2行,在< module>
from selenium import webdriver
文件C:\ Users \ ***** \AppData\Local\Programs\Python\Python35-32\lib\site- packages \ selenium-3.0.0b2-py3.5.egg\selenium\webdriver\__init __。py,第25行,在< module>从.safari.webdriver
导入WebDriver作为Safari#noqa
文件C:\ Users \ ***** \AppData\Local\Programs\Python\Python35-32 \lib\site- packages\selenium-3.0.0b2-py3.5.egg\selenium\webdriver\safari\webdriver.py,第49行
executable_path = os.environ.get (SELENIUM_SERVER_JAR)
^
TabError:缩进中制表符和空格的不一致使用

使用退出代码1

我的问题是这是我的代码错误,或者是由于更新到selenium-3.0.0b2导致的这个错误?奇怪的是,我正在使用Firefox(48.0),在这里列出了Safari。这是怎么回事!



我写的脚本没有空格或制表符 - 只是一个命令列表。
我的代码示例:

  from selenium import webdriver 
driver = webdriver.Firefox()
driver.get(http://192.168.99.100:8080/***/***)
driver.implicitly_wait(10)
element = driver.find_element_by_id(lv-username )

等等...

解决方案

我有同样的错误,对我来说,工作是 init .py在你的情况下,它会是



C:\ Users ***** \AppData\Local\Programs\Python\Python35-32\lib\site- packages\selenium-3.0 .0b2-py3.5.egg\selenium\webdriver__init __。py

然后只是注释掉行



从.safari.webdriver导入WebDriver作为Safari#noqa



这是Safari浏览器的一个。因为那不是你想用的那个。


Traceback (most recent call last):
  File "C:/Users/****/PycharmProjects/********/load_all_params.py", line     2, in <module>
    from selenium import webdriver
  File "C:\Users\*****\AppData\Local\Programs\Python\Python35-32\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:\Users\*****\AppData\Local\Programs\Python\Python35-32\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

Process finished with exit code 1

My question is this an error with my code or is this error caused by update to selenium-3.0.0b2? The weird thing is that I am using Firefox(48.0) and here the Safari is listed. What is going on?!

The script I wrote has no spaces or tabs - its just a list of commands. My code sample:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://192.168.99.100:8080/***/***")
driver.implicitly_wait(10)
element = driver.find_element_by_id("lv-username")

and so on...

解决方案

I had the same error and what worked for me was going to the path of the init.py in your case it would be

"C:\Users*****\AppData\Local\Programs\Python\Python35-32\lib\site- packages\selenium-3.0.0b2-py3.5.egg\selenium\webdriver__init__.py"

Then just comment out the line

from .safari.webdriver import WebDriver as Safari # noqa

That is the one for the safari browser. Since that is not the one you want to use anyways.

这篇关于Python3.5.2,selenium 3.0.0b2,Firefox 48.0:使用缩进中的制表符和空格不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆