raceback (most recent call last):
File “debt666.py”, line 74, in test_app_launch
el = self.dr.find_element_by_android_uiautomator(‘new UiSelector().description(“账户中心”)’)
File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/appium/webdriver/webdriver.py”, line 110, in find_element_by_android_uiautomator
return self.find_element(by=By.ANDROID_UIAUTOMATOR, value=uia_string)
File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py”, line 745, in find_element
{‘using’: by, ‘value’: value})[‘value’]
File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py”, line 236, in execute
self.error_handler.check_response(response)
File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/appium/webdriver/errorhandler.py”, line 29, in check_response
raise wde
File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/appium/webdriver/errorhandler.py”, line 24, in check_response
super(MobileErrorHandler, self).check_response(response)
File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py”, line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.
my script is
coding = utf-8
import os
import unittest
from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction
from time import sleep
import yaml
from yaml import load, dump
from lib import time as tima
from lib.global_data import global_data_yaml_write
from lib.global_data import global_data_yaml_read
from lib.data_conversion import amount_to_digit
from lib.accounting import debit_amount
from lib.accounting import transfer_price
PATH = lambda p: op.path.abspath(
op.path.join(os.path.dirname(file), p)
)
class debt_assignment(unittest.TestCase):
@classmethod
def setUpClass(self):
desired_caps = {}
desired_caps['deviceName'] = 'B2T7N16812001216'
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '7.0'
desired_caps['appPackage'] = 'com.gclfax.app.android'
desired_caps['appActivity'] = 'com.uzmap.pkg.EntranceActivity'
self.dr = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
self.action = TouchAction(self.dr)
self.dr.implicitly_wait(15)
# 用户,base url等配置信息
configuration_yaml = "./data/configuration.yaml"
# self.configuration_data = yaml.load(open(configuration_yaml, 'r', encoding='utf-8'))
self.configuration_data = yaml.load(open(configuration_yaml, 'r'))
print(self.configuration_data)
self.username = self.configuration_data[1]['username']
self.password = self.configuration_data[1]['password']
print(self.username, self.password)
# 普通债权转让标的信息
debt_assignment_yaml = "./data/debt_assignment.yaml"
# self.debt_assignment_data = yaml.load(open(debt_assignment_yaml, 'r', encoding='utf-8'))
self.debt_assignment_data = yaml.load(open(debt_assignment_yaml, 'r'))
# print(self.debt_assignment_data)
@classmethod
def tearDownClass(self):
self.dr.quit()
# pass
def setUp(self):
print('TestCase starting-------')
def tearDown(self):
print('TestCase ending-------')
def test_app_launch(self):
print('App启动啦+_+')
sleep(5)
# self.dr.wait_activity('appActivity',10,1)
# 通过resource-id定位
# jingpin_loc = self.dr.find_element_by_id("com.lufax.android:id/tv_bottombar1")
# self.dr.wait_activity(jingpin_loc, 12, 2)
# self.assertIsNotNone(jingpin_loc)
# jingpin_loc.click()
# print('App启动正常凸^-^凸')
el = self.dr.find_element_by_android_uiautomator('new UiSelector().description("账户中心")')
print(el)
self.assertIsNotNone(el)
el.click()
sleep(3)
if name == ‘main’:
suite = unittest.TestSuite()
suite.addTest(debt_assignment(“test_app_launch”))
runner = unittest.TextTestRunner()
runner.run(suite)