예제 #1
0
        """
        Method to save screenshot to a given path with the function name
        :param funcName: Function name
        :param defaultPath:  is an optional paramter
        :return: None
        """
        path = os.path.dirname(os.path.dirname(__file__))
        path = path + "\\reports\\report_" + str(
            datetime.datetime.now().date()) + os.sep
        try:
            if not os.path.exists(path):
                print("path is not there creating...")
                os.makedirs(path)
            name = path + funcName + str(
                datetime.datetime.now().time()).replace(":", "_") + ".jpg"
            print(name)
            self._browser.get_screenshot_as_file(name)
        except Exception, e:
            print(e)

if __name__ == "__main__":
    params = {"name": "Vinay"}
    myBrowser = Browser(params)
    myBrowser.go_to("http://google.com")
    Webaction = WebElementAction(myBrowser)
    Webaction.input_text("SearchButton", "Vinay")
    Webaction.submit_form("SearchButton")
    #Webaction.press_key("SearchButton","ENTER")
    time.sleep(3)
    myBrowser.quit()