def py_type(self, obj, friendlyName, data, verify=False): """ Types the given data into the object requested Arguments: obj -- Object to type into friendlyName -- Friendly name for the object, used in logging data -- data to type into the object Keyword Arguments: verify -- true to retrieve the text after typing and retry to type the value if it does not match the data given Returns: Resulting text contained by the given object """ try: tgto = TextGuiTestObject(obj) tgto.setText(data) if verify: RationalTestScript.sleep(0.2) if (tgto.getText() == data) == False: tgto.setText(data) return tgto.getText() except UnregisteredObjectException: Log.logError( "Failed to type " + data + " Into " + friendlyName + " because the object became unregistered.", Console.getScreenshot(), ) except WindowActivateFailedException: Log.logError( "Failed to type " + data + " Into " + friendlyName + " because it is disabled.", Console.getScreenshot() ) except ObjectIsDisposedException: Log.logError( "Failed to type " + data + " Into " + friendlyName + " because the object was disposed.", Console.getScreenshot(), ) except: exception = sys.exc_info()[1] if isinstance(exception, Exception): Log.logException(exception, "Failed to type " + data + " Into " + friendlyName) else: Log.logError("Failed to type " + data + " Into " + friendlyName, exception.__str__()) return ""
def py_select(self, itemName, data): tos = self.findKnownItems(itemName, 30) if(tos and len(tos) > 0): value = self.super__getActionLib().py_select(tos[0], data, itemName) RationalTestScript.unregister(tos) return value
def py_type(self, itemName, data, verify=True): tos = self.findKnownItems(itemName, 30) if(tos and len(tos) > 0): value = self.super__getActionLib().py_type(tos[0], itemName, data, verify) RationalTestScript.unregister(tos) return value
Created on Dec 19, 2011 @author: smcadams """ from com.rational.test.ft.script import RationalTestScript from python.screens.GoogleSearch import GoogleSearch if __name__ == "__main__": # Open Google Search Page search = GoogleSearch(launch=True) # Type Into the Search Box search.type("Google Search Box", "Java Testing", True) RationalTestScript.sleep(3) # For Demo purposes # Click the Images link on the left hand side search.click("Images") # wait for the browser to finish loading search.browser.sync(20, 1) # Using Jython click evertyhing link on left hand side search.py_click("Everything") RationalTestScript.sleep(3) # For Demo purposes # waid for browser to finish loading search.browser.sync(20, 1)
def launch(self): self.browser = Browser("www.google.com") RationalTestScript.sleep(2)
def __init__(self, url): cmdLine = "\"" + self.ie_folder + os.sep + self.ie_name + "\" \"" + url.strip() + "\""; self.rootBrowserProcess = RationalTestScript.run(cmdLine, None); self.rootBrowserProcess.waitForExistence(120, 1)
def launch(self, url): self.browser = Browser(url) RationalTestScript.sleep(2)