예제 #1
0
    def _focusChrome(self, startsWithTestCaseTitle: re.Pattern):
        """ Ensure chrome started and is focused.
		Different versions of chrome have variations in how the title is presented.
		This may mean that there is a separator between document name and application name.
		E.G. "htmlTest   Google Chrome", "html – Google Chrome" or perhaps no application name at all.
		Rather than try to get this right, just use the doc title.
		If this continues to be unreliable we could use Selenium or similar to start chrome and inform us
		when it is ready.
		"""
        success, _success = _blockUntilConditionMet(
            getValue=lambda: SetForegroundWindow(startsWithTestCaseTitle,
                                                 builtIn.log),
            giveUpAfterSeconds=3,
            intervalBetweenSeconds=0.5)
        if success:
            return
        windowInformation = ""
        try:
            windowInformation = f"Foreground Window: {GetForegroundWindowTitle()}.\n"
            windowInformation += f"Open Windows: {GetVisibleWindowTitles()}"
        except OSError as e:
            builtIn.log(
                f"Couldn't retrieve active window information.\nException: {e}"
            )
        raise AssertionError("Unable to focus Chrome.\n"
                             f"{windowInformation}")
예제 #2
0
	def _focusNotepad(self, startsWithTestCaseTitle: re.Pattern):
		""" Ensure Notepad started and is focused.
		"""
		success, _success = _blockUntilConditionMet(
			getValue=lambda: SetForegroundWindow(startsWithTestCaseTitle, builtIn.log),
			giveUpAfterSeconds=3,
			intervalBetweenSeconds=0.5
		)
		if success:
			return
		windowInformation = ""
		try:
			windowInformation = f"Foreground Window: {GetForegroundWindowTitle()}.\n"
			windowInformation += f"Open Windows: {GetVisibleWindowTitles()}"
		except OSError as e:
			builtIn.log(f"Couldn't retrieve active window information.\nException: {e}")
		raise AssertionError(
			"Unable to focus Notepad.\n"
			f"{windowInformation}"
		)