-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathappium_simple.py
36 lines (25 loc) · 1.4 KB
/
appium_simple.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#This an example with typical setup
#Some Opera specific functionality was extracted to appium_helper.py
#If you need a custom setup, please a look at https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md
import time
from appium_helper import OperaAppiumDriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ExpectedConditions
######## WEB DRIVER INITIALIZATION #############################
desired_caps = {
'chromedriverExecutable' : 'path/to/operadriver', #download from https://github.com/operasoftware/operachromiumdriver/releases
'app' : 'path/to/opera-browser.apk', #download it from http://www.opera.com/mobile/operabrowser/android
}
driver = OperaAppiumDriver('http://localhost:4723/wd/hub', desired_caps)
######## TEST ##################################################
driver.skip_introduction_guide()
driver.open_page_in_native_context("https://www.google.com/")
driver.switch_to.context('CHROMIUM')
driver.get("https://www.google.com/")
text_input = WebDriverWait(driver, 10).until(ExpectedConditions.element_to_be_clickable((By.NAME, "q")))
text_input.send_keys('OperaDriver\n')
driver.switch_to.context('NATIVE_APP')
driver.close_native_dialog() # close the 'Allow location access?' dialog
time.sleep(5) #just to see the dialog is closed
driver.quit()