当前位置:网站首页>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
边栏推荐
- 代码技巧——Controller参数注解@RequestParam
- FE - Eggjs 结合 Typeorm 出现连接不了数据库
- Learn about various joins in SQL and their differences
- New version of dedecms collection and release plug-in tutorial tool
- AWD学习
- 数据科学【九】:SVD(二)
- BGP报文详细解释
- Cglib agent - Code enhancement test
- js中正则表达式的使用
- Find the highest value of the current element Z-index of the page
猜你喜欢
Code skills - Controller Parameter annotation @requestparam
Shardingsphere JDBC
深入了解JUC并发(二)并发理论
Invalid operation: Load into table ‘sources_orderdata‘ failed. Check ‘stl_load_errors‘ system table
Summary of WLAN related knowledge points
Browser principle mind map
Hydration failed because the initial UI does not match what was rendered on the server. One of the reasons for the problem
Don't use the new WP collection. Don't use WordPress collection without update
Invalid operation: Load into table ‘sources_ orderdata‘ failed. Check ‘stl_ load_ errors‘ system table
Data science [9]: SVD (2)
随机推荐
奇葩pip install
Cglib代理-代码增强测试
MySQL的10大经典错误
Linear DP (split)
Data science [9]: SVD (2)
Idea announced a new default UI, which is too refreshing (including the application link)
Shardingsphere JDBC
IPv6 experiment and summary
BGP 路由優選規則和通告原則
日志(常用的日志框架)
VLAN experiment of switching technology
Hydration failed because the initial UI does not match what was rendered on the server. One of the reasons for the problem
Bgp Routing preference Rules and notice Principles
sudo提权
Sudo right raising
js中正则表达式的使用
Decryption skills of encrypted compressed files
LeetCode 83. Delete duplicate elements in the sorting linked list
Introduce two automatic code generators to help improve work efficiency
Name six schemes to realize delayed messages at one go