# 编辑成员信息页面
from appium.webdriver.common.mobileby import MobileBy

from homework_zfh.test_appium.page.BasePage import BasePage


class ContactEditPage(BasePage):
    def edit_name(self, name):
        self.find((MobileBy.XPATH, "//*[contains(@text,'姓名')]/../android.widget.EditText")).send_keys(name)
        return self

    def edit_gender(self, gender):
        self.find((MobileBy.XPATH, '//*[@text="男"]')).click()
        if gender == '女':
            self.find((MobileBy.XPATH, '//*[@text="女"]')).click()
        else:
            self.find((MobileBy.XPATH, '//*[@text="男"]')).click()

        return self

    def edit_phonenum(self, phonenum):
        self.find((MobileBy.ID, "com.tencent.wework:id/fwi")).send_keys(phonenum)
        return self

    def click_save(self):
        from homework_zfh.test_appium.page.memberinvite_page import MemberInvitePage
        self.find((MobileBy.XPATH, "//*[@text='保存']")).click()
        return MemberInvitePage(self.driver)
