小编Cla*_*tte的帖子

AttributeError:“str”对象没有属性“text”错误

收到以下块的 AttributeError: 'str' 对象没有属性 'text' 错误:

 `version = driver.find_element_by_id('com.project.PROJECT:id/version').text
  print(version)
  for i in version:
     if 'Version : 1.2.0.133' == str(i):
         print('Step 46. NAS version is displayed correctly - PASS')
     else:
          print('Step 46. NAS version is incorrect - Fail')
 time.sleep(2)
 pass`
Run Code Online (Sandbox Code Playgroud)

也尝试过: if 'Version : 1.2.0.133' == i.text

还是行不通。

print(version)返回正确的值:版本:1.2.0.133

但我无法打印if value is true: print('Step 46. NAS version is displayed correctly - PASS')

正在向我发送垃圾邮件else print FAIL value

另外,如果我使用.textfor EC 等待也会返回错误。

谢谢

python selenium android attributes webdriver

1
推荐指数
1
解决办法
4290
查看次数

标签 统计

android ×1

attributes ×1

python ×1

selenium ×1

webdriver ×1