我找不到android.webkit.WebView在我的本地应用程序中。在
通过将setWebContentsDebuggingEnabled设置为TRUE,然后在DevTools中打开webview,我可以检索username和password字段属性chrome://inspect/#设备在
我编写了运行应用程序的Python脚本:# -*- coding: utf-8 -*-
#!/usr/bin/python
import os
import unittest
import time, re
try:
import c as s
except:
ImportError
sys.stderr.write("Error: Cannot find the 'c.py' file")
from time import sleep
from appium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
class AndroidTestsUpdatedMoreOptions(unittest.TestCase):
@classmethod
def setUpClass(self):
"Setup for the test"
desired_caps = {}
desired_caps['browserName']=''
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4.2'
desired_caps['deviceName'] = 'karthikphone1'
desired_caps['app'] = s.APK_PATH
desired_caps['noReset'] = 'true'
desired_caps['fullReset'] = 'false'
desired_caps['appPackage'] = 'com.xxx.yyy'
desired_caps['app-activity'] = '.SplashActivity'
#desired_caps['newCommandTimeout'] = 5000
desired_caps['app-wait-activity'] = '.AuthorizationCodeActivity'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
def test_User_enters_credentials(self):
element = WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.ID, "toolbar")))
print (" ")
self.assertEqual('NATIVE_APP', self.driver.current_context)
elementUsername = WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.XPATH, '//*[@id="oauth2_authorization_email"]')))
elementUsername.send_keys(s.SANDBOX_USERNAME)
elementUsername.send_keys(Keys.RETURN)
print('USERNAME- pass')
elementPassword = WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.XPATH, '//*[@id="oauth2_authorization_password"]')))
elementPassword.send_keys(s.SANDBOX_PASSWORD)
elementPassword.send_keys(Keys.RETURN)
print('PASSWORD- pass')
print(' ')
#The tearDown() method runs after every test.
@classmethod
def tearDownClass(self):
"Tear down the test"
self.driver.quit()
#---START OF SCRIPT
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(AndroidTestsUpdatedMoreOptions)
unittest.TextTestRunner(verbosity=2).run(suite)
输出:
^{pr2}$
我哪里出错了??
有人能帮帮我吗!!!在
这些问题看起来很相似,但没有一个得到正确的答案。。在