appium android webview,在使用Appium和Python的android原生应用的webview页面上找不到元素...

3a23422689b31ba36a7eb5a95aef2cd7.png

我找不到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}$

我哪里出错了??

有人能帮帮我吗!!!在

这些问题看起来很相似,但没有一个得到正确的答案。。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值