Open NickAb opened 8 years ago
Added Contexts, GetContext, SetContext, GetPageSource (web)
some samples to see PR in action
import os
from appium.webdriver import Remote
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from time import sleep
APPX = r"C:\Dev\Winium.StoreApps\Winium\WebViewApp\AppPackages\WebViewApp_1.0.0.0_AnyCPU_Debug_Test\WebViewApp_1.0.0.0_AnyCPU_Debug.appx"
DESIRED_CAPABILITIES = {
"app": APPX,
"deviceName": "Emulator 8.1",
"debugConnectToRunningApp": True
}
class TestPlayground:
def setup_method(self, _):
self.driver = Remote(command_executor="http://localhost:9999", desired_capabilities=DESIRED_CAPABILITIES)
def teardown_method(self, _):
self.driver.quit()
@property
def waiter(self):
return WebDriverWait(self.driver, timeout=5)
def test_web_app(self):
print(self.driver.contexts)
self.driver.switch_to.context('WEBVIEW_1')
self.driver.get("http://www.google.com")
s = self.driver.page_source
assert len(s) > 0
def test(self):
pivots = self.driver.find_elements_by_class_name("Windows.UI.Xaml.Controls.Primitives.PivotHeaderItem")
pivots[2].click()
tab = self.driver.find_element_by_id('ThirdTab')
self.waiter.until(EC.visibility_of(tab))
print(self.driver.contexts)
self.driver.switch_to.context('WEBVIEW_1')
el = self.driver.find_element_by_name('q')
sleep(1)
el.click()
sleep(1)
#el.send_keys('Hello World!')
el.send_keys('2^2=')
sleep(2)
sbmt = self.driver.find_element_by_xpath('//button[@type="submit"]')
sbmt.click()
sleep(5)
list of commands included in PR
WIP. Web context / Hybrid apps support.