python中属性对象不可下标是什么意思_python - 模块对象不可下标不能从硒调用方法,如何解决? - SO中文参考 - www.soinside.com...

所以我想将配置文件首选项调用到已初始化的浏览器,所以基本上我使用字典的方法名称来在浏览器之间轻松切换,这给了我这个错误,这个名称还可以,如果像这样self._webdriver.FirefoxProfile()可以使用,但是我想动态选择该方法的首选项,我喜欢这个self._webdriver[self._profile]()“” __profile“”“是有效的,我会检查一下

我的字典:PREFERENCE_DICTIONARY = {

'chrome':{'browser':'ChromeOptions', 'add_preference_method':'add_experimental_option', 'update_preference': 'update', 'set_preference':'chrome_options', 'capabilities_init':"ChromeOptions", 'capabilities_add_method':'add_argument', 'update_capabilities_method':"to_capabilities", 'capabilities_set_method': 'desired_capabilities'},

'firefox':{'browser':'FirefoxProfile', 'add_preference_method':"set_preference", 'update_preference':'update_preferences', 'set_preference':'firefox_profile', 'capabilities_init':"['DesiredCapabilities']['FIREFOX']['copy']", 'capabilities_add_method':'', 'update_capabilities_method':"", 'capabilities_set_method': 'capabilities'}}

我有从该字典字符串加载到变量值到“ _profile”的方法,然后稍后调用

然后在我的函数中,我称其为动态更改我所需要的,但是我不能这样做,因为它给了我错误。def setup_profile_preferences(self):

profile_preference = self._webdriver[self._profile]()

追踪browser.py", line 79, in setup_profile_preferences

profile_preference = self._webdriver[self._profile]()

TypeError: 'module' object is not subscriptable

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值