make screenshots
This commit is contained in:
@@ -2,7 +2,6 @@ import pytest
|
|||||||
import logging
|
import logging
|
||||||
import allure
|
import allure
|
||||||
from selenium.webdriver import Chrome, ChromeOptions
|
from selenium.webdriver import Chrome, ChromeOptions
|
||||||
from webdriver_manager.chrome import ChromeDriverManager
|
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
@@ -14,8 +13,8 @@ class Config:
|
|||||||
def driver():
|
def driver():
|
||||||
options = ChromeOptions()
|
options = ChromeOptions()
|
||||||
options.add_argument("--headless")
|
options.add_argument("--headless")
|
||||||
webdriver = Chrome(ChromeDriverManager().install(), desired_capabilities=options.to_capabilities())
|
webdriver = Chrome('/home/ashatora/yandexdriver', options=options)
|
||||||
webdriver.implicitly_wait(5)
|
webdriver.implicitly_wait(2)
|
||||||
yield webdriver
|
yield webdriver
|
||||||
allure.attach(webdriver.current_url, "last url", allure.attachment_type.URI_LIST)
|
allure.attach(webdriver.current_url, "last url", allure.attachment_type.URI_LIST)
|
||||||
webdriver.quit()
|
webdriver.quit()
|
||||||
@@ -24,13 +23,13 @@ def driver():
|
|||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
"""Command line parser."""
|
"""Command line parser."""
|
||||||
parser.addoption(f'--{Config.BASE_URL}',
|
parser.addoption(f'--{Config.BASE_URL}',
|
||||||
default='https://go.mail.ru/',
|
default='https://s57.ivazh.ru/styles/r14/#12.13/71.2832/72.13405',
|
||||||
dest=Config.BASE_URL,
|
dest=Config.BASE_URL,
|
||||||
action='store',
|
action='store',
|
||||||
metavar='str',
|
metavar='str',
|
||||||
help='Environment for run tests.')
|
help='Environment for run tests.')
|
||||||
parser.addoption(f'--{Config.STAGING}',
|
parser.addoption(f'--{Config.STAGING}',
|
||||||
default='go.mail.ru',
|
default='s57.ivazh.ru',
|
||||||
dest=Config.STAGING,
|
dest=Config.STAGING,
|
||||||
action='store',
|
action='store',
|
||||||
metavar='str',
|
metavar='str',
|
||||||
|
|||||||
@@ -1,31 +1,20 @@
|
|||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
|
|
||||||
from screenshot_tests.utils.screenshots import TestCase
|
from screenshot_tests.utils.screenshots import TestCase
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
class TestExample(TestCase):
|
class TestExample(TestCase):
|
||||||
"""Tests for https://go.mail.ru"""
|
|
||||||
|
|
||||||
def test_main_page(self):
|
def test_main_page(self):
|
||||||
self.driver.get("https://go.mail.ru/")
|
self.driver.get("https://s57.ivazh.ru/styles/r14/#12.13/71.2832/72.13405")
|
||||||
|
|
||||||
def action():
|
def action():
|
||||||
# Убираем фокус с инпута, чтобы тест не флакал из-за курсора
|
time.sleep(5)
|
||||||
self.driver.find_element(By.XPATH, "//*[text()='найти']").click()
|
|
||||||
|
|
||||||
self.check_by_screenshot(None, action=action, full_page=True)
|
self.check_by_screenshot(None, full_page=True, action=action)
|
||||||
|
|
||||||
def test_main_page_flaky(self):
|
# def test_search_block(self):
|
||||||
self.driver.get("https://go.mail.ru/")
|
# self.driver.get("https://s57.ivazh.ru/styles/r14/#12.13/71.2832/72.13405")
|
||||||
# Чтобы посмотреть как выглядит сломанный тeест в отчетe
|
# self.driver.implicitly_wait(5)
|
||||||
self.driver.find_element(By.XPATH, "//input[not(@type='hidden')]").send_keys("foo")
|
#
|
||||||
self.check_by_screenshot(None, full_page=True)
|
# self.check_by_screenshot((By.CSS_SELECTOR, ".ol-mouse-position"))
|
||||||
|
|
||||||
def test_search_block(self):
|
|
||||||
self.driver.get("https://go.mail.ru/")
|
|
||||||
|
|
||||||
def action():
|
|
||||||
# Тестируем подсветку таба после переключения на другую вертикаль
|
|
||||||
self.driver.find_element(By.XPATH, "//span[contains(text(), 'Соцсети')]").click()
|
|
||||||
|
|
||||||
self.check_by_screenshot((By.CSS_SELECTOR, ".MainVerticalsNav-listItemActive"), action=action)
|
|
||||||
|
|||||||
@@ -95,6 +95,10 @@ class TestCase(common.TestCase):
|
|||||||
y = location["y"]
|
y = location["y"]
|
||||||
width = location["x"] + size['width']
|
width = location["x"] + size['width']
|
||||||
height = location["y"] + size['height']
|
height = location["y"] + size['height']
|
||||||
|
if width == 0:
|
||||||
|
width = 1920
|
||||||
|
if height == 0:
|
||||||
|
height = 1080
|
||||||
# (312, 691, 1112, 691)
|
# (312, 691, 1112, 691)
|
||||||
return x, y, width, height
|
return x, y, width, height
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user