code thay gmail va tai app

 avatar
user_8607526207
python
2 years ago
3.6 kB
4
Indexable
Never
path = "link.txt"
app = "app.txt"

import uiautomator2 as u2
d = u2.connect()
import time
def GetPassword(path):
    f = open(path)
    link = f.readline()
    f.close
    return link

def GetMail(path):
    f = open(path)
    links = f.readlines()
    f.close
    return links

#text = ReadFile(path)

def ChangeMail(gmail,passwd):
    d.app_start("com.android.vending", use_monkey=True)
    time.sleep(5)
    # click dang nhap
    d(resourceId="com.android.vending:id/0_resource_name_obfuscated", text="Đăng nhập").click()
    time.sleep(5)
    # click email
    d.xpath('//*[@resource-id="view_container"]/android.view.View[2]/android.view.View[1]/android.view.View[1]/android.widget.TextView[2]').click()
    # click email
    time.sleep(5)
    d(resourceId="identifierId").click()
    # send key
    d.send_keys(gmail, clear=True)
    # click nut tiep theo
    d(text="Tiếp theo").click()
    d(resourceId="identifierId").click()
    d.send_keys(passwd, clear=True)
    d(text="Tiếp theo").click()
    time.sleep(5)
    d(text="Tôi đồng ý").click()
    time.sleep(5)
    d(scrollable=True).fling()
    time.sleep(5)
    d(text="Chấp nhận").click()



def CloseAll():
    d(resourceId="com.android.systemui:id/recent_apps").click()
    time.sleep(5)
    d(resourceId="com.sec.android.app.launcher:id/clear_all_button").click()


def InstallApp(app):
    d.open_url(app)
    time.sleep(5)
    d.xpath('//androidx.compose.ui.platform.ComposeView/android.view.View[1]/android.view.View[2]/android.view.View[2]/android.view.View[2]').click()



def UninstallApp(app):
    d.open_url(app)
    time.sleep(5)
    d.xpath('//androidx.compose.ui.platform.ComposeView/android.view.View[1]/android.view.View[2]/android.view.View[2]/android.view.View[2]').click()
    time.sleep(5)
    d(description="Gỡ cài đặt").click()



def DeleteMail():
    d.app_start("com.android.vending", use_monkey=True)
    time.sleep(10)
    d.xpath('//androidx.compose.ui.platform.ComposeView/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.ViewGroup[1]').click()
    time.sleep(10)
    d.xpath('//android.widget.ScrollView/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.view.ViewGroup[1]/android.widget.FrameLayout[2]').click()
    time.sleep(10)
    d.xpath('//android.widget.ScrollView/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.support.v7.widget.RecyclerView[2]/android.view.ViewGroup[2]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]').click()
    time.sleep(10)
    d.xpath('//*[@resource-id="com.android.settings:id/list"]/android.widget.LinearLayout[3]/android.widget.LinearLayout[2]').click()
    time.sleep(10)
    d(resourceId="com.android.settings:id/button").click()
    time.sleep(10)
    d(resourceId="android:id/button1").click()

#listlink = ReadFiles(path)
gmail = GetMail(path)
targetapp = GetPassword(app)
passwd = "Cellphone18"
for cur in gmail:
    ChangeMail(cur,passwd)
    time.sleep(10)
    CloseAll()
    time.sleep(10)
    InstallApp(targetapp)
    time.sleep(100)
    CloseAll()
    time.sleep(10)
    UninstallApp(targetapp)
    time.sleep(20)
    CloseAll()
    time.sleep(10)
    DeleteMail()
    time.sleep(10)
    CloseAll()