如上图,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 属性元素的值