Add method: "save_screenshot_to_logs()"
This commit is contained in:
parent
e43746f930
commit
ccfd4a5456
|
@ -205,6 +205,8 @@ self.switch_to_default_driver()
|
|||
|
||||
self.save_screenshot(name, folder=None)
|
||||
|
||||
self.save_screenshot_to_logs(name=None)
|
||||
|
||||
self.save_page_source(name, folder=None)
|
||||
|
||||
self.save_cookies(name="cookies.txt")
|
||||
|
|
|
@ -2285,10 +2285,37 @@ class BaseCase(unittest.TestCase):
|
|||
self.browser = self.__driver_browser_map[self.driver]
|
||||
|
||||
def save_screenshot(self, name, folder=None):
|
||||
""" The screenshot will be in PNG format. """
|
||||
"""Saves a screenshot of the current page.
|
||||
If no folder is specified, uses the folder where pytest was called.
|
||||
The screenshot will be in PNG format."""
|
||||
self.wait_for_ready_state_complete()
|
||||
return page_actions.save_screenshot(self.driver, name, folder)
|
||||
|
||||
def save_screenshot_to_logs(self, name=None):
|
||||
"""Saves a screenshot of the current page to the "latest_logs" folder.
|
||||
Naming is automatic:
|
||||
If NO NAME provided: "_1_screenshot.png", "_2_screenshot.png", etc.
|
||||
If NAME IS provided, it becomes: "_1_name.png", "_2_name.png", etc.
|
||||
(The last_page / failure screenshot is always "screenshot.png")
|
||||
The screenshot will be in PNG format."""
|
||||
self.wait_for_ready_state_complete()
|
||||
test_id = self.__get_test_id()
|
||||
test_logpath = self.log_path + "/" + test_id
|
||||
self.__create_log_path_as_needed(test_logpath)
|
||||
if name:
|
||||
name = str(name)
|
||||
self.__screenshot_count += 1
|
||||
if not name or len(name) == 0:
|
||||
name = "_%s_screenshot.png" % self.__screenshot_count
|
||||
else:
|
||||
pre_name = "_%s_" % self.__screenshot_count
|
||||
if len(name) >= 4 and name[-4:].lower() == ".png":
|
||||
name = name[:-4]
|
||||
if len(name) == 0:
|
||||
name = "screenshot"
|
||||
name = "%s%s.png" % (pre_name, name)
|
||||
return page_actions.save_screenshot(self.driver, name, test_logpath)
|
||||
|
||||
def save_page_source(self, name, folder=None):
|
||||
""" Saves the page HTML to the current directory (or given subfolder).
|
||||
If the folder specified doesn't exist, it will get created.
|
||||
|
|
|
@ -217,6 +217,10 @@ class 硒测试用例(BaseCase): # noqa
|
|||
# save_screenshot(name)
|
||||
return self.save_screenshot(*args, **kwargs)
|
||||
|
||||
def 保存截图到日志(self, *args, **kwargs):
|
||||
# save_screenshot_to_logs(name)
|
||||
return self.save_screenshot_to_logs(*args, **kwargs)
|
||||
|
||||
def 选择文件(self, *args, **kwargs):
|
||||
# choose_file(selector, file_path)
|
||||
return self.choose_file(*args, **kwargs)
|
||||
|
|
|
@ -217,6 +217,10 @@ class Testgeval(BaseCase):
|
|||
# save_screenshot(name)
|
||||
return self.save_screenshot(*args, **kwargs)
|
||||
|
||||
def bewaar_screenshot_om_te_loggen(self, *args, **kwargs):
|
||||
# save_screenshot_to_logs(name)
|
||||
return self.save_screenshot_to_logs(*args, **kwargs)
|
||||
|
||||
def selecteer_bestand(self, *args, **kwargs):
|
||||
# choose_file(selector, file_path)
|
||||
return self.choose_file(*args, **kwargs)
|
||||
|
|
|
@ -217,6 +217,10 @@ class CasDeBase(BaseCase):
|
|||
# save_screenshot(name)
|
||||
return self.save_screenshot(*args, **kwargs)
|
||||
|
||||
def enregistrer_capture_d_écran_aux_logs(self, *args, **kwargs):
|
||||
# save_screenshot_to_logs(name)
|
||||
return self.save_screenshot_to_logs(*args, **kwargs)
|
||||
|
||||
def sélectionner_fichier(self, *args, **kwargs):
|
||||
# choose_file(selector, file_path)
|
||||
return self.choose_file(*args, **kwargs)
|
||||
|
|
|
@ -217,6 +217,10 @@ class CasoDiProva(BaseCase):
|
|||
# save_screenshot(name)
|
||||
return self.save_screenshot(*args, **kwargs)
|
||||
|
||||
def salva_screenshot_nei_logs(self, *args, **kwargs):
|
||||
# save_screenshot_to_logs(name)
|
||||
return self.save_screenshot_to_logs(*args, **kwargs)
|
||||
|
||||
def seleziona_file(self, *args, **kwargs):
|
||||
# choose_file(selector, file_path)
|
||||
return self.choose_file(*args, **kwargs)
|
||||
|
|
|
@ -217,6 +217,10 @@ class セレニウムテストケース(BaseCase): # noqa
|
|||
# save_screenshot(name)
|
||||
return self.save_screenshot(*args, **kwargs)
|
||||
|
||||
def ログにスクリーンショットを保存(self, *args, **kwargs):
|
||||
# save_screenshot_to_logs(name)
|
||||
return self.save_screenshot_to_logs(*args, **kwargs)
|
||||
|
||||
def ファイルを選択(self, *args, **kwargs):
|
||||
# choose_file(selector, file_path)
|
||||
return self.choose_file(*args, **kwargs)
|
||||
|
|
|
@ -217,6 +217,10 @@ class 셀레늄_테스트_케이스(BaseCase): # noqa
|
|||
# save_screenshot(name)
|
||||
return self.save_screenshot(*args, **kwargs)
|
||||
|
||||
def 로그에_스크린_샷_저장(self, *args, **kwargs):
|
||||
# save_screenshot_to_logs(name)
|
||||
return self.save_screenshot_to_logs(*args, **kwargs)
|
||||
|
||||
def 파일을_선택(self, *args, **kwargs):
|
||||
# choose_file(selector, file_path)
|
||||
return self.choose_file(*args, **kwargs)
|
||||
|
|
|
@ -851,6 +851,18 @@ class MD:
|
|||
md["save_screenshot"][8] = "сохранить_скриншот"
|
||||
md["save_screenshot"][9] = "guardar_captura_de_pantalla"
|
||||
|
||||
md["save_screenshot_to_logs"] = ["*"] * num_langs
|
||||
md["save_screenshot_to_logs"][0] = "save_screenshot_to_logs"
|
||||
md["save_screenshot_to_logs"][1] = "保存截图到日志"
|
||||
md["save_screenshot_to_logs"][2] = "bewaar_screenshot_om_te_loggen"
|
||||
md["save_screenshot_to_logs"][3] = "enregistrer_capture_d_écran_aux_logs"
|
||||
md["save_screenshot_to_logs"][4] = "salva_screenshot_nei_logs"
|
||||
md["save_screenshot_to_logs"][5] = "ログにスクリーンショットを保存"
|
||||
md["save_screenshot_to_logs"][6] = "로그에_스크린_샷_저장"
|
||||
md["save_screenshot_to_logs"][7] = "salvar_captura_de_tela_para_logs"
|
||||
md["save_screenshot_to_logs"][8] = "сохранить_скриншот_в_логи"
|
||||
md["save_screenshot_to_logs"][9] = "guardar_captura_de_pantalla_para_logs"
|
||||
|
||||
md["choose_file"] = ["*"] * num_langs
|
||||
md["choose_file"][0] = "choose_file"
|
||||
md["choose_file"][1] = "选择文件"
|
||||
|
|
|
@ -217,6 +217,10 @@ class CasoDeTeste(BaseCase):
|
|||
# save_screenshot(name)
|
||||
return self.save_screenshot(*args, **kwargs)
|
||||
|
||||
def salvar_captura_de_tela_para_logs(self, *args, **kwargs):
|
||||
# save_screenshot_to_logs(name)
|
||||
return self.save_screenshot_to_logs(*args, **kwargs)
|
||||
|
||||
def selecionar_arquivo(self, *args, **kwargs):
|
||||
# choose_file(selector, file_path)
|
||||
return self.choose_file(*args, **kwargs)
|
||||
|
|
|
@ -217,6 +217,10 @@ class ТестНаСелен(BaseCase): # noqa
|
|||
# save_screenshot(name)
|
||||
return self.save_screenshot(*args, **kwargs)
|
||||
|
||||
def сохранить_скриншот_в_логи(self, *args, **kwargs):
|
||||
# save_screenshot_to_logs(name)
|
||||
return self.save_screenshot_to_logs(*args, **kwargs)
|
||||
|
||||
def выберите_файл(self, *args, **kwargs):
|
||||
# choose_file(selector, file_path)
|
||||
return self.choose_file(*args, **kwargs)
|
||||
|
|
|
@ -217,6 +217,10 @@ class CasoDePrueba(BaseCase):
|
|||
# save_screenshot(name)
|
||||
return self.save_screenshot(*args, **kwargs)
|
||||
|
||||
def guardar_captura_de_pantalla_para_logs(self, *args, **kwargs):
|
||||
# save_screenshot_to_logs(name)
|
||||
return self.save_screenshot_to_logs(*args, **kwargs)
|
||||
|
||||
def seleccionar_archivo(self, *args, **kwargs):
|
||||
# choose_file(selector, file_path)
|
||||
return self.choose_file(*args, **kwargs)
|
||||
|
|
Loading…
Reference in New Issue