def save_element_as_image_file(self, selector, file_name, folder=None):
element = self.find_element(selector)<EOL>element_png = element.screenshot_as_png<EOL>if len(file_name.split('<STR_LIT:.>')[<NUM_LIT:0>]) < <NUM_LIT:1>:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>if not file_name.endswith("<STR_LIT>"):<EOL><INDENT>file_name = file_name + "<STR_LIT>"<EOL><DEDENT>image_file_path = None<EOL>if folder:<EOL><INDENT>if folder.endswith("<STR_LIT:/>"):<EOL><INDENT>folder = folder[:-<NUM_LIT:1>]<EOL><DEDENT>if len(folder) > <NUM_LIT:0>:<EOL><INDENT>self.create_folder(folder)<EOL>image_file_path = "<STR_LIT>" % (folder, file_name)<EOL><DEDENT><DEDENT>if not image_file_path:<EOL><INDENT>image_file_path = file_name<EOL><DEDENT>with open(image_file_path, "<STR_LIT:wb>") as file:<EOL><INDENT>file.write(element_png)<EOL><DEDENT>
Take a screenshot of an element and save it as an image file.
            If no folder is specified, will save it to the current folder.