Skip to content

[WIP] Web context / hybrid apps experiments - #165

Open
NickAb wants to merge 6 commits into
masterfrom
webviews
Open

[WIP] Web context / hybrid apps experiments#165
NickAb wants to merge 6 commits into
masterfrom
webviews

Conversation

@NickAb

@NickAb NickAb commented Oct 13, 2016

Copy link
Copy Markdown
Contributor

WIP. Web context / Hybrid apps support.

@NickAb

NickAb commented Oct 13, 2016

Copy link
Copy Markdown
Contributor Author

Added Contexts, GetContext, SetContext, GetPageSource (web)

@NickAb

NickAb commented Feb 20, 2017

Copy link
Copy Markdown
Contributor Author

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)

@NickAb

NickAb commented Feb 20, 2017

Copy link
Copy Markdown
Contributor Author

list of commands included in PR

  • ClickElementCommand
  • FindElementCommand
  • GetActiveElementCommand
  • GetElementTextCommand
  • GetPageSourceCommand
  • GetTitleCommand
  • GoToUrlCommand
  • SendKeysCommand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant