Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from page.app import App | ||
from utils.get_data import GetData | ||
|
||
|
||
class TestAddMember: | ||
def setup_class(self): | ||
self.app = App() | ||
self.data = GetData() | ||
self.name = self.data.get_name() | ||
self.phonenum = self.data.get_phonenum() | ||
|
||
def setup(self): | ||
self.main = self.app.start().goto_main() | ||
|
||
|
||
def teardown_class(self): | ||
self.app.quit() | ||
|
||
def test_add(self): | ||
ele = self.main.click_contact().click_add_member().add_member().editor_member(self.name, | ||
self.phonenum).find_toast() | ||
assert ele | ||
|
||
|
||
def test_delete(self): | ||
print(self.name) | ||
ele2 = self.main.click_contact().delete_member(self.name) | ||
assert ele2 | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from page.base_page import BasePage | ||
from page.editor_member_page import Editor | ||
|
||
|
||
class AddMemberPage(BasePage): | ||
def add_member(self): | ||
self.driver.find_element_by_xpath("//*[@text='手动输入添加']").click() | ||
return Editor(self.driver) | ||
|
||
def find_toast(self): | ||
ele = self.driver.find_element_by_xpath("//*[@text='添加成功']") | ||
return ele | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from appium import webdriver | ||
|
||
from page.base_page import BasePage | ||
from page.main_page import MainPage | ||
|
||
|
||
class App(BasePage): | ||
def start(self): | ||
if self.driver == None: | ||
desire_caps = { # capability 设置 | ||
"platformName": "android", # 要测试的平台 | ||
"deviceName": "127.0.0.1:7555", # 要启动设备的名称 | ||
"appPackage": "com.tencent.wework", # 包名 | ||
"appActivity": ".launch.WwMainActivity", # 要打开的活动页 | ||
"noReset": "true", # 不清理缓存 | ||
"unicodeKeyBoard": "true", # 设置允许输入中文 | ||
"resetKeyBoard": "true", # 同上 | ||
"skipDeviceInitialization": "true", # 跳过设备的初始化 | ||
'automationName': "uiautomator2" # 用到的平台工具名 | ||
} | ||
self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desire_caps) # 打开设备,并传入capability参数 | ||
self.driver.implicitly_wait(5) # 隐式等待 | ||
else: | ||
self.driver.launch_app() | ||
return self | ||
|
||
def quit(self): | ||
self.driver.quit() | ||
|
||
def goto_main(self): | ||
return MainPage(self.driver) | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from selenium.webdriver.remote.webdriver import WebDriver | ||
|
||
|
||
class BasePage: | ||
def __init__(self,driver:WebDriver=None): | ||
self.driver = driver | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from appium.webdriver.common.mobileby import MobileBy | ||
|
||
from page.add_member_page import AddMemberPage | ||
from page.base_page import BasePage | ||
|
||
|
||
class ContactPage(BasePage): | ||
def click_add_member(self): | ||
self.driver.find_element(MobileBy.ANDROID_UIAUTOMATOR, | ||
'new UiScrollable(new UiSelector().' | ||
'scrollable(true).instance(0)).' | ||
'scrollIntoView(new UiSelector().' | ||
'text("添加成员").instance(0));').click() # 滑动寻找并点击'添加成员' | ||
return AddMemberPage(self.driver) # 跳转到添加成员界面 | ||
|
||
def delete_member(self, name): | ||
self.driver.find_element(MobileBy.ANDROID_UIAUTOMATOR, | ||
f'new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text("{name}").instance(0));').click() # 滑动寻找并点击成员姓名 | ||
self.driver.find_element_by_xpath("//*[contains(@text,'个人信息')]/../../../../../*[2]").click() # 点击更多 | ||
self.driver.find_element_by_xpath("//*[@text='编辑成员']").click() # 点击'编辑成员' | ||
self.driver.find_element(MobileBy.ANDROID_UIAUTOMATOR, | ||
'new UiScrollable(new UiSelector().' | ||
'scrollable(true).instance(0)).' | ||
'scrollIntoView(new UiSelector().' | ||
'text("删除成员").instance(0));').click() # 滑动寻找并点击'删除成员' | ||
self.driver.find_element_by_xpath("//*[@text='确定']").click() # 点击确定 | ||
return AddMemberPage(self.driver) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
from page.base_page import BasePage | ||
|
||
|
||
class Editor(BasePage): | ||
def editor_member(self,name,phonenumber): | ||
self.driver.find_element_by_xpath( | ||
"//*[contains(@text,'姓名')]/../android.widget.EditText").send_keys(name) | ||
self.driver.find_element_by_xpath( | ||
"//*[contains(@text,'手机')]/../android.widget.RelativeLayout/android.widget.RelativeLayout" | ||
"/android.widget.EditText").send_keys(phonenumber) | ||
self.driver.find_element_by_xpath("//*[@text='保存']").click() | ||
from page.add_member_page import AddMemberPage | ||
return AddMemberPage(self.driver) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from page.base_page import BasePage | ||
from page.contact_page import ContactPage | ||
|
||
|
||
class MainPage(BasePage): | ||
def click_contact(self): | ||
self.driver.find_element_by_xpath("//*[@text='通讯录']").click() | ||
return ContactPage(self.driver) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from faker import Faker | ||
|
||
|
||
class GetData: | ||
def __init__(self): | ||
self.faker = Faker("zh-CN") | ||
|
||
def get_name(self): | ||
return self.faker.name() | ||
|
||
def get_phonenum(self): | ||
return self.faker.phone_number() | ||
|
||
if __name__ == '__main__': | ||
print(GetData().get_name()) | ||
print(GetData().get_phonenum()) |