【发布时间】:2023-04-09 14:47:02
【问题描述】:
我是 Splinter 的新手,但我使用过几次 python。所以我希望使用 splinter 自动化一个网站。但是执行时出现“ImportError: cannot import name Browser”错误。
这是我的代码。
from splinter import Browser
browser = Browser()
browser.visit('http://google.com')
browser.fill('q', 'splinter - python acceptance testing for web applications')
browser.find_by_name('btnG').click()
if browser.is_text_present('splinter.readthedocs.org'):
print "Yes, the official website was found!"
else:
print "No, it wasn't found... We need to improve our SEO techniques"
browser.quit()
在终端中,这就是我得到的。
Traceback (most recent call last):
File "splinter.py", line 3, in <module>
from splinter import Browser
File "/var/www/project/splinter.py", line 3, in <module>
from splinter import Browser
ImportError: cannot import name Browser
我怎样才能不出错地运行这个程序? 我已经提到了类似问题的解决方案,例如删除 splinter.pyc,但它对我没有帮助。
【问题讨论】:
标签: python selenium automation python-import splinter