from
appium
import
webdriver
from
time
import
sleep
from
selenium.webdriver.support.ui
import
WebDriverWait
from
selenium.webdriver.support
import
expected_conditions as EC
from
appiumPython.util.get_by_local
import
GetByLocal
def
get_driver():
capabilities
=
{
"platformName"
:
"Android"
,
"deviceName"
:
"127.0.0.1:21503"
,
"app"
:
"D:/appuim/appium-sofe/mukewang.apk"
,
"appWaitActivity"
:
"cn.com.open.mooc.index.splash.MCSplashActivity"
,
"noReset"
:
'true'
}
driver
=
webdriver.Remote(
"http://127.0.0.1:4723/wd/hub"
, capabilities)
sleep(
10
)
return
driver
def
get_web_view():
sleep(
12
)
webview
=
driver.contexts
print
(webview)
for
viw
in
webview:
if
'WEBVIEW_cn.com.open.mooc'
in
viw:
driver.switch_to.context(viw)
break
driver.find_element_by_link_text(
'JAVA'
).click()
try
:
driver.find_element_by_id(
"cn.com.open.mooc:id/left_icon"
).click()
except
Exception as e:
driver.switch_to.context(webview[
0
])
driver.find_element_by_id(
"cn.com.open.mooc:id/left_icon"
).click()
raise
e