selenium报错:'str' object has no attribute 'text'

在base里封装了获取文本框内容的方法

在page里调用此方法来获取错误提示框的内容

代码如下

# 获取文本信息 方法封装
def base_get_text(self, loc):
        return self.base_find(loc).text

# 获取错误提示信息
def page_get_error_info(self):
        return self.base_get_text(page.login_err_info).text

运行结果如下

AttributeError: 'str' object has no attribute 'text'

return self.base_get_text(page.login_err_info)
就可以了,去掉 .text