Пример #1
0
def pytest_generate_tests(metafunc):
    os.environ["TEST_BROWSERS"] = "chrome"
    stitches = [
        dict(stitch_mode=StitchMode.CSS),
        dict(stitch_mode=StitchMode.Scroll)
    ]

    if strtobool(os.getenv("TEST_RUN_ON_VG", "False")):
        stitches = [dict(stitch_mode=StitchMode.CSS)]
        if "eyes_class" in metafunc.fixturenames:
            metafunc.parametrize("eyes_class", [vg_eyes]),

    if "batch_info" in metafunc.fixturenames:
        b_info = BatchInfo("Python SDK Desktop Sel")
        if strtobool(os.getenv("TEST_RUN_ON_VG", "False")):
            b_info = BatchInfo("Python SDK Desktop VG")
        metafunc.parametrize("batch_info", [b_info])

    if "page" in metafunc.fixturenames:
        metafunc.parametrize("page", ["mobile", "desktop", "scrolled_mobile"])
    if "eyes" in metafunc.fixturenames:
        metafunc.parametrize(
            "eyes",
            stitches,
            indirect=True,
            ids=lambda o: "CSS"
            if o["stitch_mode"] == StitchMode.CSS else "Scroll",
        ),
Пример #2
0
def set_up(eyes):

    # You can get your api key from the Applitools dashboard
    eyes.configure.set_api_key("APPLITOOLS_API_KEY")

    # set new batch
    eyes.configure.set_batch(BatchInfo("Demo batch"))
def set_up(eyes):

    # You can get your api key from the Applitools dashboard
    eyes.configure.set_api_key(api_key)

    # create a new batch info instance and set it to the configuration
    eyes.configure.set_batch(BatchInfo(batch_name))

    # Add browsers with different viewports
    # Add mobile emulation devices in Portrait mode
    (eyes.configure.add_browser(
        desktop_viewport.get("width"),
        desktop_viewport.get("height"), BrowserType.CHROME).add_browser(
            desktop_viewport.get("width"),
            desktop_viewport.get("height"), BrowserType.FIREFOX).add_browser(
                desktop_viewport.get("width"), desktop_viewport.get("height"),
                BrowserType.EDGE
            )  # Edge will be depricated, but EDGE_CHROMIUM isn't valid yet.
     .add_browser(
         tablet_viewport.get("width"),
         tablet_viewport.get("height"), BrowserType.CHROME).add_browser(
             tablet_viewport.get("width"),
             tablet_viewport.get("height"), BrowserType.FIREFOX).add_browser(
                 tablet_viewport.get("width"), tablet_viewport.get("height"),
                 BrowserType.EDGE).add_device_emulation(
                     DeviceName.iPhone_X)  # Viewport doesn't match rules.
     )
def set_up(eyes):
    eyes.configure.set_api_key(
        "3j06RRiK1c2pjjfw98uCO3I9bgpjCmiNSa100QhnVKRznk110")
    eyes.configure.set_batch(BatchInfo("Ultrafast Batch"))
    (eyes.configure.add_browser(800, 600, BrowserType.CHROME).add_browser(
        700, 500, BrowserType.FIREFOX).add_browser(
            1600, 1200, BrowserType.IE_11).add_browser(
                1024, 768, BrowserType.EDGE_CHROMIUM).add_browser(
                    800, 600, BrowserType.SAFARI).add_device_emulation(
                        DeviceName.iPhone_X).add_device_emulation(
                            DeviceName.Pixel_2))
class HelloWorld:

    eyes = Eyes()

    # Initialize the eyes SDK and set your private API key.
    eyes.api_key = os.environ['APPLITOOLS_API_KEY']

    # obtain the ID from the environment variables - the name should be specified as None
    batch_name = None
    batch_id = os.environ.get('APPLITOOLS_BATCH_ID')

    # set the batch
    batch_info = BatchInfo(batch_name)
    batch_info.id = batch_id
    eyes.batch = batch_info

    try:
        capabilities = {
            'browserName': 'chrome',
            'browserVersion': '78.0',
            'platformName': 'Windows 10',
            'sauce:options': {}
        }
        # Open a Chrome browser.
        username = os.environ["SAUCE_USERNAME"]
        access_key = os.environ["SAUCE_ACCESS_KEY"]
        capabilities["tunnel-identifier"] = os.environ["TRAVIS_JOB_NUMBER"]
        hub_url = "%s:%s@localhost:4445" % (username, access_key)
        driver = webdriver.Remote(desired_capabilities=capabilities,
                                  command_executor="http://%s/wd/hub" %
                                  hub_url)

        # Start the test and set the browser's viewport size to 800x600.
        eyes.open(driver, "Test app", "First test", {
            'width': 800,
            'height': 600
        })

        # Navigate the browser to the "hello world!" web-site.
        driver.get('https://applitools.com/helloworld')

        # Visual checkpoint #1.
        eyes.check("Login Window test", Target.window())

        # End the test.
        eyes.close()

    finally:

        # Close the browser.
        driver.quit()

        # If the test was aborted before eyes.close was called, ends the test as aborted.
        eyes.abort()
Пример #6
0
def test_eyes_runner(driver, runner):
    eyes = Eyes(runner)
    eyes2 = Eyes(runner)
    batch_info = BatchInfo("Runner Testing")
    config = (
        Configuration()
        .set_send_dom(True)
        .set_hide_scrollbars(True)
        .set_stitch_mode(StitchMode.CSS)
        .set_batch(batch_info)
    )
    eyes.set_configuration(config)
    eyes2.set_configuration(config)
    driver.get(
        "http://applitools.github.io/demo/TestPages/VisualGridTestPage/index.html"
    )
    eyes.add_property(
        "Runner", "VisualGrid" if isinstance(runner, VisualGridRunner) else "Selenium"
    )
    eyes.open(
        driver,
        "Applitools Eyes Java SDK",
        "Classic Runner Test",
        dict(width=1200, height=800),
    )
    eyes2.open(
        driver,
        "Applitools Eyes Java SDK",
        "Classic Runner 2 Test",
        dict(width=1200, height=800),
    )

    eyes.check("Step 1", Target.window().fully().ignore_displacements(False))
    eyes2.check("Step 1", Target.window().fully().ignore_displacements(False))

    eyes.close_async()

    eyes.open(
        driver,
        "Applitools Eyes Java SDK",
        "Classic Runner Test",
        dict(width=1200, height=800),
    )
    eyes.check("Step 2", Target.window().fully().ignore_displacements(False))
    eyes.close_async()
    eyes2.close(True)

    driver.quit()
    all_tests_results = runner.get_all_test_results()
    if len(all_tests_results.all_results) != 3:
        raise Exception
Пример #7
0
    def create_batch_info(
            self,
            name,  # type: Text
            started_at=None,  # type: Optional[Union[datetime,Text]]
            batch_sequence_name=None,  # type: Optional[Text]
            batch_id=None,  # type: Optional[Text]
    ):
        # type: (...) -> Text
        """
        Returns a BatchInfo ID string that may be used as batch argument on `Eyes Open`.

            | =Arguments=                  | =Description=                                                                              |
            | Name                         | The name of the batch                                                                      |
            | Started At                   | The date and time that will be displayed in the Test Manager as the batch start time *(*)* |
            | Batch ID                     | This argument groups together tests ran in different executions                            |

        The *Started At* argument may be passed as:
        - String: YYYY-mm-dd HH:MM:SS
        - Datetime variable: See [https://robotframework.org/robotframework/latest/libraries/DateTime.html|DateTime library]

        *Example:*
            | ${batch_id}= | Create Eyes Batch |
        """

        if started_at:
            if isinstance(started_at, basestring):
                started_at = datetime.strptime(started_at, "%Y-%m-%d %H:%M:%S")
            elif not isinstance(started_at, datetime):
                raise TypeError(
                    "BatchInfo started_at should be `str` or `datetime`")
        batch = BatchInfo(name,
                          started_at=started_at,
                          batch_sequence_name=batch_sequence_name)
        if batch_id:
            batch = batch.with_batch_id(batch_id)
        self.ctx.register_or_get_batch(batch)
        return batch.id
Пример #8
0
def step_impl(context):
    title = context.browser.title
    if "Chick-fil-A Login" in title:
        print("We Have logged out of the application")
    batch_info = BatchInfo('CFAHome - Logout Check')
    eyes.batch = batch_info
    eyes.open(context.browser, "CFAHome", "Logout Check")
    eyes.match_level = MatchLevel.LAYOUT
    eyes.force_full_page_screenshot = True
    eyes.check(context.browser.current_url + "Log Out", Target.window())

    # # End the test.
    eyes.close()

    print(u'STEP: Then I should be logged out of the application')
Пример #9
0
def batch_info(tmp_path_factory, worker_id):
    #If there's only 1 thread, it's called master
    if worker_id == "master":
        my_batch_info = BatchInfo("Pytest Batch")
        yield my_batch_info

    root_tmp_dir = tmp_path_factory.getbasetemp().parent
    my_batch_info = BatchInfo("Pytest Batch")
    fn = root_tmp_dir / "data.json"

    with FileLock(str(fn) + ".lock"):
        if fn.is_file():
            my_batch_info.with_batch_id(int(json.loads(fn.read_text())))
        else:
            batchId = random.randint(0, 999999)
            my_batch_info.with_batch_id(batchId)
            fn.write_text(json.dumps(str(batchId)))
    yield my_batch_info
def sel_config(test_page_url):
    conf = Configuration()
    conf.test_name = "Top 10 websites - {}".format(test_page_url)
    conf.app_name = "Top Ten Sites"
    conf.batch = BatchInfo("Python VisualGrid")
    conf.branch_name = "TTS - config branch"
    conf.add_browser(800, 600, BrowserType.CHROME)
    conf.add_browser(700, 500, BrowserType.FIREFOX)
    # conf.add_browser(700, 500, BrowserType.IE_10)
    # conf.add_browser(700, 500, BrowserType.IE_11)
    conf.add_browser(1600, 1200, BrowserType.CHROME)
    conf.add_browser(1200, 800, BrowserType.EDGE)
    conf.add_browser(800, 600, BrowserType.CHROME)
    conf.add_browser(700, 500, BrowserType.CHROME)
    conf.add_device_emulation(DeviceName.iPhone_4)
    conf.add_device_emulation(DeviceName.iPhone_X)
    conf.add_device_emulation(DeviceName.Nexus_10, ScreenOrientation.LANDSCAPE)
    return conf
Пример #11
0
def set_up(eyes):

    # You can get your api key from the Applitools dashboard
    eyes.configure.set_api_key("APPLITOOLS_API_KEY")

    # create a new batch info instance and set it to the configuration
    eyes.configure.set_batch(BatchInfo("Ultrafast Batch"))

    # Add browsers with different viewports
    # Add mobile emulation devices in Portrait mode
    (
        eyes.configure.add_browser(800, 600, BrowserType.CHROME)
        .add_browser(700, 500, BrowserType.FIREFOX)
        .add_browser(1600, 1200, BrowserType.IE_11)
        .add_browser(1024, 768, BrowserType.EDGE_CHROMIUM)
        .add_browser(800, 600, BrowserType.SAFARI)
        .add_device_emulation(DeviceName.iPhone_X)
        .add_device_emulation(DeviceName.Pixel_2)
    )
Пример #12
0
def step_impl(context, items):
    itemName = context.browser.find_element_by_xpath(
        '(//div[@class="source-title"])').text
    context.browser.find_element_by_xpath(
        '(//div[@class="source-title"])').click()
    if itemName == items:
        print(itemName)

    batch_info = BatchInfo('CFAHome - Search results check - Exact Match')
    eyes.batch = batch_info
    eyes.open(context.browser, "CFAHome", "Search Results Check - Exact Match")
    eyes.match_level = MatchLevel.LAYOUT
    #eyes.force_full_page_screenshot = True
    eyes.check(
        context.browser.current_url + itemName + " Search Results Check",
        Target.window())

    # # End the test.
    eyes.close()
    print(u'STEP: Then I should see <items> in the search results')
Пример #13
0
def set_up(eyes):

    # You can get your api key from the Applitools dashboard

    APPLITOOLS_API_KEY = os.environ["APPLITOOLS_API_KEY"]
    eyes.configure.set_api_key(APPLITOOLS_API_KEY)

    # create a new batch info instance and set it to the configuration
    eyes.configure.set_batch(BatchInfo("UFG Hackathon"))

    # Add browsers with different viewports
    # Add mobile emulation devices in Portrait mode
    (
        eyes.configure.add_browser(1200, 700, BrowserType.CHROME)
        .add_browser(1200, 700, BrowserType.FIREFOX)
        .add_browser(1200, 700, BrowserType.EDGE_CHROMIUM)
        .add_browser(768, 700, BrowserType.CHROME)
        .add_browser(768, 700, BrowserType.FIREFOX)
        .add_browser(768, 700, BrowserType.EDGE_CHROMIUM)
        .add_device_emulation(DeviceName.iPhone_X)
    )
def py_eyes():
    runner = VisualGridRunner(10)
    py_eyes = Eyes(runner)
    # You can get your api key from the Applitools dashboard
    api_key = os.environ["APPLITOOLS_API_KEY"]
    py_eyes.configure.set_api_key(api_key)

    # create a new batch info instance and set it to the configuration
    py_eyes.configure.set_batch(BatchInfo("UFG Hackaton"))

    # Add browsers with different viewports
    # Add mobile emulation devices in Portrait mode
    (py_eyes.configure.add_browser(1200, 700, BrowserType.CHROME).add_browser(
        1200, 700, BrowserType.FIREFOX).add_browser(
            1200, 700, BrowserType.EDGE_CHROMIUM).add_browser(
                768, 700, BrowserType.CHROME).add_browser(
                    1200, 700, BrowserType.FIREFOX).add_browser(
                        1200, 700,
                        BrowserType.EDGE_CHROMIUM).add_device_emulation(
                            DeviceName.iPhone_X)  # Portrait mode
     )
    yield py_eyes
    all_test_results = runner.get_all_test_results(False)
    print(all_test_results)
def initialize_eyes(runner):
    eyes = Eyes(runner)
    # Set API key
    eyes.api_key = "YOU API KEY"

    # If dedicated or on-prem cloud, uncomment and enter the cloud url
    # Default: https://eyes.applitools.com
    # eyes.server_url = "https://testeyes.applitools.com"

    # Create SeleniumConfiguration.
    sconf = Configuration()

    # Set the AUT name
    sconf.app_name = "Blank App"

    # Set a test name
    sconf.test_name = "Smoke Test via Visual Grid"

    #  Set a batch name so all the different browser and mobile combinations are
    #  part of the same batch
    sconf.batch = BatchInfo("VIP Browser combo batch")

    # Add Chrome browsers with different Viewports
    sconf.add_browser(800, 600, BrowserType.CHROME)
    sconf.add_browser(700, 500, BrowserType.CHROME)

    # Add Firefox browser with different Viewports
    sconf.add_browser(1200, 800, BrowserType.FIREFOX)
    sconf.add_browser(1600, 1200, BrowserType.FIREFOX)

    # Add iPhone 4 device emulation
    sconf.add_device_emulation(DeviceName.iPhone_4)

    # Set the configuration object to eyes
    eyes.configuration = sconf
    return eyes
Пример #16
0
 def batch_info():
     return BatchInfo("Python SDK Desktop Selenium")
Пример #17
0
def batch_info():
    """
    Use one BatchInfo for all tests inside module
    """
    return BatchInfo("Demo Batch - Selenium for Python - Ultrafast")
Пример #18
0
def batch_info():
    """
    Use one BatchInfo for all tests inside module
    """
    return BatchInfo("Some general Test cases name")
from selenium.webdriver.support.wait import WebDriverWait

from applitools.selenium import Eyes, BatchInfo, Target

batch_info = BatchInfo("Test Visual Grid RCA")


def test_VG_RCA_config(driver, vg_runner):
    eyes = Eyes(vg_runner)
    eyes.batch = batch_info
    driver.get(
        "https://applitools.github.io/demo/TestPages/VisualGridTestPage")
    eyes.open(driver, "Test Visual Grid", "Test RCA Config")
    eyes.send_dom = True
    eyes.check("", Target.window())
    eyes.close()
    vg_runner.get_all_test_results()


def test_VG_RCA_fluent(driver, vg_runner):
    eyes = Eyes(vg_runner)
    eyes.batch = batch_info
    driver.get(
        "https://applitools.github.io/demo/TestPages/VisualGridTestPage")
    driver.switch_to.frame("iframe")
    WebDriverWait(driver, 30)
    driver.switch_to.default_content()

    eyes.open(driver, "Test Visual Grid", "Test RCA Fluent")
    eyes.send_dom = True
    eyes.check("", Target.window().send_dom(True))
Пример #20
0
 def check_and_return(self, value, context=None):
     sanitized = self.scheme.check(value, context=context)
     batch = BatchInfo()
     for key, val in sanitized.items():
         setattr(batch, key, val)
     return batch
Пример #21
0
def batch_info():
    return BatchInfo("Python SDK VisualGridTests")
import os
import pytest
from applitools.selenium import (
    logger,
    FileLogger,
    VisualGridRunner,
    Eyes,
    BatchInfo,
    BrowserType,
    DeviceName,
    ScreenOrientation,
)
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

batch_info = BatchInfo("Holiday Shopping")


def eyes_setup(runner):
    eyes = Eyes(runner)
    logger.set_logger(FileLogger("mostrecent.log", mode="w"))
    # Initialize the eyes SDK and set your private API key.
    eyes.api_key = os.environ["APPLITOOLS_KEY"]
    return eyes


@pytest.fixture(name="chrome_eyes", scope="function")
def chrome_eyes_setup(runner):
    """
    Basic Eyes setup for Chrome browser only. It'll abort test if not closed properly.
    """
Пример #23
0
def batch_info():
    """
    Use one BatchInfo for all tests inside module
    """
    return BatchInfo("Ultrafast Batch")
Пример #24
0
def batch_info():
    return BatchInfo("FZ UI Verification cases")
Пример #25
0
def batch_info():
    return BatchInfo("Python Generated tests")
Пример #26
0
 def batch_info():
     return BatchInfo("Python SDK Desktop VG")