当前位置:网站首页>web自动化切换窗口时报错“list“ object is not callable
web自动化切换窗口时报错“list“ object is not callable
2022-07-02 06:22:00 【bthtth】
# 重新封装switch_to.window
def is_open_new_window(self,current_handles) # 形参名和new_window_is_opened的形参重复
"""
检测是否有新窗口打开,如果有就切换到新窗口
"""
if EC.new_window_is_opened(all_handles):
self.driver.switch_to.window(self.driver.window_handles[-1])
# 编写page对象
def to_new_page(self):
""" 点击按钮,跳转到新的页面 """
WebDriverWait(self.driver).until(EC.visiblity_of_element_located((By.ID,index.list_fc))
window_handles = self.driver.window_handles
# window_handles 和window_handles()重复
self.click(index.list_fc)
self.is_open_new_window(handles_index) # 调用重新封装的方法
以上为报错代码,凭借印象重写的,不能复现,仅作参考.
解决的方法就是,检查变量名,方法名是否与变量,方法,形参名重复
修改后的代码
# 重新封装switch_to.window
def is_open_new_window(self,all_handles)
"""
检测是否有新窗口打开,如果有就切换到新窗口
"""
if EC.new_window_is_opened(all_handles): # 实参命名为all_handles
self.driver.switch_to.window(self.driver.window_handles[-1])
# 编写page对象
def to_new_page(self):
""" 点击按钮,跳转到新的页面 """
WebDriverWait(self.driver).until(EC.visiblity_of_element_located((By.ID,index.list_fc))
handles_index = self.driver.window_handles # 修改了window_handles,和window_handles方法重名
self.click(index.list_fc)
self.is_open_new_window(handles_index)
# 报错"list" object is not callable
边栏推荐
- State machine in BGP
- Is there a really free applet?
- Idea announced a new default UI, which is too refreshing (including the application link)
- Redis - big key problem
- 记录一次RDS故障排除--RDS容量徒增
- LeetCode 40. Combined sum II
- The difference between session and cookies
- ROS create workspace
- In depth understanding of JUC concurrency (II) concurrency theory
- 构建学习tensorflow
猜你喜欢
随机推荐
Summary of WLAN related knowledge points
10 erreurs classiques de MySQL
分布式事务 :可靠消息最终一致性方案
重载全局和成员new/delete
Distributed transactions: the final consistency scheme of reliable messages
RestTemplate请求时设置请求头,请求参数,请求体。
Data science [viii]: SVD (I)
日志(常用的日志框架)
AWD学习
kali最新更新指南
LeetCode 283. Move zero
Monitoring uplink of VRRP
Hydration failed because the initial UI does not match what was rendered on the server.问题原因之一
Redis——大Key問題
Redis——缓存击穿、穿透、雪崩
TensorRT的数据格式定义详解
深入了解JUC并发(一)什么是JUC
Linked list (linear structure)
Invalid operation: Load into table ‘sources_orderdata‘ failed. Check ‘stl_load_errors‘ system table
数据科学【八】:SVD(一)


![Data science [9]: SVD (2)](/img/2c/f1a8c3ff34ff3f3cc6e26157a32bfd.png)






