How to resolve Selenium with Python: TypeError: amp;#39;moduleamp;#39; object is not callable(如何使用Python解析Selenium:TypeError:amp;#39;模块amp;#39;对象不可调用)
问题描述
我是Selenium/Python的新手,很少练习。在pycharm中运行我的Selenium/Python程序时,我收到以下错误。请帮帮忙。
C:Users
k.maravPycharmProjectsRadhaSeleniumvenvScriptspython.exe C:/Users/rk.marav/PycharmProjects/RadhaSelenium/Tests/mainTest.py
Traceback (most recent call last):
File "C:/Users/rk.marav/PycharmProjects/RadhaSelenium/Tests/mainTest.py", line 13, in <module>
m.main()
File "C:/Users/rk.marav/PycharmProjects/RadhaSelenium/Tests/mainTest.py", line 10, in main
driver.getbrowserInstance()
File "C:Users
k.maravPycharmProjectsRadhaSeleniumexecutionEngineDriverScript.py", line 25, in getbrowserInstance
driver = webdriver.ie(executable_path='C:/Selenium/Drivers/IEDriverServer.exe')
TypeError: 'module' object is not callable
Main Test started...
IE
Browser invoke started
Process finished with exit code 1
下面是我的代码:
DriverScript.py:
class driverScript:
def __init__(self,browser=None):
if browser is None:
browser = {}
else:
self.browser = browser
print(self.browser)
#self.constants = Constants()
def getbrowserInstance(self):
# create a new IE session
print("Browser invoke started")
if (self.browser=='IE'):
driver = webdriver.ie(executable_path='C:/Selenium/Drivers/IEDriverServer.exe')
driver.maximize_window()
driver.implicitly_wait(5)
driver.delete.allcookies()
print("Browser is Invoked")
driver.get("http://www.store.demoqa"
".com")
mainTest.py
from executionEngine.DriverScript import driverScript
from Utilities.Constants import Constants
from selenium import webdriver
class mainTest(driverScript):
def main(self):
print("Main Test started...")
driver = driverScript('IE')
driver.getbrowserInstance()
m = mainTest()
m.main()
推荐答案
此错误消息.
driver = webdriver.ie(executable_path='C:/Selenium/Drivers/IEDriverServer.exe')
TypeError: 'module' object is not callable
.表示webdriver.ie是一个模块,不可调用。
@JohnGordon在他的分析中相当正确。selenium.webdriver.ie.webdriver
是与Selenium相关的Python Module之一,不可调用。
若要通过selenium-iedriver启动internet-explorer会话,您需要将较小的i
替换为大写I
。因此,实际上您的代码行将是:
driver = webdriver.Ie(executable_path=r'C:SeleniumDriversIEDriverServer.exe')
您可以在TypeError: 'module' object is not callable error with driver=webdriver("C:Python34Libsite-packagesseleniumwebdriverchromedriver.exe")
中找到相关讨论
这篇关于如何使用Python解析Selenium:TypeError:&;#39;模块&;#39;对象不可调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用Python解析Selenium:TypeError:&;#39;模块&;#39;对象不可调用


- 如何将一个类的函数分成多个文件? 2022-01-01
- 如何在 Python 的元组列表中对每个元组中的第一个值求和? 2022-01-01
- python check_output 失败,退出状态为 1,但 Popen 适用于相同的命令 2022-01-01
- padding='same' 转换为 PyTorch padding=# 2022-01-01
- 沿轴计算直方图 2022-01-01
- python-m http.server 443--使用SSL? 2022-01-01
- pytorch 中的自适应池是如何工作的? 2022-07-12
- 如何在 python3 中将 OrderedDict 转换为常规字典 2022-01-01
- 分析异常:路径不存在:dbfs:/databricks/python/lib/python3.7/site-packages/sampleFolder/data; 2022-01-01
- 使用Heroku上托管的Selenium登录Instagram时,找不到元素';用户名'; 2022-01-01