Skip to content

Instantly share code, notes, and snippets.

@mogeta mogeta/back.py
Created Feb 15, 2019

Embed
What would you like to do?
AppiumとAirtestを利用したハイブリッドゲームアップのE2Eテスト
# -*- encoding=utf8 -*-
from airtest.core.api import *
auto_setup(__file__)
# 指定画像を捜査しタッチ捜査をおこなう。
# back.airディレクトリ内に画像配置済み
def back_button():
touch(Template(r"tpl1550048906014.png", record_pos=(-0.472, -0.255), resolution=(1920, 1080)))
from airtest.core.api import *
from appium import webdriver
#Appium起動処理
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['automationName'] = 'Appium'
desired_caps['deviceName'] = 'ASUS_Z01KD_1'
desired_caps['appPackage'] = 'net.gree.webview.sample'
desired_caps['appActivity'] = 'com.unity3d.player.UnityPlayerActivity'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
time.sleep(7)
auto_setup(__file__)
# Appium内 Contextスイッチ
webview = driver.contexts[-1]
driver.switch_to.context(webview)
# WebView操作
form = driver.find_element_by_css_selector('body > p:nth-child(4) > a')
print(form.text) # google.com
# form.click() 動作せず
driver.execute_script('document.getElementsByTagName("A")[0].click()')
time.sleep(5)
#Airtest側操作
using("back.air")
from back import back_button
back_button()
time.sleep(10)
driver.quit()
# mock.air内にmock.pyファイル配置、airtestライブラリを起点として起動。
python -m airtest run mock.air --log log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.