Commit 3141225a authored by 李康's avatar 李康

Initial commit

parents
__pycache__
.idea
from appium import webdriver
def get_desired_capabilities():
desired_caps = {
"platformName": "Android",
"deviceName": "Redmi Note 4X",
"udid": "d52196830204",
"automationName": "uiautomator2",
"appActivity": ".ui.LauncherUI",
"noReset": "True",
"waitForQuiescence": "false",
"useJSONSource": "true",
"simpleIsVisibleCheck": "true"
}
return desired_caps
def get_uri():
return 'http://localhost:4723/wd/hub'
def setUpDriver():
desired_cap = get_desired_capabilities()
print(desired_cap)
uri = get_uri()
driver = webdriver.Remote(uri, desired_cap)
return driver
\ No newline at end of file
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import unittest
import time
from selenium.common.exceptions import NoSuchElementException
from appium_common import setUpDriver
brand_xpath = "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/" \
"android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/" \
"android.support.v4.view.ViewPager/android.support.v7.widget.RecyclerView/" \
"android.widget.RelativeLayout[%d]"
def getAllBrands():
drv = setUpDriver()
done = []
while True:
brand = drv.find_element_by_xpath(brand_xpath % 1)
try:
brand_name = brand.find_element_by_id("org.c2h4.afei.beauty:id/tv_name")
except NoSuchElementException:
brand_name = None
try:
brand_name_en = brand.find_element_by_id("org.c2h4.afei.beauty:id/tv_name_en")
except NoSuchElementException:
brand_name_en = None
if brand_name is not None:
if brand_name.text not in done:
done.append(brand_name.text)
print(brand_name.text)
print(brand_name_en.text)
else:
drv.swipe(0, 600, 0, 0, 1000)
continue
elif brand_name_en is not None:
if brand_name_en.text not in done:
done.append(brand_name_en.text)
print(brand_name_en.text)
else:
drv.swipe(0, 600, 0, 0, 1000)
continue
else:
drv.swipe(0, 600, 0, 0, 1000)
continue
brand_year = brand.find_element_by_id("org.c2h4.afei.beauty:id/tv_year")
print(brand_year.text)
brand_desc = brand.find_element_by_id("org.c2h4.afei.beauty:id/tv_desc")
print(brand_desc.text)
drv.swipe(0, 600, 0, 0, 1000)
if __name__=='__main__':
getAllBrands()
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