使用python+selenium做自动化测试,切换窗口时用到一个方法current_window_handle,但是这个方法调用时加括号却报错,一开始以为这是一个变量,但查了源代码发现这就是一个方法,方法在定义的时候是有参数self的,但使用方法却明确说明不用加括号,这个是什么意思呢?这个方法的源代码如下:@propertydef current_window_handle(self):
"""
Returns the handle of the current window.
:Usage:
driver.current_window_handle
"""
if self.w3c: return self.execute(Command.W3C_GET_CURRENT_WINDOW_HANDLE)['value'] else: return self.execute(Command.GET_CURRENT_WINDOW_HANDLE)['value']
添加回答
举报
0/150
提交
取消