コード例 #1
0
    def __init__(self, driver, stringDict={}, conf=None):
        "CONFIG"
        if conf == None:
            logging.info("%s Config file is None" %
                         driver.capabilities['deviceName'])
            conf = ConfigFile.Config()

        self._assertionDebug = conf.ASSERTION_DEBUG
        self.PACKAGE_NAME = conf.PACKAGE_NAME
        self.DEVICE_NAME = driver.capabilities['deviceName']
        self.driver = driver
        self.stringDict = stringDict
        self.midX = driver.get_window_size()['width'] // 2
        self.midY = driver.get_window_size()['height'] // 2
        self._content = 'android:id/content'
        self._alertTitle = 'android:id/alertTitle'
        self._message = 'android:id/message'
        self._button1 = 'android:id/button1'
        self._button2 = 'android:id/button2'
        self.webkit_class = 'android.webkit.WebView'
        self.n_test_cases = 0
        self.n_test_pass = 0
        self.n_test_fail = 0
        self.l_test_fail = list()
        self.tls = TestLink(conf.DEVKEY, conf.TESTLINK_URL,
                            str(conf.TESTPLANID), str(conf.BUILDID),
                            str(conf.PLATFORMID), conf.RESULTASSIGNMENT,
                            self.DEVICE_NAME)
        self.conf = conf
コード例 #2
0
    def __init__(self, driver, stringDict={}, conf=None):
        if conf == None:
            conf = ConfigFile.Config()
        self.conf = conf
        self.PACKAGE_NAME = self.conf.PACKAGE_NAME
        self.DEVICE_NAME = driver.capabilities['deviceName']

        self._ramSSCounter = 0
        if 'RAMDUMP' not in os.listdir():
            os.mkdir('RAMDUMP')

        self._gfxSSCounter = 0
        if 'GFXDUMP' not in os.listdir():
            os.mkdir('GFXDUMP')
        self.driver = driver
        self.stringDict = stringDict
コード例 #3
0
    def __init__(self, driver, stringDict={}, conf=None):
        "CONFIG"
        if conf == None:
            conf = ConfigFile.Config()

        self._assertionDebug = conf.ASSERTION_DEBUG
        self.driver = driver
        self.stringDict = stringDict
        self.n_test_cases = 0
        self.n_test_pass = 0
        self.n_test_fail = 0
        self.l_test_fail = list()
        self.DEVICE_NAME = driver.name
        self.tls = TestLink(conf.DEVKEY, conf.TESTLINK_URL,
                            str(conf.TESTPLANID), str(conf.BUILDID),
                            str(conf.PLATFORMID), conf.RESULTASSIGNMENT,
                            self.DEVICE_NAME)
        self.conf = conf
コード例 #4
0
ファイル: DriverFactory.py プロジェクト: monopecez/python-pom
	def getDriver(self, port = 4723, installAppium = True, resetApp = False, config = ConfigFile.Config()):
		'''Initialize driver and return an initialized driver.
		Parameters:
		port: int, default 4723
			Port number of appium server. Set up another server on another port to run a parallelized test.
			Default value is 4723. 
		installAppium: bool, default True
			Install appium settings on device under test. Set to False IF appium settings has been installed, speed up initialization process
			Default value is True
		resetApp: bool, default False
			Reset application under test, revert to newly installed condition. Same as clear data before launch or fresh install.
			Default value is False
		config: Configuration file
			May be left blank and it will use ConfigFile.Config() file if parameter was left blank'''
	
		try:
			logging.info("Checking for adb.exe executable ...")
			subprocess.run('adb.exe version')
		except:
			logging.info("adb.exe executable is not found on PATH variable")
			logging.info("using supplied adb.exe files inside Utils folder")
			self._adbPrefix = '.\\Utils\\platform-tools\\'
		
		deviceName = config.DEVICE_NAME
		self._appPackage = config.PACKAGE_NAME
		self._appActivity = config.MAIN_ACTIVITY
		
		if not deviceName:
			deviceName = subprocess.getoutput(self._adbPrefix + 'adb.exe devices').splitlines()[1].split('\t')[0]
			_cmd = self._adbPrefix + 'adb.exe shell getprop ro.build.version.release'
		else:
			_cmd = self._adbPrefix + 'adb.exe -s ' + deviceName + ' shell getprop ro.build.version.release'
		
		if self._appPackage == None or self._appActivity == None:
			self._appPackage = 'com.android.settings'
			self._appActivity = '.Settings'
			logging.info("%s either appPackage or appActivity is empty, starting in Android Settings Activity" % deviceName)

		
		_platformVersion = subprocess.getoutput(_cmd)
		self._desired_caps = {
			'platformName': 'Android',
			'platformVersion': _platformVersion,
			'udid': deviceName,
			'deviceName': deviceName,
			'automationName': 'UiAutomator2',
			'skipServerInstallation': 'true',
			'dontStopAppOnReset': 'true',
			'newCommandTimeout': '1200'
			}
		
		if config.APK_LOCATION is not None:
			logging.info("Config.APK_LOCATION is not empty. Overriding any ACTIVITY_NAME or PACKAGE_NAME")
			logging.info("using and installing apk from %s" % config.APK_LOCATION)
			self._appLocation = config.APK_LOCATION
			self._desired_caps['app'] = self._appLocation
		else:
			self._appLocation = None
			self._desired_caps['appPackage'] = self._appPackage
			self._desired_caps['appActivity'] = self._appActivity


		self._desired_caps['autoWebView'] = 'true'
		self._port = port
		self._deviceName = deviceName
		if installAppium:
			self._desired_caps['skipServerInstallation'] = 'false'
		else:
			self._desired_caps['skipServerInstallation'] = 'true'
		logging.info('%s %s' % (deviceName, str(self._desired_caps)))
		logging.info('%s connecting to %s' % (deviceName, deviceName)) 
		self._driver = webdriver.Remote('http://127.0.0.1:' + str(port) + '/wd/hub', desired_capabilities = self._desired_caps, keep_alive =True)
		self._width = self._driver.get_window_size()['width']
		self._height = self._driver.get_window_size()['height']
		self.config = config
		logging.info('%s connected' % deviceName)
		if resetApp: self._driver.reset()
		return self._driver