python中怎么获取js的输出值_[已解决] Appium H5,python 调用 js 语句取值,打印出来为 NONE,如何才能获取 input 元素的值...

d7065981-c25a-455f-8fa0-836f687c62f9.png!large

如上图,js语句在控制台可以取到value值,但在python脚本中print出来却为NONE

class mailGroupChatTest(unittest.TestCase):

def setUp(self):

desired_caps = {}

desired_caps['platformName'] = GlobalVar.platformName

desired_caps['platformVersion'] = GlobalVar.platformVersion_7

desired_caps['deviceName'] = GlobalVar.deviceName

desired_caps['appPackage'] = GlobalVar.appPackage_7

desired_caps['appActivity'] = GlobalVar.appActivity_7

desired_caps['fullReset'] = 'false'

desired_caps['unicodeKeyboard'] = 'True'

desired_caps['resetKeyboard'] = 'True'

desired_caps['fastReset'] = 'false'

self.dr = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

def tearDown(self):

self.dr.quit()

def test_mailGroupChat(self):

actionEvent.login.go_loginPage(self) # 访问登录页

actionEvent.login.login(self, GlobalVar.wudi_email, GlobalVar.wudi_name) # wudi登录OA

js = 'document.getElementById("272dffca-edf3-4bcf-98f8-996180dff194").value'

ele = self.dr.execute_script(js)

print(ele)

if __name__ == '__main__':

suite = unittest.TestLoader().loadTestsFromTestCase(mailGroupChatTest)

unittest.TextTestRunner(verbosity=2).run(suite)

执行结果:

D:\AutoWork\Python\python.exe "D:\AutoWork\Pycharm\PyCharm Community Edition 2017.1.2\helpers\pycharm_jb_unittest_runner.py" --path D:/AutoWork/自动化测试项目/Milan_H5_Auto/test_case/debug_test.py

Testing started at 10:07 ...

Launching unittests with arguments python -m unittest D:/AutoWork/自动化测试项目/Milan_H5_Auto/test_case/debug_test.py in D:\AutoWork\自动化测试项目\Milan_H5_Auto\test_case

None

Ran 1 test in 45.708s

OK

Process finished with exit code 0

问题:

python调用js语句如何才能获取input属性元素的值

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值