Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
Appium-crawl
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李康
Appium-crawl
Commits
3141225a
Commit
3141225a
authored
Oct 15, 2019
by
李康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
0 deletions
+79
-0
.gitignore
.gitignore
+2
-0
appium_common.py
appium_common.py
+26
-0
brands.py
brands.py
+51
-0
No files found.
.gitignore
0 → 100644
View file @
3141225a
__pycache__
.idea
appium_common.py
0 → 100644
View file @
3141225a
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
brands.py
0 → 100644
View file @
3141225a
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
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment