Created
June 8, 2018 10:31
-
-
Save shadow1163/dd8a37d8f0d88f6653608ffd3ea6a658 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from appium import webdriver | |
import time | |
desired_caps = {} | |
desired_caps['platformName'] = 'Android' | |
desired_caps['platformVersion'] = '7.1.1' | |
desired_caps['deviceName'] = 'Android Emulator' | |
desired_caps['appPackage'] = 'com.android.chrome' | |
desired_caps['appWaitActivity'] = 'com.watchguard.authpoint.view.activity.WelcomeActivity' | |
desired_caps['appWaitPackage'] = 'com.watchguard.authpoint' | |
# desired_caps['appActivity'] = '.MainActivity' | |
desired_caps['browserName'] = 'Chrome' | |
# desired_caps['autoAcceptAlerts'] = True | |
# desired_caps['autoGrantPermissions'] = True | |
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) | |
# webview = driver.contexts.last | |
# driver.switch_to.context(webview) | |
# driver.get("https://m.baidu.com") | |
# driver.get("https://3g.163.com/touch/#/") | |
driver.switch_to.context("NATIVE_APP") | |
driver.implicitly_wait(30) | |
active = driver.find_element_by_xpath("//android.view.View[@text = 'ACTIVATE']") | |
active.click() | |
# driver.start_activity("com.watchguard.authpoint", "com.watchguard.authpoint.view.activity.WelcomeActivity") | |
# active = driver.find_element_by_id('com.watchguard.authpoint:id/btn_activate') | |
# active.click() | |
# active.click() | |
# deny = 'new UiSelector().text("BLOCK")).className("android.widget.Button")' | |
# driver.find_element_by_id('login_panel').click() | |
# driver.switch_to_alert() | |
# time.sleep(10) | |
# while True: | |
# current = driver.current_context | |
# print(current) | |
# driver.switch_to.context("NATIVE_APP") | |
# try: | |
# driver.switch_to_alert() | |
# block = driver.find_element_by_id('android:id/button2') | |
# block = driver.find_element_by_xpath("//android.widget.Button[@text = 'BLOCK']") | |
# block.click() | |
# driver.switch_to.context(current) | |
# break | |
# except Exception: | |
# print("error") | |
# time.sleep(5) | |
# | |
# # block = driver.find_element_by_id('com.android.chrome:id/button2') | |
# | |
# driver.find_element_by_id('index-kw').send_keys("123") | |
# driver.find_element_by_accessibility_id('index-bn').click() | |
# driver.start_activity() | |
# driver.get('http://saucelabs.com/test/guinea-pig') | |
# div = driver.find_element_by_id('i_am_an_id') | |
# check the text retrieved matches expected value | |
# assertEqual('I am a div', div.text) | |
# if div.text == 'I am a div': | |
# print("Yes") | |
# else: | |
# print("No") | |
# | |
# # populate the comments field by id | |
# driver.find_element_by_id('comments').send_keys('My comment') | |
time.sleep(10) | |
driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment