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