Commit da1c721a authored by Betty周薇薇's avatar Betty周薇薇

appui

parents
# Default ignored files
/shelf/
/workspace.xml
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="false" level="WARNING" enabled_by_default="false">
<option name="ignoredPackages">
<value>
<list size="0" />
</value>
</option>
</inspection_tool>
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="E303" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyStatementEffectInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredIdentifiers">
<list>
<option value="run.selenium" />
</list>
</option>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pythonProjec_app234.iml" filepath="$PROJECT_DIR$/.idea/pythonProjec_app234.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.11" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
# appium是由selenium团队二次打开的app自动化第三方库
# appium基于selenium
# app自动化测试跟web自动化唯一的区别
# app测试的是手机程序界面
# web测试的是网站的页面
#import time
# 导包
from appium import webdriver
from selenium.webdriver.common.by import By
# 配置手机的连接参数信息
# 字典的数据类型,键值对
desired_caps = {}
# 设备的名字
desired_caps["deviceName"] = "huawei"
# 系统的名字
desired_caps["platformName"] = "Android"
# app的名字
desired_caps["appPackage"] = "com.taobao.taobao"
# app的界面名字
desired_caps["appActivity"] = "com.taobao.tao.welcome.Welcome"
# desired_caps["appActivity"] = ".Settings$WifiSettingsActivity"
# 连接手机最基本的配置参数:设备,系统,app以及界面
# print(desired_caps)
# 发送链接请求,获取驱动对象
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities=desired_caps)
#time.sleep(5)
#driver.quit()
# appium是由selenium团队二次打开的app自动化第三方库
# appium基于selenium
# app自动化测试跟web自动化唯一的区别
# app测试的是手机程序界面
# web测试的是网站的页面
import time
# 导包
from appium import webdriver
from selenium.webdriver.common.by import By
# 配置手机的连接参数信息
# 字典的数据类型,键值对
desired_caps = {}
# 设备的名字
desired_caps["deviceName"] = "127.0.0.1:62001"
# 系统的名字
desired_caps["platformName"] = "Android"
# app的名字
desired_caps["appPackage"] = "com.android.settings"
# app的界面名字
desired_caps["appActivity"] = ".Settings"
# desired_caps["appActivity"] = ".Settings$WifiSettingsActivity"
# 连接手机最基本的配置参数:设备,系统,app以及界面
print(desired_caps)
# 发送链接请求,获取驱动对象
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities=desired_caps)
# 定位元素,操作元素
# driver.find_element(By.XPATH, '//*[@text="显示"]').click()
# driver.find_element(By.XPATH, '//*[@text="声音"]').click()
# # app的界面跳转之后,由于代码脚本执行速度太快,还没跳转之前就已经执行定位操作元素,所以找不到
# time.sleep(0.5)
# driver.find_element(By.XPATH, '//*[@text="手机铃声"]').click()
# 定位当前界面之外的元素
# app界面为了保证内存发挥比较极致,所有可操作的元素仅仅是当前界面存在的元素
# 如果app界面进行了切换,只能操作当前界面的元素
# driver.find_element(By.XPATH, '//*[@text="安全"]').click()
# 通过坐标定位:定位声音元素
# driver.tap([(144, 1615)], duration=100) # 左上角
# driver.tap([(208, 1658)], duration=100) # 右下角
time.sleep(5)
driver.quit()
# appium是由selenium团队二次打开的app自动化第三方库
# appium基于selenium
# app自动化测试跟web自动化唯一的区别
# app测试的是手机程序界面
# web测试的是网站的页面
import time
# 导包
from appium import webdriver
from selenium.webdriver.common.by import By
# 配置手机的连接参数信息
# 字典的数据类型,键值对
desired_caps = {}
# 设备的名字
desired_caps["deviceName"] = "mjdqt8nvbmob9hsg"
# 系统的名字
desired_caps["platformName"] = "Android"
# app的名字
desired_caps["appPackage"] = "com.ifeng.news2"
# app的界面名字
desired_caps["appActivity"] = ".activity.IfengTabMainActivity"
# desired_caps["appActivity"] = ".Settings$WifiSettingsActivity"
# 连接手机最基本的配置参数:设备,系统,app以及界面
# print(desired_caps)
# 发送链接请求,获取驱动对象
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities=desired_caps)
# - 安装应用
# - install_app("app安装包的绝对路径")
driver.install_app(r'D:\测试相关\脚本\ui自动化云测平台\凤凰新闻.apk')
# - 卸载应用
# - remove_app("应用的包名")
# driver.remove_app('io.manong.developerdaily')
# - 判断应用是否已经安装
# - is_app_installed("应用的包名")
# print(driver.is_app_installed('io.manong.developerdaily'))
# if driver.is_app_installed('io.manong.developerdaily'):
# driver.remove_app("io.manong.developerdaily")
# print("app卸载完成")
# else:
# driver.install_app(r'C:\Users\86188\Desktop\234期app自动化\day02\toutiao.apk')
# print("app安装完成")
# - 获取当前操作的应用包名
# - current_package
print(driver.current_package)
# - 获取当前操作的界面名字
# - current_activity
print(driver.current_activity)
# - 获取当面界面的xml源码
# - page_source
print(driver.page_source)
time.sleep(5)
driver.quit()
# appium是由selenium团队二次打开的app自动化第三方库
# appium基于selenium
# app自动化测试跟web自动化唯一的区别
# app测试的是手机程序界面
# web测试的是网站的页面
import time
# 导包
from appium import webdriver
from selenium.webdriver.common.by import By
# 配置手机的连接参数信息
# 字典的数据类型,键值对
desired_caps = {}
# 设备的名字
desired_caps["deviceName"] = "127.0.0.1:62001"
# 系统的名字
desired_caps["platformName"] = "Android"
# app的名字
desired_caps["appPackage"] = "com.android.settings"
# app的界面名字
desired_caps["appActivity"] = ".Settings"
# desired_caps["appActivity"] = ".Settings$WifiSettingsActivity"
# 连接手机最基本的配置参数:设备,系统,app以及界面
# print(desired_caps)
# 发送链接请求,获取驱动对象
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities=desired_caps)
# el1 = driver.find_element(By.XPATH, '//*[@text="显示"]')
el1 = driver.find_element(By.XPATH,'//*[@test="显示"]')
el1.get_attribute("class")
# # - 获取元素的文本内容
# # - text
# print(el1.text)
# # - 获取元素的属性值
# # - get_attribute("属性名字")
# print(el1.get_attribute('class'))
# # - 获取元素的坐标
# # - location
# print(el1.location)
# # - 获取元素的宽高(大小)
# # - size
# print(el1.size)
# # - 对元素进行点击操作
# # - click()
# el1.click()
# - 对元素进行输入操作
# - send_keys("输入的内容")
driver.tap([(984, 56)], duration=100)
driver.find_element(By.ID, 'android:id/search_src_text').send_keys("安全")
time.sleep(5)
driver.quit()
# appium是由selenium团队二次打开的app自动化第三方库
# appium基于selenium
# app自动化测试跟web自动化唯一的区别
# app测试的是手机程序界面
# web测试的是网站的页面
import time
# 导包
from appium import webdriver
from selenium.webdriver.common.by import By
# 配置手机的连接参数信息
# 字典的数据类型,键值对
desired_caps = {}
# 设备的名字
desired_caps["deviceName"] = "127.0.0.1:62001"
# 系统的名字
desired_caps["platformName"] = "Android"
# app的名字
desired_caps["appPackage"] = "com.android.settings"
# app的界面名字
desired_caps["appActivity"] = ".Settings"
# desired_caps["appActivity"] = ".Settings$WifiSettingsActivity"
# 连接手机最基本的配置参数:设备,系统,app以及界面
# print(desired_caps)
# 发送链接请求,获取驱动对象
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities=desired_caps)
# 通过元素的相对位置进行滚动
# el1 = driver.find_element(By.XPATH, '//*[@text="应用"]')
# el2 = driver.find_element(By.XPATH, '//*[@text="蓝牙"]')
# # 进行滚动
# driver.scroll(el1, el2)
# driver.find_element(By.XPATH, '//*[@text="安全"]').click()
# 通过坐标进行开始和结束滚动
driver.swipe(144, 1759, 144, 943)
driver.find_element(By.XPATH, '//*[@text="安全"]').click()
time.sleep(5)
driver.quit()
# appium是由selenium团队二次打开的app自动化第三方库
# appium基于selenium
# app自动化测试跟web自动化唯一的区别
# app测试的是手机程序界面
# web测试的是网站的页面
import time
# 导包
from appium import webdriver
from selenium.webdriver.common.by import By
# 配置手机的连接参数信息
# 字典的数据类型,键值对
desired_caps = {}
# 设备的名字
desired_caps["deviceName"] = "127.0.0.1:62001"
# 系统的名字
desired_caps["platformName"] = "Android"
# app的名字
desired_caps["appPackage"] = "com.android.launcher3"
# app的界面名字
desired_caps["appActivity"] = ".launcher3.Launcher"
# desired_caps["appActivity"] = ".Settings$WifiSettingsActivity"
# 连接手机最基本的配置参数:设备,系统,app以及界面
# print(desired_caps)
# 发送链接请求,获取驱动对象
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities=desired_caps)
# el1 = driver.find_element(By.XPATH, "//*[@text='浏览器']")
# el2 = driver.find_element(By.XPATH, "//*[@text='开发者头条']")
# print(el1.text)
# print(el2.text)
# driver.drag_and_drop(el1, el2)
driver.drag_and_drop(driver.find_element(By.XPATH, "//*[@text='浏览器']"), driver.find_element(By.XPATH, "//*[@text='开发者头条']"))
time.sleep(5)
driver.quit()
# appium是由selenium团队二次打开的app自动化第三方库
# appium基于selenium
# app自动化测试跟web自动化唯一的区别
# app测试的是手机程序界面
# web测试的是网站的页面
import time
# 导包
from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.common.by import By
# 配置手机的连接参数信息
# 字典的数据类型,键值对
desired_caps = {}
# 设备的名字
desired_caps["deviceName"] = "127.0.0.1:62001"
# 系统的名字
desired_caps["platformName"] = "Android"
# app的名字
desired_caps["appPackage"] = "com.android.settings"
# app的界面名字
desired_caps["appActivity"] = ".Settings"
# desired_caps["appActivity"] = ".Settings$WifiSettingsActivity"
# 连接手机最基本的配置参数:设备,系统,app以及界面
# print(desired_caps)
# 发送链接请求,获取驱动对象
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities=desired_caps)
action = TouchAction(driver)
el1 = driver.find_element(By.XPATH, '//*[@text="应用"]')
el2 = driver.find_element(By.XPATH, '//*[@text="蓝牙"]')
# 通过事件链的方式进行滚动操作
# press:按下
# wait:按下的时间毫秒
# move_to:移动
action.press(el1).wait(200).move_to(el2)
# 事件链操作完成之后需要松手:release()
action.release()
# 提交事件链
action.perform()
# 点击安全进入图案界面
time.sleep(0.5)
driver.find_element(By.XPATH, '//*[@text="安全"]').click()
time.sleep(0.5)
driver.find_element(By.XPATH, '//*[@text="屏幕锁定"]').click()
time.sleep(0.5)
driver.find_element(By.XPATH, '//*[@text="图案"]').click()
time.sleep(0.5)
# 通过坐标绘制图案
action.press(x=210, y=900).wait(100) \
.move_to(x=539, y=900) \
.wait(100).move_to(x=867, y=900) \
.wait(100).move_to(x=539, y=1230) \
.wait(100).move_to(x=210, y=1562) \
.wait(100).move_to(x=539, y=1560) \
.wait(100).move_to(x=867, y=1558).wait(100)
# 松手操作
action.release()
# 提交事件链
action.perform()
driver.find_element(By.XPATH, '//*[@text="继续"]').click()
time.sleep(0.5)
# 第二次:通过坐标绘制图案
action.press(x=210, y=900).wait(100) \
.move_to(x=539, y=900) \
.wait(100).move_to(x=867, y=900) \
.wait(100).move_to(x=539, y=1230) \
.wait(100).move_to(x=210, y=1562) \
.wait(100).move_to(x=539, y=1560) \
.wait(100).move_to(x=867, y=1558).wait(100)
# 松手操作
action.release()
# 提交事件链
action.perform()
driver.find_element(By.XPATH, '//*[@text="确认"]').click()
time.sleep(0.5)
driver.find_element(By.XPATH, '//*[@text="完成"]').click()
# adb shell dumpsys window windows | findstr mFocusedApp
time.sleep(5)
driver.quit()
# appium是由selenium团队二次打开的app自动化第三方库
# appium基于selenium
# app自动化测试跟web自动化唯一的区别
# app测试的是手机程序界面
# web测试的是网站的页面
import time
# 导包
from appium import webdriver
from selenium.webdriver.common.by import By
# 配置手机的连接参数信息
# 字典的数据类型,键值对
desired_caps = {}
# 设备的名字
desired_caps["deviceName"] = "127.0.0.1:62001"
# 系统的名字
desired_caps["platformName"] = "Android"
# app的名字
desired_caps["appPackage"] = "com.android.settings"
# app的界面名字
desired_caps["appActivity"] = ".Settings"
# 发送链接请求,获取驱动对象
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities=desired_caps)
# 获取时间
print(driver.device_time) # 2023-11-06T18:41:10+08:00
# 获取分辨率
print(driver.get_window_size()) # {'width': 1080, 'height': 1920}
# 获取手机的网络信息
print(driver.network_connection) # 返回一个数值:6=移动网+wife
# 设置网络信息
driver.set_network_connection(2) # 注意:已经开启的网络不会重复开启
time.sleep(1)
print(driver.network_connection)
# 打开手机的通知栏
time.sleep(2)
driver.open_notifications()
# 截图
driver.save_screenshot("123.png")
time.sleep(5)
driver.quit()
import pytest
from selenium.webdriver.common.by import By
import time
from common.driver import get_app_driver
from common.pom import LoginPage
from common.util import get_csv_data
@pytest.mark.parametrize("username,password",get_csv_data())
def test_login(username,password):
#driver = get_app_driver()
login_page = LoginPage()
login_page.login(username,password)
# time.sleep(0.5)
# driver.find_element(By.XPATH,'//*[@text="同意"]').click()
# time.sleep(0.5)
# driver.find_element(By.XPATH,'//*[@text="知道了"]').click()
# time.sleep(0.5)
# driver.find_element(By.XPATH,'//*[@text="允许"]').click()
# time.sleep(0.5)
# driver.find_element(By.XPATH,'//*[@text="未登录"]').click()
# time.sleep(0.5)
# driver.find_element(By.XPATH,'//*[@text="登录"]').click()
# time.sleep(0.5)
# driver.find_element(By.XPATH,'//*[@text="账号密码登录"]').click()
# time.sleep(0.5)
# driver.find_element(By.XPATH,'//*[@text="手机号/邮箱账号"]').send_keys("13760437542")
# driver.find_element(By.XPATH,'//*[@text="密码"]').send_keys("woaita330808+")
# driver.find_element(By.XPATH,'//*[@text="登 录"]').click()
# time.sleep(3)
# msg = driver.find_element(By.ID,'com.ifeng.news2:id/txt_personal_page').text
# print(msg)
# if msg == "个人主页":
# print(msg)
# assert msg == "个人主页"
# else:
# print("登录失败!!!")
#
#
# time.sleep(3)
# driver.quit()
from appium import webdriver
import time
from selenium.webdriver.common.by import By
desired_caps={}
desired_caps['platformName']='Android'
desired_caps['deviceName'] ='HUAWEI'
desired_caps['appPackage']='com.ifeng.news2'
desired_caps['appActivity']='.activity.IfengTabMainActivity'
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub",desired_capabilities=desired_caps)
time.sleep(0.5)
driver.find_element(By.XPATH,'//*[@text="同意"]').click()
time.sleep(0.5)
driver.find_element(By.XPATH,'//*[@text="知道了"]').click()
time.sleep(0.5)
driver.find_element(By.XPATH,'//*[@text="允许"]').click()
time.sleep(0.5)
driver.find_element(By.XPATH,'//*[@text="未登录"]').click()
time.sleep(0.5)
driver.find_element(By.XPATH,'//*[@text="登录"]').click()
time.sleep(0.5)
driver.find_element(By.XPATH,'//*[@text="账号密码登录"]').click()
time.sleep(0.5)
driver.find_element(By.XPATH,'//*[@text="手机号/邮箱账号"]').send_keys("13760437542")
driver.find_element(By.XPATH,'//*[@text="密码"]').send_keys("woaita330808+")
driver.find_element(By.XPATH,'//*[@text="登 录"]').click()
time.sleep(3)
msg = driver.find_element(By.ID,'com.ifeng.news2:id/txt_personal_page').text
print(msg)
if msg == "个人主页":
print(msg)
assert msg == "个人主页"
else:
print("登录失败!!!")
time.sleep(3)
driver.quit()
\ No newline at end of file
from selenium.webdriver.common.by import By
from appium import webdriver
import time
from appium.webdriver.common.touch_action import TouchAction
def get_app_driver():
print("进入get_app_driver================")
desired_caps = {}
desired_caps['platformName'] = 'Android'
# desired_caps['deviceName'] = 'huawei'
desired_caps['deviceName'] = 'mjdqt8nvbmob9hsg'
desired_caps['appPackage'] = 'com.ifeng.news2'
desired_caps['appActivity'] = '.activity.IfengTabMainActivity'
desired_caps['skipServerInstallation'] = True
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_capabilities=desired_caps)
return driver
\ No newline at end of file
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from common.driver import get_app_driver
class KeyWord:
def __init__(self, driver, *args):
self.driver = driver
def wait(self, func,*args):
return WebDriverWait(self.driver, 5).until(func)
def find_element(self, by, value, need_wait=False,*args):
def f(driver, *args):
if driver.find_element(by, value).text:
msg = driver.find_element(by, value).text
if need_wait: # 如果有实际结果文本信息
# 当元素存在,但是没有任何内容时,需要进行空值替换,直到有内容获取返回
return msg.replace(" ", "")
else:
return True # 直接成功(没有获取实际结果的内容直接定位元素)
else:
return True
self.wait(f) # 通过self对象,调用类方法出发显式等待
return self.driver.find_element(by, value) # 通过selenium本身元素定位方法进行等待完毕之后再定位
# def click(self, loc: str, by=By.XPATH, *args):
# el1 = self.find_element(by, loc)
# # selenium原生的点击方法click()
# el1.click()
def click(self, loc:str, by, *args):
el1 = self.find_element(by,loc)
el1.click()
# 输入关键字封装
def input(self, loc: str, by=By.XPATH, content=""):
el1 = self.find_element(by, loc)
el1.send_keys(content)
def gettext(self,loc: str,*args):
el1 = self.find_element(By.ID,loc).text
return el1
def assert_text(self,loc:str,text:str,*args):
el_text=self.gettext(loc)
assert text == el_text
print(text+"断言成功")
# 强制等待
def sleep(self, x,*args):
time.sleep(x)
def swipe(self,start_x:int,start_y:int,end_x:int,end_y:int,duration:int =0):
self.driver.swipe(start_x,start_y,end_x,end_y)
def tap(self, positions: list, duration:int,*args):
self.driver.tap(positions, duration)
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from common.driver import get_app_driver
import time
class BasePage:
driver = get_app_driver()
def __int__(self, driver):
self.driver = driver
def wait(self, func):
return WebDriverWait(self.driver,5).until(func)
def find_element(self, by, value, need_wait=False):
def f(driver):
if driver.find_element(by,value).text:
msg = driver.find_element(by,value).text
if need_wait:
return msg
else:
return True
else:
return True
self.wait(f)
return self.driver.find_element(by, value)
class LoginPage(BasePage):
#time.sleep(0.5)
btn_agree = (By.XPATH,'//*[@text="同意"]')
#time.sleep(0.5)
btn_know = (By.XPATH,'//*[@text="知道了"]')
#time.sleep(0.5)
btn_ok = (By.XPATH,'//*[@text="允许"]')
#time.sleep(0.5)
btn_not_login = (By.XPATH,'//*[@text="未登录"]')
#time.sleep(0.5)
btn_login = (By.XPATH,'//*[@text="登录"]')
#time.sleep(0.5)
btn_change_login = (By.XPATH,'//*[@text="账号密码登录"]')
#time.sleep(0.5)
btn_mobile = (By.XPATH,'//*[@text="手机号/邮箱账号"]')
btn_password = (By.XPATH,'//*[@text="密码"]')
btn_login_button = (By.XPATH,'//*[@text="登 录"]')
#time.sleep(3)
btn_personal = (By.ID,'com.ifeng.news2:id/txt_personal_page')
def login(self,username,password):
self.find_element(*self.btn_agree).click()
self.find_element(*self.btn_know).click()
self.find_element(*self.btn_ok).click()
self.find_element(*self.btn_not_login).click()
self.find_element(*self.btn_login).click()
self.find_element(*self.btn_change_login).click()
self.find_element(*self.btn_mobile).send_keys(username)
self.find_element(*self.btn_password).send_keys(password)
self.find_element(*self.btn_login_button).click()
msg = self.find_element(*self.btn_personal).text
print(msg)
import csv
def get_csv_data():
list1=[]
c1=csv.reader(open(r"D:\测试相关\脚本\ui自动化云测平台\pythonProjec_app234\data\后台登录数据内容.csv", encoding="UTF-8"))
for i in c1:
list1.append(i)
return list1
\ No newline at end of file
import logging
import pytest
from pytest_xlsx.file import XlsxItem
from common.driver import get_app_driver
from common.ktd import KeyWord
def pytest_xlsx_run_step(item:XlsxItem):
logging.warning("进入python_xlsx_run_step")
driver = item.usefixtures["get_driver"]
kw = KeyWord(driver)
step = item.current_step
key = step['标记']
args = [step['内容'],step['列1'],step['列2'],step['列3']]
if key == "tap":
args[0] = eval(args[0])
print("进入args[0]======================="+str(args[0]))
if args[-1] is None:
print("进入args[-1]==============")
args.pop()
logging.warning(f"关键字:{key},关键字实参内容:{args}")
func = getattr(kw,key)
func(*args)
@pytest.fixture(scope="session")
def get_driver():
print("进入get_driver-------------------")
driver_login = get_app_driver()
yield driver_login
#driver_login.install_app(r'D:\测试相关\脚本\ui自动化云测平台\凤凰新闻.apk')
# @pytest.fixture(scope="session")
# def go_login_kdt():
# print("进入go_login_kdt")
# driver_login = get_app_driver()
# kw = KeyWord(driver_login)
# kw.click('//*[@text="同意"]')
# kw.click('//*[@text="知道了"]')
# kw.click('//*[@text="允许"]')
# kw.click('//*[@text="未登录"]')
# kw.click('//*[@text="登录"]')
# kw.click('//*[@text="账号密码登录"]')
# kw.input('//*[@text="手机号/邮箱账号"]','13760437542')
# kw.input('//*[@text="密码"]','woaita330808+')
# kw.click('//*[@text="登 录"]')
# kw.assert_text('com.ifeng.news2:id/txt_personal_page','个人主页')
# yield kw
pytest
pytest-html
pytest-xdist
pytest-ordering
pytest-rerunfailures
pytest-base-url
allure-pytest
selenium
csv
13760437542,woaita330808+
\ No newline at end of file
INFO 2024-02-21 19:29:20 [pytest_result_log:104] : --Start: testcases/test_app_login.xlsx::login::test_login---
ERROR 2024-02-21 19:29:22 [pytest_result_log:171] : test status is FAILED (testcases/test_app_login.xlsx::login::test_login): Please review verbose content
INFO 2024-02-21 19:29:22 [pytest_result_log:109] : ---End: testcases/test_app_login.xlsx::login::test_login----
INFO 2024-02-21 19:29:22 [pytest_result_log:104] : ---Start: testcases/test_app_login.xlsx::login::test_news---
ERROR 2024-02-21 19:29:22 [pytest_result_log:171] : test status is FAILED (testcases/test_app_login.xlsx::login::test_news): Please review verbose content
INFO 2024-02-21 19:29:22 [pytest_result_log:109] : ----End: testcases/test_app_login.xlsx::login::test_news----
import time
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.common.by import By
from appium import webdriver
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['deviceName'] = 'huawei'
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = '.Settings'
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_capabilities=desired_caps)
# etl1=driver.find_element(By.XPATH,'//*[@text="工具"]')
# etl1.click()
# time.sleep(1)
# etl2=driver.find_element(By.XPATH,'//*[@test="设置"]')
# etl2.click()
# time.sleep(1)
etl3 = driver.find_element(By.XPATH,'//*[@text="应用"]')
etl4 = driver.find_element(By.XPATH,'//*[@text="蓝牙"]')
time.sleep(1)
action = TouchAction(driver)
action.press(etl3).wait(200).move_to(etl4)
action.release()
action.perform()
time.sleep(1)
etl5 = driver.find_element(By.XPATH,'//*[@text="安全"]')
etl5.click()
time.sleep(1)
etl6 = driver.find_element(By.XPATH,'//*[@text="屏幕锁定"]')
etl6.click()
time.sleep(1)
etl7 = driver.find_element(By.XPATH,'//*[@text="图案"]')
etl7.click()
time.sleep(1)
action.press(x=427, y=1809).wait(100) \
.move_to(x=1076, y=1805) \
.wait(100).move_to(x=1737, y=1805) \
.wait(100).move_to(x=1092, y=2466) \
.wait(100).move_to(x=427, y=3123) \
.wait(100).move_to(x=1080, y=3119) \
.wait(100).move_to(x=1745, y=3119).wait(100)
# 松手操作
action.release()
# 提交事件链
action.perform()
driver.find_element(By.XPATH,'//*[@text="继续"]').click()
time.sleep(1)
action.press(x=427, y=1809).wait(100) \
.move_to(x=1076, y=1805) \
.wait(100).move_to(x=1737, y=1805) \
.wait(100).move_to(x=1092, y=2466) \
.wait(100).move_to(x=427, y=3123) \
.wait(100).move_to(x=1080, y=3119) \
.wait(100).move_to(x=1745, y=3119).wait(100)
# 松手操作
action.release()
# 提交事件链
action.perform()
driver.find_element(By.XPATH, '//*[@text="确认"]').click()
time.sleep(0.5)
driver.find_element(By.XPATH, '//*[@text="完成"]').click()
time.sleep(5)
driver.quit()
\ No newline at end of file
import os
import pytest
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_hi('PyCharm')
pytest.main()
os.system("allure generate ./report/report/ -o ./report/allure-report/ --clean")
[pytest]
addopts = -vs --alluredir=./report/report --clean-alluredir -W ignore
log_file = D:\测试相关\脚\ui自动化云测平台\pythonProjec_app234\log/pytest.log
log_file_level = info
log_file_format = %(levelname)-8s %(asctime)s [%(name)s:%(lineno)s] : %(message)s
log_file_date_format = %Y-%m-%d %H:%M:%S
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
INFO pytest_result_log:plugin.py:104 --Start: testcases/test_app_login.xlsx::login::test_login---
INFO pytest_result_log:plugin.py:109 ---End: testcases/test_app_login.xlsx::login::test_login----
\ No newline at end of file
INFO pytest_result_log:plugin.py:104 ---Start: testcases/test_app_login.xlsx::login::test_news---
INFO pytest_result_log:plugin.py:109 ----End: testcases/test_app_login.xlsx::login::test_news----
\ No newline at end of file
"Epic","Feature","Story","FAILED","BROKEN","PASSED","SKIPPED","UNKNOWN"
"","","","0","2","0","0","0"
{
"uid" : "b1a8273437954620fa374b796ffaacdd",
"children" : [ {
"name" : "test_login",
"uid" : "b6ab9e10fbdef993",
"parentUid" : "b1a8273437954620fa374b796ffaacdd",
"status" : "broken",
"time" : {
"start" : 1708514960669,
"stop" : 1708514962830,
"duration" : 2161
},
"flaky" : false,
"parameters" : [ ]
}, {
"name" : "test_news",
"uid" : "4a9b9ad4ef7ef157",
"parentUid" : "b1a8273437954620fa374b796ffaacdd",
"status" : "broken",
"time" : {
"start" : 1708514962833,
"stop" : 1708514962833,
"duration" : 0
},
"flaky" : false,
"parameters" : [ ]
} ],
"name" : "behaviors"
}
\ No newline at end of file
"Category","FAILED","BROKEN","PASSED","SKIPPED","UNKNOWN"
"Test defects","0","2","0","0","0"
{
"uid" : "4b4757e66a1912dae1a509f688f20b0f",
"children" : [ {
"name" : "Test defects",
"children" : [ {
"name" : "selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)",
"children" : [ {
"name" : "test_login",
"uid" : "b6ab9e10fbdef993",
"parentUid" : "f197da8e833f65b5c025c0663e0c54c8",
"status" : "broken",
"time" : {
"start" : 1708514960669,
"stop" : 1708514962830,
"duration" : 2161
},
"flaky" : false,
"parameters" : [ ]
}, {
"name" : "test_news",
"uid" : "4a9b9ad4ef7ef157",
"parentUid" : "f197da8e833f65b5c025c0663e0c54c8",
"status" : "broken",
"time" : {
"start" : 1708514962833,
"stop" : 1708514962833,
"duration" : 0
},
"flaky" : false,
"parameters" : [ ]
} ],
"uid" : "f197da8e833f65b5c025c0663e0c54c8"
} ],
"uid" : "bdbf199525818fae7a8651db9eafe741"
} ],
"name" : "categories"
}
\ No newline at end of file
{
"uid" : "83edc06c07f9ae9e47eb6dd1b683e4e2",
"children" : [ {
"name" : "testcases.test_app_login",
"children" : [ {
"name" : "test_login",
"uid" : "b6ab9e10fbdef993",
"parentUid" : "3223cde26458aa9070036ac7c36786a3",
"status" : "broken",
"time" : {
"start" : 1708514960669,
"stop" : 1708514962830,
"duration" : 2161
},
"flaky" : false,
"parameters" : [ ]
}, {
"name" : "test_news",
"uid" : "4a9b9ad4ef7ef157",
"parentUid" : "3223cde26458aa9070036ac7c36786a3",
"status" : "broken",
"time" : {
"start" : 1708514962833,
"stop" : 1708514962833,
"duration" : 0
},
"flaky" : false,
"parameters" : [ ]
} ],
"uid" : "testcases.test_app_login"
} ],
"name" : "packages"
}
\ No newline at end of file
"Status","Name","Duration in ms","Description"
"broken","testcases.test_app_login.login#test_login","2161",""
"broken","testcases.test_app_login.login#test_news","0",""
{
"uid" : "98d3104e051c652961429bf95fa0b5d6",
"children" : [ {
"name" : "testcases",
"children" : [ {
"name" : "test_app_login",
"children" : [ {
"name" : "login",
"children" : [ {
"name" : "test_login",
"uid" : "b6ab9e10fbdef993",
"parentUid" : "979fe0d47bd105831b3cfb5148424ea4",
"status" : "broken",
"time" : {
"start" : 1708514960669,
"stop" : 1708514962830,
"duration" : 2161
},
"flaky" : false,
"parameters" : [ ]
}, {
"name" : "test_news",
"uid" : "4a9b9ad4ef7ef157",
"parentUid" : "979fe0d47bd105831b3cfb5148424ea4",
"status" : "broken",
"time" : {
"start" : 1708514962833,
"stop" : 1708514962833,
"duration" : 0
},
"flaky" : false,
"parameters" : [ ]
} ],
"uid" : "979fe0d47bd105831b3cfb5148424ea4"
} ],
"uid" : "da75468b83c12e013667380d64c95ec7"
} ],
"uid" : "b51346658ccdb9db01a6b5f6c12deab1"
} ],
"name" : "suites"
}
\ No newline at end of file
{
"uid" : "4a9b9ad4ef7ef157",
"name" : "test_news",
"fullName" : "testcases.test_app_login.login#test_news",
"historyId" : "376ab601bc6f081b2e4b7d6a898aa21d",
"time" : {
"start" : 1708514962833,
"stop" : 1708514962833,
"duration" : 0
},
"status" : "broken",
"statusMessage" : "selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)",
"statusTrace" : "C:\\Python\\Python311\\Lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py:244: WebDriverException\nMessage: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)",
"flaky" : false,
"beforeStages" : [ ],
"testStage" : {
"status" : "broken",
"statusMessage" : "selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)",
"statusTrace" : "C:\\Python\\Python311\\Lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py:244: WebDriverException\nMessage: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)",
"steps" : [ ],
"attachments" : [ {
"uid" : "a8b0f5d88f2e2b19",
"name" : "log",
"source" : "a8b0f5d88f2e2b19.txt",
"type" : "text/plain",
"size" : 203
} ],
"parameters" : [ ],
"stepsCount" : 0,
"hasContent" : true,
"shouldDisplayMessage" : true,
"attachmentsCount" : 1
},
"afterStages" : [ ],
"labels" : [ {
"name" : "parentSuite",
"value" : "testcases"
}, {
"name" : "suite",
"value" : "test_app_login"
}, {
"name" : "subSuite",
"value" : "login"
}, {
"name" : "host",
"value" : "DESKTOP-MKSHDA6"
}, {
"name" : "thread",
"value" : "6444-MainThread"
}, {
"name" : "framework",
"value" : "pytest"
}, {
"name" : "language",
"value" : "cpython3"
}, {
"name" : "package",
"value" : "testcases.test_app_login"
}, {
"name" : "resultFormat",
"value" : "allure2"
} ],
"parameters" : [ ],
"links" : [ ],
"hidden" : false,
"retry" : false,
"extra" : {
"severity" : "normal",
"retries" : [ ],
"categories" : [ {
"name" : "Test defects",
"matchedStatuses" : [ ],
"flaky" : false
} ],
"tags" : [ ]
},
"source" : "4a9b9ad4ef7ef157.json",
"parameterValues" : [ ]
}
\ No newline at end of file
{
"uid" : "b6ab9e10fbdef993",
"name" : "test_login",
"fullName" : "testcases.test_app_login.login#test_login",
"historyId" : "006b1722c7f3feea0d7d6db073062845",
"time" : {
"start" : 1708514960669,
"stop" : 1708514962830,
"duration" : 2161
},
"status" : "broken",
"statusMessage" : "selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)",
"statusTrace" : "C:\\Python\\Python311\\Lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py:244: WebDriverException\nMessage: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)",
"flaky" : false,
"beforeStages" : [ ],
"testStage" : {
"status" : "broken",
"statusMessage" : "selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)",
"statusTrace" : "C:\\Python\\Python311\\Lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py:244: WebDriverException\nMessage: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)",
"steps" : [ ],
"attachments" : [ {
"uid" : "a50fc19b4df0dd88",
"name" : "log",
"source" : "a50fc19b4df0dd88.txt",
"type" : "text/plain",
"size" : 203
} ],
"parameters" : [ ],
"stepsCount" : 0,
"hasContent" : true,
"shouldDisplayMessage" : true,
"attachmentsCount" : 1
},
"afterStages" : [ ],
"labels" : [ {
"name" : "parentSuite",
"value" : "testcases"
}, {
"name" : "suite",
"value" : "test_app_login"
}, {
"name" : "subSuite",
"value" : "login"
}, {
"name" : "host",
"value" : "DESKTOP-MKSHDA6"
}, {
"name" : "thread",
"value" : "6444-MainThread"
}, {
"name" : "framework",
"value" : "pytest"
}, {
"name" : "language",
"value" : "cpython3"
}, {
"name" : "package",
"value" : "testcases.test_app_login"
}, {
"name" : "resultFormat",
"value" : "allure2"
} ],
"parameters" : [ ],
"links" : [ ],
"hidden" : false,
"retry" : false,
"extra" : {
"severity" : "normal",
"retries" : [ ],
"categories" : [ {
"name" : "Test defects",
"matchedStatuses" : [ ],
"flaky" : false
} ],
"tags" : [ ]
},
"source" : "b6ab9e10fbdef993.json",
"parameterValues" : [ ]
}
\ No newline at end of file
{
"uid" : "ab17fc5a4eb3bca4b216b548c7f9fcbc",
"children" : [ {
"name" : "DESKTOP-MKSHDA6",
"children" : [ {
"name" : "6444-MainThread",
"children" : [ {
"name" : "test_login",
"uid" : "b6ab9e10fbdef993",
"parentUid" : "35a70bf50fb4a2ebfc199384c5f21ef0",
"status" : "broken",
"time" : {
"start" : 1708514960669,
"stop" : 1708514962830,
"duration" : 2161
},
"flaky" : false,
"parameters" : [ ]
}, {
"name" : "test_news",
"uid" : "4a9b9ad4ef7ef157",
"parentUid" : "35a70bf50fb4a2ebfc199384c5f21ef0",
"status" : "broken",
"time" : {
"start" : 1708514962833,
"stop" : 1708514962833,
"duration" : 0
},
"flaky" : false,
"parameters" : [ ]
} ],
"uid" : "35a70bf50fb4a2ebfc199384c5f21ef0"
} ],
"uid" : "d375ea80cb48e53379a497e900e13f5a"
} ],
"name" : "timeline"
}
\ No newline at end of file
launch_status failed=0 1708514963000000000
launch_status broken=2 1708514963000000000
launch_status passed=0 1708514963000000000
launch_status skipped=0 1708514963000000000
launch_status unknown=0 1708514963000000000
launch_time duration=2164 1708514963000000000
launch_time min_duration=0 1708514963000000000
launch_time max_duration=2161 1708514963000000000
launch_time sum_duration=2161 1708514963000000000
launch_problems test_defects=2 1708514963000000000
launch_retries retries=0 1708514963000000000
launch_retries run=2 1708514963000000000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Allure Report summary mail</title>
</head>
<body>
Mail body
</body>
</html>
launch_status_failed 0
launch_status_broken 2
launch_status_passed 0
launch_status_skipped 0
launch_status_unknown 0
launch_time_duration 2164
launch_time_min_duration 0
launch_time_max_duration 2161
launch_time_sum_duration 2161
launch_problems_test_defects 2
launch_retries_retries 0
launch_retries_run 2
[ {
"data" : {
"Test defects" : 2
}
} ]
\ No newline at end of file
[ {
"data" : {
"duration" : 2164
}
} ]
\ No newline at end of file
[ {
"data" : {
"failed" : 0,
"broken" : 2,
"skipped" : 0,
"passed" : 0,
"unknown" : 0,
"total" : 2
}
} ]
\ No newline at end of file
{
"376ab601bc6f081b2e4b7d6a898aa21d" : {
"statistic" : {
"failed" : 0,
"broken" : 1,
"skipped" : 0,
"passed" : 0,
"unknown" : 0,
"total" : 1
},
"items" : [ {
"uid" : "4a9b9ad4ef7ef157",
"status" : "broken",
"statusDetails" : "selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)",
"time" : {
"start" : 1708514962833,
"stop" : 1708514962833,
"duration" : 0
}
} ]
},
"006b1722c7f3feea0d7d6db073062845" : {
"statistic" : {
"failed" : 0,
"broken" : 1,
"skipped" : 0,
"passed" : 0,
"unknown" : 0,
"total" : 1
},
"items" : [ {
"uid" : "b6ab9e10fbdef993",
"status" : "broken",
"statusDetails" : "selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)",
"time" : {
"start" : 1708514960669,
"stop" : 1708514962830,
"duration" : 2161
}
} ]
}
}
\ No newline at end of file
[ {
"data" : {
"run" : 2,
"retry" : 0
}
} ]
\ No newline at end of file
<!DOCTYPE html>
<html dir="ltr">
<head>
<meta charset="utf-8">
<title>Allure Report</title>
<link rel="favicon" href="favicon.ico?v=2">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="plugins/screen-diff/styles.css">
</head>
<body>
<div id="alert"></div>
<div id="content">
<span class="spinner">
<span class="spinner__circle"></span>
</span>
</div>
<div id="popup"></div>
<script src="app.js"></script>
<script src="plugins/behaviors/index.js"></script>
<script src="plugins/packages/index.js"></script>
<script src="plugins/screen-diff/index.js"></script>
</body>
</html>
'use strict';
allure.api.addTranslation('en', {
tab: {
behaviors: {
name: 'Behaviors'
}
},
widget: {
behaviors: {
name: 'Features by stories',
showAll: 'show all'
}
}
});
allure.api.addTranslation('ru', {
tab: {
behaviors: {
name: 'Функциональность'
}
},
widget: {
behaviors: {
name: 'Функциональность',
showAll: 'показать все'
}
}
});
allure.api.addTranslation('zh', {
tab: {
behaviors: {
name: '功能'
}
},
widget: {
behaviors: {
name: '特性场景',
showAll: '显示所有'
}
}
});
allure.api.addTranslation('de', {
tab: {
behaviors: {
name: 'Verhalten'
}
},
widget: {
behaviors: {
name: 'Features nach Stories',
showAll: 'Zeige alle'
}
}
});
allure.api.addTranslation('he', {
tab: {
behaviors: {
name: 'התנהגויות'
}
},
widget: {
behaviors: {
name: 'תכונות לפי סיפורי משתמש',
showAll: 'הצג הכול'
}
}
});
allure.api.addTranslation('br', {
tab: {
behaviors: {
name: 'Comportamentos'
}
},
widget: {
behaviors: {
name: 'Funcionalidades por história',
showAll: 'Mostrar tudo'
}
}
});
allure.api.addTab('behaviors', {
title: 'tab.behaviors.name', icon: 'fa fa-list',
route: 'behaviors(/)(:testGroup)(/)(:testResult)(/)(:testResultTab)(/)',
onEnter: (function (testGroup, testResult, testResultTab) {
return new allure.components.TreeLayout({
testGroup: testGroup,
testResult: testResult,
testResultTab: testResultTab,
tabName: 'tab.behaviors.name',
baseUrl: 'behaviors',
url: 'data/behaviors.json',
csvUrl: 'data/behaviors.csv'
});
})
});
allure.api.addWidget('widgets', 'behaviors', allure.components.WidgetStatusView.extend({
rowTag: 'a',
title: 'widget.behaviors.name',
baseUrl: 'behaviors',
showLinks: true
}));
\ No newline at end of file
'use strict';
allure.api.addTranslation('en', {
tab: {
packages: {
name: 'Packages'
}
}
});
allure.api.addTranslation('ru', {
tab: {
packages: {
name: 'Пакеты'
}
}
});
allure.api.addTranslation('zh', {
tab: {
packages: {
name: '包'
}
}
});
allure.api.addTranslation('de', {
tab: {
packages: {
name: 'Pakete'
}
}
});
allure.api.addTranslation('he', {
tab: {
packages: {
name: 'חבילות'
}
}
});
allure.api.addTranslation('br', {
tab: {
packages: {
name: 'Pacotes'
}
}
});
allure.api.addTab('packages', {
title: 'tab.packages.name', icon: 'fa fa-align-left',
route: 'packages(/)(:testGroup)(/)(:testResult)(/)(:testResultTab)(/)',
onEnter: (function (testGroup, testResult, testResultTab) {
return new allure.components.TreeLayout({
testGroup: testGroup,
testResult: testResult,
testResultTab: testResultTab,
tabName: 'tab.packages.name',
baseUrl: 'packages',
url: 'data/packages.json'
});
})
});
(function () {
var settings = allure.getPluginSettings('screen-diff', {diffType: 'diff'});
function renderImage(src) {
return '<div class="screen-diff__container">' +
'<img class="screen-diff__image" src="data/attachments/' + src + '">' +
'</div>';
}
function renderDiffContent(type, data) {
function findImage(name) {
if (data.testStage && data.testStage.attachments) {
return data.testStage.attachments.filter(function (attachment) {
return attachment.name === name;
})[0];
}
return null;
}
var diffImage = findImage('diff');
var actualImage = findImage('actual');
var expectedImage = findImage('expected');
if (!diffImage && !actualImage && !expectedImage) {
return '<span>Diff, actual and expected image have not been provided.</span>';
}
if (type === 'diff') {
if (!diffImage) {
return renderImage(actualImage.source);
}
return renderImage(diffImage.source);
}
if (type === 'overlay') {
return '<div class="screen-diff__overlay screen-diff__container">' +
'<img class="screen-diff__image" src="data/attachments/' + expectedImage.source + '">' +
'<div class="screen-diff__image-over">' +
'<img class="screen-diff__image" src="data/attachments/' + actualImage.source + '">' +
'</div>' +
'</div>';
}
}
var ScreenDiffView = Backbone.Marionette.View.extend({
className: 'pane__section',
events: {
'click [name="screen-diff-type"]': 'onDiffTypeChange',
'mousemove .screen-diff__overlay': 'onOverlayMove'
},
templateContext: function () {
return {
diffType: settings.get('diffType')
}
},
template: function (data) {
var testType = data.labels.filter(function (label) {
return label.name === 'testType'
})[0];
if (!testType || testType.value !== 'screenshotDiff') {
return '';
}
return '<h3 class="pane__section-title">Screen Diff</h3>' +
'<div class="screen-diff__content">' +
'<div class="screen-diff__switchers">' +
'<label><input type="radio" name="screen-diff-type" value="diff"> Show diff</label>' +
'<label><input type="radio" name="screen-diff-type" value="overlay"> Show overlay</label>' +
'</div>' +
renderDiffContent(data.diffType, data) +
'</div>';
},
adjustImageSize: function (event) {
var overImage = this.$(event.target);
overImage.width(overImage.width());
},
onRender: function () {
const diffType = settings.get('diffType');
this.$('[name="screen-diff-type"][value="' + diffType + '"]').prop('checked', true);
if (diffType === 'overlay') {
this.$('.screen-diff__image-over img').on('load', this.adjustImageSize.bind(this));
}
},
onOverlayMove: function (event) {
var pageX = event.pageX;
var containerScroll = this.$('.screen-diff__container').scrollLeft();
var elementX = event.currentTarget.getBoundingClientRect().left;
var delta = pageX - elementX + containerScroll;
this.$('.screen-diff__image-over').width(delta);
},
onDiffTypeChange: function (event) {
settings.save('diffType', event.target.value);
this.render();
}
});
allure.api.addTestResultBlock(ScreenDiffView, {position: 'before'});
})();
.screen-diff__switchers {
margin-bottom: 1em;
}
.screen-diff__switchers label + label {
margin-left: 1em;
}
.screen-diff__overlay {
position: relative;
cursor: col-resize;
}
.screen-diff__container {
overflow-x: auto;
}
.screen-diff__image-over {
top: 0;
left: 0;
bottom: 0;
background: #fff;
position: absolute;
overflow: hidden;
box-shadow: 2px 0 1px -1px #aaa;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"total" : 2,
"items" : [ ]
}
\ No newline at end of file
[ {
"data" : {
"Test defects" : 2
}
} ]
\ No newline at end of file
{
"total" : 1,
"items" : [ {
"uid" : "bdbf199525818fae7a8651db9eafe741",
"name" : "Test defects",
"statistic" : {
"failed" : 0,
"broken" : 2,
"skipped" : 0,
"passed" : 0,
"unknown" : 0,
"total" : 2
}
} ]
}
\ No newline at end of file
[ {
"data" : {
"duration" : 2164
}
} ]
\ No newline at end of file
[ {
"uid" : "b6ab9e10fbdef993",
"name" : "test_login",
"time" : {
"start" : 1708514960669,
"stop" : 1708514962830,
"duration" : 2161
},
"status" : "broken",
"severity" : "normal"
}, {
"uid" : "4a9b9ad4ef7ef157",
"name" : "test_news",
"time" : {
"start" : 1708514962833,
"stop" : 1708514962833,
"duration" : 0
},
"status" : "broken",
"severity" : "normal"
} ]
\ No newline at end of file
[ {
"data" : {
"failed" : 0,
"broken" : 2,
"skipped" : 0,
"passed" : 0,
"unknown" : 0,
"total" : 2
}
} ]
\ No newline at end of file
[ {
"data" : {
"run" : 2,
"retry" : 0
}
} ]
\ No newline at end of file
[ {
"uid" : "b6ab9e10fbdef993",
"name" : "test_login",
"time" : {
"start" : 1708514960669,
"stop" : 1708514962830,
"duration" : 2161
},
"status" : "broken",
"severity" : "normal"
}, {
"uid" : "4a9b9ad4ef7ef157",
"name" : "test_news",
"time" : {
"start" : 1708514962833,
"stop" : 1708514962833,
"duration" : 0
},
"status" : "broken",
"severity" : "normal"
} ]
\ No newline at end of file
[ {
"uid" : "b6ab9e10fbdef993",
"name" : "test_login",
"time" : {
"start" : 1708514960669,
"stop" : 1708514962830,
"duration" : 2161
},
"status" : "broken",
"severity" : "normal"
}, {
"uid" : "4a9b9ad4ef7ef157",
"name" : "test_news",
"time" : {
"start" : 1708514962833,
"stop" : 1708514962833,
"duration" : 0
},
"status" : "broken",
"severity" : "normal"
} ]
\ No newline at end of file
{
"total" : 1,
"items" : [ {
"uid" : "b51346658ccdb9db01a6b5f6c12deab1",
"name" : "testcases",
"statistic" : {
"failed" : 0,
"broken" : 2,
"skipped" : 0,
"passed" : 0,
"unknown" : 0,
"total" : 2
}
} ]
}
\ No newline at end of file
{
"reportName" : "Allure Report",
"testRuns" : [ ],
"statistic" : {
"failed" : 0,
"broken" : 2,
"skipped" : 0,
"passed" : 0,
"unknown" : 0,
"total" : 2
},
"time" : {
"start" : 1708514960669,
"stop" : 1708514962833,
"duration" : 2164,
"minDuration" : 0,
"maxDuration" : 2161,
"sumDuration" : 2161
}
}
\ No newline at end of file
INFO pytest_result_log:plugin.py:104 ---Start: testcases/test_app_login.xlsx::login::test_news---
INFO pytest_result_log:plugin.py:109 ----End: testcases/test_app_login.xlsx::login::test_news----
\ No newline at end of file
{"name": "test_login", "status": "broken", "statusDetails": {"message": "selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)", "trace": "C:\\Python\\Python311\\Lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py:244: WebDriverException\nMessage: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)"}, "attachments": [{"name": "log", "source": "6a0b8486-e7db-47de-a49c-fc57b670b4be-attachment.txt", "type": "text/plain"}], "start": 1708514960669, "stop": 1708514962830, "uuid": "370ba280-3b54-4474-977e-4a15dedd5f36", "historyId": "006b1722c7f3feea0d7d6db073062845", "testCaseId": "006b1722c7f3feea0d7d6db073062845", "fullName": "testcases.test_app_login.login#test_login", "labels": [{"name": "parentSuite", "value": "testcases"}, {"name": "suite", "value": "test_app_login"}, {"name": "subSuite", "value": "login"}, {"name": "host", "value": "DESKTOP-MKSHDA6"}, {"name": "thread", "value": "6444-MainThread"}, {"name": "framework", "value": "pytest"}, {"name": "language", "value": "cpython3"}, {"name": "package", "value": "testcases.test_app_login"}]}
\ No newline at end of file
INFO pytest_result_log:plugin.py:104 --Start: testcases/test_app_login.xlsx::login::test_login---
INFO pytest_result_log:plugin.py:109 ---End: testcases/test_app_login.xlsx::login::test_login----
\ No newline at end of file
{"uuid": "f193a3ec-e43c-47b8-ab60-c3b9933cd337", "befores": [{"name": "get_driver", "status": "broken", "statusDetails": {"message": "selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)\n", "trace": " File \"C:\\Python\\Python311\\Lib\\site-packages\\pluggy\\_callers.py\", line 77, in _multicall\n res = hook_impl.function(*args)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"C:\\Python\\Python311\\Lib\\site-packages\\_pytest\\fixtures.py\", line 1123, in pytest_fixture_setup\n result = call_fixture_func(fixturefunc, request, kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"C:\\Python\\Python311\\Lib\\site-packages\\_pytest\\fixtures.py\", line 895, in call_fixture_func\n fixture_result = next(generator)\n ^^^^^^^^^^^^^^^\n File \"D:\\测试相关\\脚本\\ui自动化云测平台\\pythonProjec_app234\\conftest.py\", line 33, in get_driver\n driver_login = get_app_driver()\n ^^^^^^^^^^^^^^^^\n File \"D:\\测试相关\\脚本\\ui自动化云测平台\\pythonProjec_app234\\common\\driver.py\", line 16, in get_app_driver\n driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_capabilities=desired_caps)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"C:\\Python\\Python311\\Lib\\site-packages\\appium\\webdriver\\webdriver.py\", line 234, in __init__\n super().__init__(\n File \"C:\\Python\\Python311\\Lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 286, in __init__\n self.start_session(capabilities, browser_profile)\n File \"C:\\Python\\Python311\\Lib\\site-packages\\appium\\webdriver\\webdriver.py\", line 324, in start_session\n response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"C:\\Python\\Python311\\Lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 440, in execute\n self.error_handler.check_response(response)\n File \"C:\\Python\\Python311\\Lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py\", line 245, in check_response\n raise exception_class(message, screen, stacktrace)\n"}, "start": 1708514960669, "stop": 1708514962828}], "start": 1708514960669, "stop": 1708514962833}
\ No newline at end of file
{"name": "test_news", "status": "broken", "statusDetails": {"message": "selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)", "trace": "C:\\Python\\Python311\\Lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py:244: WebDriverException\nMessage: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\nStacktrace:\nUnknownError: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall\n at getResponseForW3CError (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\errors.js:804:9)\n at asyncHandler (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-base-driver\\lib\\protocol\\protocol.js:388:37)\n at process._tickCallback (internal/process/next_tick.js:68:7)"}, "attachments": [{"name": "log", "source": "4305a53f-35fc-43a1-9729-9026edb92c62-attachment.txt", "type": "text/plain"}], "start": 1708514962833, "stop": 1708514962833, "uuid": "65399654-c5ae-429f-8ed3-75a17f87fb7f", "historyId": "376ab601bc6f081b2e4b7d6a898aa21d", "testCaseId": "376ab601bc6f081b2e4b7d6a898aa21d", "fullName": "testcases.test_app_login.login#test_news", "labels": [{"name": "parentSuite", "value": "testcases"}, {"name": "suite", "value": "test_app_login"}, {"name": "subSuite", "value": "login"}, {"name": "host", "value": "DESKTOP-MKSHDA6"}, {"name": "thread", "value": "6444-MainThread"}, {"name": "framework", "value": "pytest"}, {"name": "language", "value": "cpython3"}, {"name": "package", "value": "testcases.test_app_login"}]}
\ No newline at end of file
from selenium.webdriver.common.by import By
from common.driver import get_app_driver
from common.ktd import KeyWord
# def test_kdt_login():
# login_driver = get_app_driver()
# kw = KeyWord(login_driver)
# kw.click('//*[@text="同意"]')
# kw.click('//*[@text="知道了"]')
# kw.click('//*[@text="允许"]')
# kw.click('//*[@text="未登录"]')
# kw.click('//*[@text="登录"]')
# kw.click('//*[@text="账号密码登录"]')
# kw.input('//*[@text="手机号/邮箱账号"]','13760437542')
# kw.input('//*[@text="密码"]','woaita330808+')
# kw.click('//*[@text="登 录"]')
# kw.assert_text('com.ifeng.news2:id/txt_personal_page','个人主页')
#
#
# def test_read_news(go_login_kdt):
# rea = go_login_kdt
# rea.click('//*[@text="新闻"]')
# rea.sleep(3)
# rea.tap([(229,479)])
# rea.sleep(5)
# print("文章读取成功")
# rea.swipe(1896,3226,1956,1246)
# rea.assert_text('com.ifeng.news2:id/bottom_writer_comment','我来说两句')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment