當前位置: 首頁>>代碼示例>>Python>>正文


Python webdriver.Remote方法代碼示例

本文整理匯總了Python中appium.webdriver.Remote方法的典型用法代碼示例。如果您正苦於以下問題:Python webdriver.Remote方法的具體用法?Python webdriver.Remote怎麽用?Python webdriver.Remote使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在appium.webdriver的用法示例。


在下文中一共展示了webdriver.Remote方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_browserstack

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def run_browserstack(self,os_name,os_version,browser,browser_version,remote_project_name,remote_build_name):
        "Run the test in browser stack when remote flag is 'Y'"
        #Get the browser stack credentials from browser stack credentials file
        USERNAME = remote_credentials.USERNAME
        PASSWORD = remote_credentials.ACCESS_KEY
        if browser.lower() == 'ff' or browser.lower() == 'firefox':
            desired_capabilities = DesiredCapabilities.FIREFOX            
        elif browser.lower() == 'ie':
            desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
        elif browser.lower() == 'chrome':
            desired_capabilities = DesiredCapabilities.CHROME            
        elif browser.lower() == 'opera':
            desired_capabilities = DesiredCapabilities.OPERA        
        elif browser.lower() == 'safari':
            desired_capabilities = DesiredCapabilities.SAFARI
        desired_capabilities['os'] = os_name
        desired_capabilities['os_version'] = os_version
        desired_capabilities['browser_version'] = browser_version
        if remote_project_name is not None:
            desired_capabilities['project'] = remote_project_name
        if remote_build_name is not None:
            desired_capabilities['build'] = remote_build_name+"_"+str(datetime.now().strftime("%c"))

        return webdriver.Remote(RemoteConnection("http://%s:%s@hub-cloud.browserstack.com/wd/hub"%(USERNAME,PASSWORD),resolve_ip= False),
            desired_capabilities=desired_capabilities) 
開發者ID:qxf2,項目名稱:makemework,代碼行數:27,代碼來源:DriverFactory.py

示例2: run_sauce_lab

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def run_sauce_lab(self,os_name,os_version,browser,browser_version):
        "Run the test in sauce labs when remote flag is 'Y'"
        #Get the sauce labs credentials from sauce.credentials file
        USERNAME = remote_credentials.USERNAME
        PASSWORD = remote_credentials.ACCESS_KEY
        if browser.lower() == 'ff' or browser.lower() == 'firefox':
            desired_capabilities = DesiredCapabilities.FIREFOX            
        elif browser.lower() == 'ie':
            desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
        elif browser.lower() == 'chrome':
            desired_capabilities = DesiredCapabilities.CHROME            
        elif browser.lower() == 'opera':
            desired_capabilities = DesiredCapabilities.OPERA        
        elif browser.lower() == 'safari':
            desired_capabilities = DesiredCapabilities.SAFARI
        desired_capabilities['version'] = browser_version
        desired_capabilities['platform'] = os_name + ' '+os_version
        
        
        return webdriver.Remote(command_executor="http://%s:%s@ondemand.saucelabs.com:80/wd/hub"%(USERNAME,PASSWORD),
                desired_capabilities= desired_capabilities) 
開發者ID:qxf2,項目名稱:makemework,代碼行數:23,代碼來源:DriverFactory.py

示例3: run_browserstack

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def run_browserstack(self,os_name,os_version,browser,browser_version,remote_project_name,remote_build_name):
        "Run the test in browser stack when remote flag is 'Y'"
        #Get the browser stack credentials from browser stack credentials file
        USERNAME = remote_credentials.USERNAME
        PASSWORD = remote_credentials.ACCESS_KEY
        if browser.lower() == 'ff' or browser.lower() == 'firefox':
            desired_capabilities = DesiredCapabilities.FIREFOX
        elif browser.lower() == 'ie':
            desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
        elif browser.lower() == 'chrome':
            desired_capabilities = DesiredCapabilities.CHROME
        elif browser.lower() == 'opera':
            desired_capabilities = DesiredCapabilities.OPERA
        elif browser.lower() == 'safari':
            desired_capabilities = DesiredCapabilities.SAFARI
        desired_capabilities['os'] = os_name
        desired_capabilities['os_version'] = os_version
        desired_capabilities['browser_version'] = browser_version
        if remote_project_name is not None:
            desired_capabilities['project'] = remote_project_name
        if remote_build_name is not None:
            desired_capabilities['build'] = remote_build_name+"_"+str(datetime.now().strftime("%c"))

        return webdriver.Remote(RemoteConnection("http://%s:%s@hub-cloud.browserstack.com/wd/hub"%(USERNAME,PASSWORD),resolve_ip= False),
            desired_capabilities=desired_capabilities) 
開發者ID:qxf2,項目名稱:qxf2-page-object-model,代碼行數:27,代碼來源:DriverFactory.py

示例4: run_sauce_lab

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def run_sauce_lab(self,os_name,os_version,browser,browser_version):
        "Run the test in sauce labs when remote flag is 'Y'"
        #Get the sauce labs credentials from sauce.credentials file
        USERNAME = remote_credentials.USERNAME
        PASSWORD = remote_credentials.ACCESS_KEY
        if browser.lower() == 'ff' or browser.lower() == 'firefox':
            desired_capabilities = DesiredCapabilities.FIREFOX
        elif browser.lower() == 'ie':
            desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
        elif browser.lower() == 'chrome':
            desired_capabilities = DesiredCapabilities.CHROME
        elif browser.lower() == 'opera':
            desired_capabilities = DesiredCapabilities.OPERA
        elif browser.lower() == 'safari':
            desired_capabilities = DesiredCapabilities.SAFARI
        desired_capabilities['version'] = browser_version
        desired_capabilities['platform'] = os_name + ' '+os_version


        return webdriver.Remote(command_executor="http://%s:%s@ondemand.saucelabs.com:80/wd/hub"%(USERNAME,PASSWORD),
                desired_capabilities= desired_capabilities) 
開發者ID:qxf2,項目名稱:qxf2-page-object-model,代碼行數:23,代碼來源:DriverFactory.py

示例5: test_all_sessions

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def test_all_sessions(self) -> None:
        port = get_available_from_port_range(8200, 8300)
        desired_caps = desired_capabilities.get_desired_capabilities('UICatalog.app.zip')
        desired_caps['deviceName'] = 'iPhone Xs Max'
        desired_caps['wdaLocalPort'] = port

        class session_counts_is_two:
            TIMEOUT = 10

            def __call__(self, driver: 'WebDriver') -> bool:
                return len(driver.all_sessions) == 2

        driver2 = None
        try:
            driver2 = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
            WebDriverWait(
                driver2, session_counts_is_two.TIMEOUT).until(session_counts_is_two())
            assert len(self.driver.all_sessions) == 2
        finally:
            if driver2 is not None:
                driver2.quit() 
開發者ID:appium,項目名稱:python-client,代碼行數:23,代碼來源:webdriver_tests.py

示例6: __init__

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def __init__(self):
        desired_caps = {}
        desired_caps['platformName'] = 'Android'
        desired_caps['platformVersion'] = '5.1'
        desired_caps['deviceName'] = '88CKBM622PAM'
        desired_caps['appPackage'] = 'com.tencent.mm'
        desired_caps['appActivity'] = '.ui.LauncherUI'

        # 定義在朋友圈的時候滑動位置
        self.start_x = 300
        self.start_y = 800
        self.end_x = 300
        self.end_y = 300

        # 啟動微信
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
        # 設置等待
        self.wait = WebDriverWait(self.driver, 300)
        print('微信啟動...') 
開發者ID:wistbean,項目名稱:learn_python3_spider,代碼行數:21,代碼來源:wechat_moment.py

示例7: __init__

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def __init__(self, addr=None):
        if not addr:
            addr = '127.0.0.1'
        self.url = 'http://%s:4723/wd/hub' % addr
        self.driver = webdriver.Remote(
            command_executor=self.url,
            desired_capabilities={
                'platformName': 'iOS',
                # after appium 1.2.0, deviceName is required
                'deviceName': 'ios device',
                'autoLaunch': False
            }
        )
        self._scale = None
        self.start()
        self._init() 
開發者ID:NetEase,項目名稱:airtest,代碼行數:18,代碼來源:ios.py

示例8: open_application

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def open_application(self, remote_url, alias=None, **kwargs):
        """Opens a new application to given Appium server.
        Capabilities of appium server, Android and iOS,
        Please check https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/server-args.md
        | *Option*            | *Man.* | *Description*     |
        | remote_url          | Yes    | Appium server url |
        | alias               | no     | alias             |

        Examples:
        | Open Application | http://localhost:4723/wd/hub | alias=Myapp1         | platformName=iOS      | platformVersion=7.0            | deviceName='iPhone Simulator'           | app=your.app                         |
        | Open Application | http://localhost:4723/wd/hub | platformName=Android | platformVersion=4.2.2 | deviceName=192.168.56.101:5555 | app=${CURDIR}/demoapp/OrangeDemoApp.apk | appPackage=com.netease.qa.orangedemo | appActivity=MainActivity |
        """
        desired_caps = kwargs
        application = webdriver.Remote(str(remote_url), desired_caps)

        self._debug('Opened application with session id %s' % application.session_id)

        return self._cache.register(application, alias) 
開發者ID:serhatbolsu,項目名稱:robotframework-appiumlibrary,代碼行數:20,代碼來源:_applicationmanagement.py

示例9: __init__

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def __init__(self):
        """
        初始化
        """
        # 驅動配置
        self.desired_caps = {
            'platformName': PLATFORM,
            'deviceName': DEVICE_NAME,
            'appPackage': WECHAT_PACKAGE,
            'appActivity': WECHAT_ACTIVITY,
            'noReset': True,
            "automationName": "Uiautomator2"
        }
        self.driver = webdriver.Remote(DRIVER_SERVER, self.desired_caps)
        self.wait = WebDriverWait(self.driver, TIMEOUT)
        self.client = MongoClient(MONGO_URL)
        self.db = self.client[WECHAT_XHS_MONGO_DB]
        self.collection = self.db[WECHAT_XHS_MONGO_COLLECTION]
        # 處理器
        self.processor = Processor() 
開發者ID:HhhuYu,項目名稱:xhs_simple_crawler,代碼行數:22,代碼來源:xhs_wechat.py

示例10: __init__

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def __init__(self):
        """
        初始化
        """
        # 驅動配置
        self.desired_caps = {
            'platformName': PLATFORM,
            'deviceName': DEVICE_NAME,
            'appPackage': XHS_PACKAGE,
            'appActivity': XHS_ACTIVITY,
            'noReset': True,
            "automationName": "Uiautomator2"
        }
        global collection
        self.driver = webdriver.Remote(DRIVER_SERVER, self.desired_caps)
        self.wait = WebDriverWait(self.driver, TIMEOUT)
        self.client = MongoClient(MONGO_URL)
        self.db = self.client[XHS_MONGO_DB]
        self.collection = self.db[XHS_MONGO_COLLECTION]
        self.processor = Processor() 
開發者ID:HhhuYu,項目名稱:xhs_simple_crawler,代碼行數:22,代碼來源:xhs_app.py

示例11: start_appium

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def start_appium(self):
        """
        啟動driver
        :return:
        """

        number_of_starts = 0
        while number_of_starts < 6:
            try:
                self.driver = webdriver.Remote(
                    'http://127.0.0.1:%s/wd/hub' %
                    self.__get_appium_port(), self.device_l)
                U.Logging.debug('appium start %s success' % self.device)
                return self.driver
            except Exception as e:
                number_of_starts += 1
                U.Logging.error('Failed to start appium :{}'.format(e))
                U.Logging.error(
                    'Try restarting the appium :{},Trying the {} frequency'.format(self.device, number_of_starts))
                U.sleep(5)
        if number_of_starts > 5:
            U.Logging.error('Can not start appium, the program exits')
            exit() 
開發者ID:ztwo,項目名稱:Auto_Analysis,代碼行數:25,代碼來源:integration.py

示例12: get_android_driver

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def get_android_driver(self, sno):
        desired_caps = self.get_desired_capabilities(sno)
        self.before_create_driver(desired_caps['udid'])
        port = self.get_appium_port(desired_caps["udid"])
        if not self.is_port_used(port):
            self.log4py.debug("設備號[{}]對應的appium服務沒有啟動".format(desired_caps['udid']))
            return None
        url = 'http://127.0.0.1:%s/wd/hub' % (port.strip())
        self.log4py.debug(url)
        self.log4py.debug(desired_caps)
        num = 0
        while num <= 5:
            try:
                driver = webdriver.Remote(url, desired_caps)
            except urllib2.URLError as e:
                self.log4py.error("連接appium服務,實例化driver時出錯,嘗試重連...({})".format(num))
                num = num + 1
                continue
            if self.run_data["wait_activity"] is not None:
                driver.wait_activity(self.run_data["wait_activity"], 10)
            else:
                driver.implicitly_wait(10)
            self.log4py.info("webdriver連接信息:{}:{}".format(url, str(desired_caps)))
            return driver
        return None 
開發者ID:gitjayzhen,項目名稱:AppiumTestProject,代碼行數:27,代碼來源:InitAppiumDriver.py

示例13: __init__

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def __init__(self):
        self.connect()
        self.desired_caps = {
            "platformName": caps["platformname"],
            "platformVersion": caps["platformversion"],
            "automationName": caps["automationname"],
            "unicodeKeyboard": caps["unicodekeyboard"],
            "resetKeyboard": caps["resetkeyboard"],
            "noReset": caps["noreset"],
            'newCommandTimeout': 800,
            "deviceName": caps["devicename"],
            "uuid": caps["uuid"],
            "appPackage": caps["apppackage"],
            "appActivity": caps["appactivity"]
        }
        logger.info('打開 appium 服務,正在配置...')
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', self.desired_caps)
        self.wait = WebDriverWait(self.driver, 10)
        self.size = self.driver.get_window_size() 
開發者ID:kessil,項目名稱:AutoXue,代碼行數:21,代碼來源:__init__.py

示例14: setUp

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def setUp(self):
        "Setup for the test"
        desired_caps = {}
        desired_caps['platformName'] = 'Android'
        desired_caps['platformVersion'] = '9'
        desired_caps['deviceName'] = 'emulator-5554'
        # Returns abs path relative to this file and not cwd
        # desired_caps['app'] = os.path.abspath(os.path.join(os.path.dirname(__file__),'apps/whatsapp.apk'))
        desired_caps['appPackage'] = 'com.android.contacts'
        desired_caps['appActivity'] = '.activities.PeopleActivity'
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
        #self.emulator_name = 'pixel_1'
        #self.mobile_number = '+91 78386 67436'
        #self.message_body = 'Hello There!'
        self.emulator_name = self.emulator_name
        self.mobile_number = self.mobile_number
        # self.action = action 
開發者ID:mnkgrover08-zz,項目名稱:whatsapp_automation,代碼行數:19,代碼來源:whatsapp_add_new_contact_worker.py

示例15: __init__

# 需要導入模塊: from appium import webdriver [as 別名]
# 或者: from appium.webdriver import Remote [as 別名]
def __init__(self):
        self.caps = {
            'automationName': DRIVER,
            'platformName': PLATFORM,
            'deviceName': DEVICE_NAME,
            'appPackage': APP_PACKAGE,
            'appActivity': APP_ACTIVITY,
            'platformVersion': ANDROID_VERSION,
            'autoGrantPermissions': AUTO_GRANT_PERMISSIONS,
            'unicodeKeyboard': True,
            'resetKeyboard': True
        }
        self.driver = webdriver.Remote(DRIVER_SERVER, self.caps)
        self.wait = WebDriverWait(self.driver, TIMEOUT) 
開發者ID:xingag,項目名稱:tools_python,代碼行數:16,代碼來源:nantian_keyboard.py


注:本文中的appium.webdriver.Remote方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。