def userLogin():
    # Set options so that Chrome starts fullscreen
    logger.set_logger(StdoutLogger())
    options = webdriver.ChromeOptions()
    options.add_argument("--start-maximized")

    eyes = Eyes()
    eyes.api_key = "VOfLF4XBAbbMmsOLf0BxDx4APw7gCynQz7NjZwRG1076g110"
    eyes.force_full_page_screenshot = True

    # Get a selenium web driver object.
    # driver = webdriver.Chrome(chrome_options=options)
    driver = webdriver.Firefox()
    # driver = webdriver.Chrome()
    # Make sure to use the returned driver from this point on.
    # Use the following line for a specific viewport_size (WSVGA 16:9)
    eyes.open(
        driver=driver, app_name="Home Reach", test_name="Login to Dash", viewport_size={"width": 1136, "height": 640}
    )
    # No viewport size set - using fullscreen
    # driver = eyes.open(driver=driver, app_name='Home Reach', test_name='Login to Dash')
    # Work-around for eyes SDK issue
    # eyes.open(driver=driver, app_name='Home Reach', test_name='Login to Dash')

    try:
        driver.get("https://homereach.aminocom.com")

        # Visual validation point #1
        eyes.check_window("Login Page")

        driver.find_element_by_id("username").clear()
        driver.find_element_by_id("username").send_keys("rayres-prodlive1")
        driver.find_element_by_id("username").send_keys(u"\ue004")
        driver.find_element_by_id("userpassword").clear()
        driver.find_element_by_id("userpassword").send_keys("planet07")
        driver.find_element_by_id("cmdLogin").click()

        for i in range(10):
            try:
                if driver.find_element_by_id("flashImg1"):
                    # Visual validation point #2
                    # eyes.check_window('Dashboard')
                    driver.find_element_by_link_text("Logout").click()
                    print "Logging out"
                    break
            except Exception as e:
                print "Wait.."
                time.sleep(1)
        else:
            return "Element not found"

        # End visual testing. Validate visual correctness.
        eyes.close()

    except Exception as e:
        print e

    finally:
        driver.quit()
        eyes.abort_if_not_closed()
Esempio n. 2
0
class Test(unittest.TestCase):
    eyes = 0
    driver = 0

    def setUp(self):
        self.eyes = Eyes()
        self.eyes.api_key = APPLITOOLS_APIKEY
        self.driver = webdriver.Firefox()

    def tearDown(self):
        self.eyes.abort_if_not_closed()
        self.driver.quit()

    def test(self):
        # Start visual testing with browser viewport set to 1024x768.
        # Make sure to use the returned driver from this point on.
        self.driver = self.eyes.open(driver=self.driver,
                                     app_name='Applitools website',
                                     test_name='Example test',
                                     viewport_size={
                                         'width': 900,
                                         'height': 600
                                     })
        self.driver.get('http://www.applitools.com')

        # Visual validation point #1
        self.eyes.check_window('Main Page')

        self.driver.find_element_by_css_selector('.read_more').click()

        # Visual validation point #2
        self.eyes.check_window('Features Page')

        # End visual testing. Validate visual correctness.
        self.eyes.close()
class Test(unittest.TestCase):
    eyes = 0
    driver = 0

    def setUp(self):
        self.eyes = Eyes()
        self.eyes.api_key = APPLITOOLS_APIKEY
        self.driver = webdriver.Firefox()

    def tearDown(self):
        self.eyes.abort_if_not_closed()
        self.driver.quit()

    def test(self):
        # Start visual testing with browser viewport set to 1024x768.
        # Make sure to use the returned driver from this point on.
        self.driver = self.eyes.open(driver=self.driver, app_name='Applitools website', test_name='Example test',
                                     viewport_size={'width': 900, 'height': 600})
        self.driver.get('http://www.applitools.com')

        # Visual validation point #1
        self.eyes.check_window('Main Page')

        self.driver.find_element_by_css_selector('.read_more').click()

        # Visual validation point #2
        self.eyes.check_window('Features Page')

        # End visual testing. Validate visual correctness.
        self.eyes.close()
class EightDays:
    def __init__(self, testname):
        self.eyes = Eyes()
        self.eyes.api_key = 'IlUcgRAO105BlmoORdtUxbK8CUKg3KRSa8q4f3iACoY1I110'

        desired_caps = {
            "platformName": 'Android',
            "platformVersion": '8.0.0',
            "deviceName": "Android Emulator",
            "automationName": "UiAutomator2",
            # "nativeWebScreenshot": "True",
            "app": 'C:/Users/Tea/Desktop/BCA/8Days/Automated/mobile.apk'
        }

        # need to start appium or this won't happen
        self.wd = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)
        # 127.0.0.1 is your localhost and 4723 is the port
        # http://localhost:4723/wd/hub
        self.wd.implicitly_wait(10)  # wait for the page to load
        self.eyes.open(driver=self.wd, app_name='8days', test_name=testname)
        # The string passed to checkWindow() is typically a descriptive name that identifies the checkpoint.

    def select_language(self):
        self.wd.find_element_by_id("kr.co.the8days.dev:id/radioEnglish").click()
        self.wd.find_element_by_id("kr.co.the8days.dev:id/btnNext").click()

        sleep(2)
        self.wd.hide_keyboard()

    def find_login_fields(self):
        self.userField = self.wd.find_element_by_id("kr.co.the8days.dev:id/edtSignInEmail")
        self.pwField = self.wd.find_element_by_id("kr.co.the8days.dev:id/edtSignInPassword")
        self.login_btn = self.wd.find_element_by_id("kr.co.the8days.dev:id/btnSignIn")

    def basic_login(self):
        self.find_login_fields()

        self.userField.send_keys("*****@*****.**")
        self.pwField.click()
        self.delete_field(self.pwField)

        self.pwField.send_keys("golden1")
        self.login_btn.click()

    '''general functions'''

    def delete_field(self, field):
        actions = TouchAction(self.wd)
        actions.long_press(field).release().perform()
        self.wd.press_keycode(67)

    def screenshot(self, name):
        self.eyes.check_window(name)

    def click_by_id(self, id):
        self.wd.find_element_by_id(id).click()
Esempio n. 5
0
class Driver(object):
    def __init__(self, mode, path):
        self.eyes = Eyes()
        self.eyes.api_key = 'mHHQDYWEGS5AGbjfNoVO1h4oi15w3jiQ4q9DPagYJBA110'

        if mode == 'local':
            self.driver = webdriver.Chrome(path)
        elif mode == 'docker-chrome':
            self.driver = webdriver.Remote(
                command_executor='http://127.0.0.1:32768/wd/hub',
                desired_capabilities={'browserName': 'chrome'},
            )

    def open(self):
        self.eyes.open(driver=self.driver,
                       app_name='Creative_Factory',
                       test_name='Auto Regression Test')
        #viewport_size={'width': 800,'height': 600})

    def check_window(self, text):
        self.eyes.check_window(text)

    def get_url(self, url):
        try:
            self.driver.get(url)
        except BaseException as e:
            print(e)

    def add_cookie(self, cookies):
        self.driver.add_cookie(cookie_dict=cookies)

    def find_by_class(self, classname):
        try:
            return self.driver.find_element_by_class_name(classname)
        except BaseException as e:
            print(e)

    def set_size(self):
        self.driver.set_window_size(800, 600)

    def click_elem(self, elem):
        try:
            elem.click()
        except BaseException as e:
            print(e)

    def close(self):
        self.driver.close()

    def eye_close(self):
        self.eyes.close()
Esempio n. 6
0
class Unitest(unittest.TestCase):
    eyes = 0
    driver = 0

    def setUp(self):
        self.eyes = Eyes("https://localhost.applitools.com")
        self.eyes.api_key = os.environ['APPLITOOLS_API_KEY']
        sauce_url = "http://%s:%[email protected]:80/wd/hub"
        caps = webdriver.DesiredCapabilities.CHROME
        caps['screen-resolution'] = "1280x1024"
        caps['platform'] = "Windows 8"
        sauce_user = os.environ['SAUCELABS_USER']
        sauce_key = os.environ['SAUCELABS_KEY']
        self.driver = webdriver.Remote(desired_capabilities=caps,
                                       command_executor=sauce_url %
                                       (sauce_user, sauce_key))

    def tearDown(self):
        self.eyes.abort_if_not_closed()
        self.driver.quit()

    def test(self):
        # Start visual testing with browser viewport set to 1024x768.
        # Make sure to use the returned driver from this point on.
        self.driver = self.eyes.open(driver=self.driver,
                                     app_name='Saucelabs',
                                     test_name='Saucelabs test',
                                     viewport_size={
                                         'width': 1100,
                                         'height': 600
                                     })
        self.driver.get('https://saucelabs.com')

        # Visual validation point
        self.eyes.check_window('Main Page')

        menu_items = ['Features', 'Pricing', 'Enterprise', 'Docs']
        for item in menu_items:
            self.driver.find_element_by_xpath("//a[contains(.,'" + item +
                                              "')]").click()
            # Visual validation point
            self.eyes.check_window(item)

        # End visual testing. Validate visual correctness.
        self.eyes.close()
class Unitest(unittest.TestCase):
    eyes = 0
    driver = 0

    def setUp(self):
        self.eyes = Eyes("https://localhost.applitools.com")
        self.eyes.api_key = os.environ['APPLITOOLS_API_KEY']
        sauce_url = "http://%s:%[email protected]:80/wd/hub"
        caps = webdriver.DesiredCapabilities.CHROME
        caps['screen-resolution'] = "1280x1024"
        caps['platform'] = "Windows 8"
        sauce_user = os.environ['SAUCELABS_USER']
        sauce_key = os.environ['SAUCELABS_KEY']
        self.driver = webdriver.Remote(
            desired_capabilities=caps,
            command_executor=sauce_url % (sauce_user, sauce_key))

    def tearDown(self):
        self.eyes.abort_if_not_closed()
        self.driver.quit()

    def test(self):
        # Start visual testing with browser viewport set to 1024x768.
        # Make sure to use the returned driver from this point on.
        self.driver = self.eyes.open(
            driver=self.driver, app_name='Saucelabs', test_name='Saucelabs test',
            viewport_size={'width': 1100, 'height': 600})
        self.driver.get('https://saucelabs.com')

        # Visual validation point
        self.eyes.check_window('Main Page')

        menu_items = ['Features', 'Pricing', 'Enterprise', 'Docs']
        for item in menu_items:
            self.driver.find_element_by_xpath("//a[contains(.,'" + item + "')]").click()
            # Visual validation point
            self.eyes.check_window(item)

        # End visual testing. Validate visual correctness.
        self.eyes.close()
Esempio n. 8
0
class SimpleCalculatorTests(unittest.TestCase):
    def setUp(self):
        desired_caps = {}
        desired_caps["app"] = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"
        self.driver = webdriver.Remote(
            command_executor='http://127.0.0.1:4723',
            desired_capabilities=desired_caps)
        self.eyes = Eyes()
        self.eyes.api_key = "your_applitools_key"
        self.driver.set_window_size(
            700, 700)  #set size for responsive design testing...

    def tearDown(self):
        self.driver.quit()
        self.eyes.abort_if_not_closed()

    def test_initialize(self):
        self.eyes.open(driver=self.driver,
                       app_name='Windows Calculator',
                       test_name='Python Windows Calculator Test')
        self.driver.find_element_by_name("Clear").click()
        self.driver.find_element_by_name("Seven").click()
        self.eyes.check_window("Displays 7")
        self.eyes.close()

    def test_addition(self):
        self.eyes.open(driver=self.driver,
                       app_name='Windows Calculator',
                       test_name='Python Windows Calculator Test')
        self.driver.find_element_by_name("Clear").click()
        self.driver.find_element_by_name("One").click()
        self.driver.find_element_by_name("Plus").click()
        self.driver.find_element_by_name("Seven").click()
        self.driver.find_element_by_name("Equals").click()
        self.eyes.check_window("Displays 8")
        self.eyes.close()
def test_non_logged_in_users():
    eyes = Eyes()
    eyes.api_key = 'u51qaFo104ruwwox0ewoWiFZQpijro9Z47fYTk1iQTozU110'

    driver = webdriver.Firefox()
    driver.maximize_window()

    try:
        eyes.open(driver=driver, app_name='Applitools', test_name='TpT Non Logged In Pages')
        driver.get('http://www.teacherspayteachers.com')
        eyes.check_window('Homepage')

        driver.get("https://www.teacherspayteachers.com/Product/Multi-Purpose-Graphic-Organizers-Bundle-576136")
        eyes.check_window("Product Page")

        driver.find_element_by_xpath(".//*[@id='content_layout']/div[1]/div[3]/div[5]/div/div[2]/div/a").click()
        eyes.check_window("Store Page")

        eyes.close()

    finally:
        driver.quit()
        eyes.abort_if_not_closed()
Esempio n. 10
0
driver = webdriver.Chrome()

logger.set_logger(StdoutLogger())
eyes = Eyes()
eyes.api_key = os.environ['APPLITOOLS_API_KEY']
eyes.force_full_page_screenshot = True
eyes.hide_scrollbars = True

try:
    ## First test
    driver = eyes.open(driver, "Python app", "Github Website", {
        'width': 800,
        'height': 600
    })
    driver.get('http://www.github.com')
    eyes.check_window("initial")
    results = eyes.close(False)
    print(results)

    ## Second test
    driver = eyes.open(driver, "Python app", "Applitools Website", {
        'width': 900,
        'height': 600
    })
    driver.get('http://www.applitools.com')
    eyes.check_window("initial")
    results = eyes.close(False)
    print(results)
finally:
    driver.quit()
    eyes.abort_if_not_closed()
Esempio n. 11
0
    # Start the test and set the browser's viewport size to 800x600.
    eyes.open(driver=driver,
              app_name='CrossBrowserTesting',
              test_name='My first Applitools test with Python!',
              viewport_size={
                  'width': 800,
                  'height': 600
              })

    # We want to take a full page screenshot
    eyes.force_full_page_screenshot = True

    driver.get('https://crossbrowsertesting.com/visual-testing')

    # Visual checkpoint
    eyes.check_window('Visual Testing')

    # End the test.
    eyes.close()
    test_result = 'pass'

except DiffsFoundError as e:
    # if differences are found, eyes will throw a DiffsFoundError
    # we'll set the test score on CBT's side to match up
    test_result = 'fail'

finally:
    # make an API call to CrossBrowserTesting set the score
    requests.put('https://crossbrowsertesting.com/api/v3/selenium/' +
                 driver.session_id,
                 data={
Esempio n. 12
0
# This is your api key, make sure you use it in all your tests.
eyes.api_key = APPLITOOLS_APIKEY

# Get a selenium web driver object.
driver = webdriver.Firefox()

try:
    # Start visual testing with browser viewport set to 1024x768.
    # Make sure to use the returned driver from this point on.
    driver = eyes.open(driver=driver,
                       app_name='Applitools website',
                       test_name='Example test',
                       viewport_size={
                           'width': 900,
                           'height': 600
                       })
    driver.get('http://www.applitools.com')

    # Visual validation point #1
    eyes.check_window('Main Page')

    driver.find_element_by_css_selector('.read_more').click()

    # Visual validation point #2
    eyes.check_window('Features Page')

    # End visual testing. Validate visual correctness.
    eyes.close()
finally:
    driver.quit()
    eyes.abort_if_not_closed()
Esempio n. 13
0
# Get a selenium web driver object.
driver = webdriver.Firefox()

try:
    # Array of resolutions to test. Example : viewSizeArray = [[width, height],[...]...]
    # viewSizeArray = [[1920, 1080], [1600, 1200], [1280, 1024], [1024, 768], [800, 600]]
    viewSizeArray = [[1024, 768]]

    for viewSize in viewSizeArray:
        viewSizeForAppliTools = {'width': viewSize[0], 'height': viewSize[1]}
        driver = eyes.open(driver=driver,
                           app_name='Applitools',
                           test_name='Basic Backyard test: resolution - ' + str(viewSize[0]) + 'x' + str(viewSize[1]),
                           viewport_size=viewSizeForAppliTools)
        driver.get(baseurl)
        eyes.check_window('Login page')
        # driver.maximize_window()
        # Clear Username, Password TextBoxs if already allowed "Remember Me". Fill with new values. Sign in
        driver.find_element_by_xpath(xpaths['usernameTxtBox']).clear()
        driver.find_element_by_xpath(xpaths['usernameTxtBox']).send_keys(username)
        driver.find_element_by_xpath(xpaths['passwordTxtBox']).clear()
        driver.find_element_by_xpath(xpaths['passwordTxtBox']).send_keys(password)
        driver.find_element_by_xpath(xpaths['submitButton']).click()
        eyes.check_window('Dashboard main')

        # Go to WOWP backyard
        driver.find_element_by_xpath(xpaths['DashBoard_bckWOWPMain']).click()
        eyes.check_window('Dashboard WOWP')

        # Go to account
        driver.find_element_by_xpath(xpaths['bckWOWP_accountsPage']).click()
Esempio n. 14
0
try:
    # viewSizeArray =[{'width': 1024, 'height': 768}, {'width': 1280, 'height': 1024}]
    # viewSizeArray = [[width, height],[...]...]
    viewSizeArray = [[1920, 1080], [1600, 1200], [1280, 1024], [1024, 768], [800, 600]]
    # viewSizeArray = [[1920, 1080], [1600, 1200]]
    # Make sure to use the returned driver from this point on.
    for viewSize in viewSizeArray:
        viewSizeForAppliTools = {'width': viewSize[0], 'height': viewSize[1]}
        driver = eyes.open(driver=driver,
                           app_name='Applitools',
                           test_name='Basic WG Portal test: resolution - ' + str(viewSize[0]) + 'x' + str(viewSize[1]),
                           viewport_size=viewSizeForAppliTools)
        driver.get('http://ru.wargaming.net/')
        # Visual validation point #1
        eyes.check_window('Main Page')
        wot_about = driver.find_element_by_link_text("О проекте")
        wot_about.click()
        # Visual validation point #2
        eyes.check_window('WOT about Page')

        # End visual testing. Validate visual correctness.
        test_results = list()
        test_results.append(eyes.close(False))

    #Do something with test results..
    print('And the result is...')
    for result in test_results: print(result)

finally:
    driver.quit()
from applitools import logger
from applitools.eyes import Eyes
import os


# Appium session configuration.
from applitools.logger import StdoutLogger

desired_capabilities = {'platformName': 'Android',
                        'platformVersion': '4.2',
                        'deviceName': 'Samsung Galaxy S5',
                        'app': os.environ['ANDROID_NOTES_LIST_APP'],
                        'app-package': 'com.example.android.notepad',
                        'app-activity': '.NotesList',
                        'newCommandTimeout': 300}

# Assuming Appium is running on localhost.
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities)
driver.orientation = 'LANDSCAPE'
logger.set_logger(StdoutLogger())
eyes = Eyes("https://localhost.applitools.com")
eyes.api_key = os.environ['APPLITOOLS_API_KEY']
eyes.baseline_name = "NotesList 1080x1794"
try:
    eyes.open(driver, 'Appium', 'Notes list')
    eyes.check_window('Opening screen')
    eyes.close()
finally:
    driver.quit()
    eyes.abort_if_not_closed()
def hover_over_hamburger(driver):
    hamburger = driver.find_element_by_xpath("//div[@class='menu-bars-outer']/a/i")
    ActionChains(driver).move_to_element(hamburger).perform()

eyes = Eyes()
eyes.api_key = 'u51qaFo104ruwwox0ewoWiFZQpijro9Z47fYTk1iQTozU110'
driver = webdriver.Firefox()
driver.maximize_window()

try:
    eyes.open(driver=driver, app_name='itailor', test_name='itailors')

    #homepage_new_arrivals
    driver.get('http://tailor.managedcoder.com/')
    eyes.check_window("homepage_new_arrivals")

    #homepage_hot_products
    driver.find_element_by_xpath("//div[@class='entry-content clearfix']/div[2]/div/div/div/div/div/ul/li[1]/a").click()
    eyes.check_window("homepage_hot_products")

    #homepage_best_Sellers
    driver.find_element_by_xpath("//div[@class='entry-content clearfix']/div[2]/div/div/div/div/div/ul/li[3]/a").click()
    eyes.check_window("homepage_best_Sellers")

    #suits/design tools
    driver.find_element_by_xpath("//div[@class='container']/nav/ul/li[2]/a")
    eyes.check_window("suits/design tools")

    #suits/buy
    driver.find_element_by_xpath("//div[@class='wcs_frontend_design_buy_icon wcs_show_content']").click()
def main():

    customer="winterfest"
    url_file_name="book_url_to_be_checked.xlsx"
    protocol ="https://"

    # Initialize the eyes SDK and set your private API key.
    eyes = Eyes()
    eyes.api_key = <<<<<API key here>>>>>>
    mybatch = BatchInfo(customer)

    # Testing whole web page
    eyes.force_full_page_screenshot = True
    eyes.hide_scrollbars = True
    eyes.use_css_transition = True

    eyes.batch = mybatch

    print('Opening workbook...')
    wb = openpyxl.load_workbook(url_file_name)
    sheet = wb[customer]

    domain_live = sheet['A' + str(2)].value.split('//', 1)[1].split('/', 1)[0]
    domain_staging = sheet['B' + str(2)].value.split('//', 1)[1].split('/', 1)[0]
    username_staging = sheet['C' + str(2)].value
    password_staging = sheet['D' + str(2)].value

    print("Base data for the client:", customer, "\nLiveURL: ", domain_live, "\nStagingURL: "+ domain_staging,
          "\nStaging_username: "******"info" with two elements add into the list "url_list":

        if (sheet['F' + str(row)].value==None) or (sheet['E' + str(row)].value==None):
            print("Skiped empty row: ", row)
        else:
            info = {}
            info['menu_title'] = sheet['E' + str(row)].value
            #removing the domain from url
            info['menu_path'] = ''.join(sheet['F' + str(row)].value.split('//', 1)[1].split('/', 1)[1:])
            url_list.append(info)

    driver = webdriver.Chrome()

    for item in url_list:
        #domain_live

        print("Test Live: ", item['menu_title'], protocol+domain_live+"/"+item['menu_path'])

        driver.get(protocol+domain_live+"/"+item['menu_path'])

        eyes.open(driver=driver, app_name=customer, test_name=item['menu_title'], viewport_size={'width': 800, 'height': 600})
        try:
            eyes.check_window(item['menu_title'])
        finally:
            eyes.close()

        print("Test Staging: ", item['menu_title'], protocol + domain_staging + "/"+item['menu_path'])
        driver.get(protocol + domain_staging + "/" + item['menu_path'])

        eyes.open(driver=driver, app_name=customer, test_name=item['menu_title'], viewport_size={'width': 800, 'height': 600})
        try:
            eyes.check_window(item['menu_title'])
        finally:
            eyes.close()
driver = webdriver.Firefox()
driver.maximize_window()

try:
    eyes.open(driver=driver, app_name='itailor', test_name='itailors')
    driver.get('http://tailor.managedcoder.com/')
    hover_over_hamburger(driver)
    #clicks on login/register link
    driver.find_element_by_xpath("//div[@class='menu-bars-item menu-bars-account']/ul/li[5]/a").click()

    #enter login credentails
    driver.find_element_by_xpath("//input[@id='username']").send_keys("*****@*****.**")
    driver.find_element_by_xpath("//input[@id='password']").send_keys("rash0207")
    driver.find_element_by_xpath("//input[@class='btn btn-default']").click()
    #check account page
    eyes.check_window("my account page")
    #check edit account page
    driver.find_element_by_xpath("//p[@class='myaccount_user']/a[2]").click()
    eyes.check_window("edit account")
    #go to product page
    driver.find_element_by_xpath("//div[@class='container']/nav/ul/li[2]/a").click()
    #add product to cart
    driver.find_element_by_xpath("//form[@class='cart']/button").click()
    driver.find_element_by_xpath("//div[@class='menu-bars-item menu-bars-account']/ul/li[3]/a").click()
    eyes.check_window("cart with products")
    #add to wishlist
    driver.find_element_by_xpath("//div[@class='yith-wcwl-add-to-wishlist add-to-wishlist-96']/div[1]/a").click()
    driver.find_element_by_xpath("//div[@class='yith-wcwl-add-to-wishlist add-to-wishlist-96']/div[1]/a").click()
    eyes.check_window("wishlist with products")

    #compare the products for logged in user when products are already added to compare
Esempio n. 19
0
import os
#os.environ['HTTPS_PROXY'] = "http://localhost:8888"

driver = webdriver.Chrome()

eyes = Eyes()
eyes.api_key = os.environ['APPLITOOLS_API_KEY']

logger.set_logger(StdoutLogger())

# Force Eyes to grab a full page screenshot.
eyes.force_full_page_screenshot = True
eyes.stitch_mode = StitchMode.CSS

try:
    driver = eyes.open(driver, "Python app", "applitools", {
        'width': 800,
        'height': 600
    })
    driver.get('http://www.applitools.com')
    eyes.check_window("Home")

    automated_paragraph = driver.find_element_by_class_name("automated")
    eyes.check_region_by_element(automated_paragraph,
                                 "Automated Testing Paragraph")

    eyes.close()
finally:
    driver.quit()
    eyes.abort_if_not_closed()
__author__ = 'Yanir Taflev'
from selenium import webdriver
from applitools.eyes import Eyes

eyes = Eyes()
# This is your api key, make sure you use it in all your tests.
eyes.api_key = APPLITOOLS_APIKEY

# Get a selenium web driver object.
driver = webdriver.Firefox()

try:
    # Start visual testing with browser viewport set to 1024x768.
    # Make sure to use the returned driver from this point on.
    driver = eyes.open(driver=driver, app_name='Applitools website', test_name='Example test',
                       viewport_size={'width': 900, 'height': 600})
    driver.get('http://www.applitools.com')

    # Visual validation point #1
    eyes.check_window('Main Page')

    driver.find_element_by_css_selector('.read_more').click()

    # Visual validation point #2
    eyes.check_window('Features Page')

    # End visual testing. Validate visual correctness.
    eyes.close()
finally:
    driver.quit()
    eyes.abort_if_not_closed()
# os.environ['HTTPS_PROXY'] = "http://localhost:8888"

driver = webdriver.Chrome()

logger.set_logger(StdoutLogger())
eyes = Eyes("https://localhost.applitools.com")
eyes.api_key = os.environ['APPLITOOLS_API_KEY']
eyes.force_full_page_screenshot = True
eyes.save_new_tests = False

try:
    ## First test
    driver = eyes.open(driver, "Python app", "Python binary", {'width': 800, 'height': 600})

    driver.get('http://www.applitools.com')
    eyes.check_window("initial")

    pricing_element = driver.find_element_by_css_selector("li.pricing a")
    eyes.check_region_by_element(pricing_element, "pricing button")

    driver.find_element_by_css_selector("li.contact-us a").click()
    eyes.check_window("contact us page")

    ## Second test
    # driver.find_element_by_class_name("input-name").send_keys("my name is what?")
    # eyes.check_window("name input")
    # results = eyes.close(False)
    # print(results)
    #
    # driver = eyes.open(driver, "Python app", "Python binary", {'width': 800, 'height': 600})
    # driver.get('http://www.applitools.com')
from applitools.eyes import Eyes
from applitools.logger import StdoutLogger

# os.environ['HTTPS_PROXY'] = "http://localhost:8888"

driver = webdriver.Chrome()

logger.set_logger(StdoutLogger())
eyes = Eyes()
eyes.api_key = os.environ['APPLITOOLS_API_KEY']
eyes.force_full_page_screenshot = True
eyes.hide_scrollbars = True

try:
    ## First test
    driver = eyes.open(driver, "Python app", "Github Website", {'width': 800, 'height': 600})
    driver.get('http://www.github.com')
    eyes.check_window("initial")
    results = eyes.close(False)
    print(results)

    ## Second test
    driver = eyes.open(driver, "Python app", "Applitools Website", {'width': 900, 'height': 600})
    driver.get('http://www.applitools.com')
    eyes.check_window("initial")
    results = eyes.close(False)
    print(results)
finally:
    driver.quit()
    eyes.abort_if_not_closed()
Esempio n. 23
0
class EventScheduler_FrontEndTest:

    def setup(self, test_registration=False):
        self.eyes = Eyes()
        self.eyes.api_key = 'IlUcgRAO105BlmoORdtUxbK8CUKg3KRSa8q4f3iACoY1I110'
        self.driver = webdriver.Chrome(r"C:\Users\Tea\Desktop\chromedriver_win32 (1)\chromedriver.exe")

        self.eyes.open(driver=self.driver, app_name='Hello World!', test_name='eventScheduler')
        self.driver.get('http://*****:*****@mymail.sutd.edu.sg'

    def test_redirection(self):
        self.driver.find_element_by_xpath("//a[text()='Home']").click()
        self.eyes.check_window('Redirected to login')

        # show dropdown menu
        self.driver.find_element_by_xpath("//a[contains(text(),'Forms')]").click()
        self.eyes.check_window('Dropdown menu')

        self.driver.find_element_by_xpath("//a[contains(text(),'Schedule R')]").click()
        self.eyes.check_window('Redirected to login')

        assert(self.driver.current_url == "http://*****:*****@name="username"]')
        username.send_keys(self.ran_name)

        email = self.driver.find_element_by_xpath('//input[@name="email"]').click()
        self.eyes.check_window('Focused textbox')
        self.driver.find_element_by_xpath('//input[@name="email"]').send_keys(self.Email)

        pw1 = self.driver.find_element_by_xpath('//input[@name="password1"]')
        pw1.send_keys(self.LEGAL_PASSWORD)
        pw2 = self.driver.find_element_by_xpath('//input[@name="password2"]')
        pw2.send_keys(self.LEGAL_PASSWORD)
        pw2.send_keys(Keys.RETURN)

        self.eyes.check_window("Submitted")

    # re-registering with the same username
    def test_registration_repeatUser(self):
        self.driver.find_element_by_xpath("//a[text()='Register']").click()

        username = self.driver.find_element_by_xpath('//input[@name="username"]')
        username.send_keys(self.ran_name)

        email = self.driver.find_element_by_xpath('//input[@name="email"]').click()
        self.driver.find_element_by_xpath('//input[@name="email"]').send_keys(self.Email)

        pw1 = self.driver.find_element_by_xpath('//input[@name="password1"]')
        pw1.send_keys(self.LEGAL_PASSWORD)
        pw2 = self.driver.find_element_by_xpath('//input[@name="password2"]')
        pw2.send_keys(self.LEGAL_PASSWORD)
        pw2.send_keys(Keys.RETURN)

        assert('A user with that username already exists.' in self.driver.page_source)
        self.eyes.check_window("same user error message")

    # weak passwords
    def test_registration_fail(self):
        self.driver.find_element_by_xpath("//a[text()='Register']").click()

        # test weakpasswords
        username = self.driver.find_element_by_xpath('//input[@name="username"]')
        username.send_keys(self.RANDOM_NAME)

        email = self.driver.find_element_by_xpath('//input[@name="email"]').click()
        self.driver.find_element_by_xpath('//input[@name="email"]').send_keys(self.Email)

        pw1 = self.driver.find_element_by_xpath('//input[@name="password1"]')
        pw1.send_keys(self.WEAK_PASSWORD)
        pw2 = self.driver.find_element_by_xpath('//input[@name="password2"]')
        pw2.send_keys(self.WEAK_PASSWORD)
        pw2.send_keys(Keys.RETURN)

        self.driver.find_element_by_xpath("//a[text()='Register']").click()
        username = self.driver.find_element_by_xpath('//input[@name="username"]')
        username.send_keys(self.RANDOM_NAME)

        email = self.driver.find_element_by_xpath('//input[@name="email"]').click()
        self.driver.find_element_by_xpath('//input[@name="email"]').send_keys(self.Email)
        pw1 = self.driver.find_element_by_xpath('//input[@name="password1"]')
        pw1.send_keys("fakestrongpassword091")
        pw2 = self.driver.find_element_by_xpath('//input[@name="password2"]')
        pw2.send_keys('fakestrongpassword091')
        pw2.send_keys(Keys.RETURN)

        self.driver.find_element_by_xpath("//a[text()='Register']").click()
        username = self.driver.find_element_by_xpath('//input[@name="username"]')
        username.send_keys(self.RANDOM_NAME)

        email = self.driver.find_element_by_xpath('//input[@name="email"]').click()
        self.driver.find_element_by_xpath('//input[@name="email"]').send_keys(self.Email)
        pw1 = self.driver.find_element_by_xpath('//input[@name="password1"]')
        pw1.send_keys("fakestrongpassword091!")
        pw2 = self.driver.find_element_by_xpath('//input[@name="password2"]')
        pw2.send_keys('fakestrongpassword091!')
        pw2.send_keys(Keys.RETURN)

        self.driver.find_element_by_xpath("//a[text()='Register']").click()
        username = self.driver.find_element_by_xpath('//input[@name="username"]')
        username.send_keys(self.RANDOM_NAME)

        email = self.driver.find_element_by_xpath('//input[@name="email"]').click()
        self.driver.find_element_by_xpath('//input[@name="email"]').send_keys(self.Email)
        pw1 = self.driver.find_element_by_xpath('//input[@name="password1"]')
        pw1.send_keys("100091")
        pw2 = self.driver.find_element_by_xpath('//input[@name="password2"]')
        pw2.send_keys('100091')
        pw2.send_keys(Keys.RETURN)

    def test_login_wrong_username(self):
        self.driver.find_element_by_xpath('//a[text()="Login"]').click()
        self.driver.find_element_by_xpath('//input[@name="username"]').send_keys("WRONG NAME")
        self.driver.find_element_by_xpath('//input[@name = "password"]').send_keys(self.LEGAL_PASSWORD)
        self.driver.find_element_by_xpath('//button[text()="Login"]').click()
        self.eyes.check_window("error")
        assert("Please enter a correct username and password. Note that both fields may be case-sensitive." in self.driver.page_source)

    def test_login_wrong_pw(self):
        self.driver.find_element_by_xpath('//a[text()="Login"]').click()
        self.driver.find_element_by_xpath('//input[@name="username"]').send_keys(self.ran_name)
        self.driver.find_element_by_xpath('//input[@name = "password"]').send_keys("self.LEGAL_PASSWORD")
        self.driver.find_element_by_xpath('//button[text()="Login"]').click()
        assert("Please enter a correct username and password. Note that both fields may be case-sensitive." in self.driver.page_source)

    def test_login_pass(self):
        self.driver.find_element_by_xpath('//a[text()="Login"]').click()
        self.driver.find_element_by_xpath('//input[@name="username"]').send_keys(self.ran_name)
        self.driver.find_element_by_xpath('//input[@name = "password"]').send_keys(self.LEGAL_PASSWORD)
        self.driver.find_element_by_xpath('//button[text()="Login"]').click()

        self.eyes.check_window("Login-ed")

        # right = self.driver.find_element_by_xpath('//button[@class="fc-next-button fc-button fc-state-default fc-corner-right"]')
        # right.click()
        # self.eyes.check_window("today button lit up")

        # left=self.driver.find_element_by_xpath('        //button[@class="fc-prev-button fc-button fc-state-default fc-corner-left"]')
        # left.click()
        # self.eyes.check_window("today not lit")

        # self.driver.find_element_by_xpath('        //button[@class="fc-prev-button fc-button fc-state-default fc-corner-left"]').click()

    def test_collapse(self):
        self.driver.set_window_size(300, 800)
        self.driver.set_window_position(0, 0)
        self.eyes.check_window("check collapse")

        self.driver.set_window_size(1536, 673)
        self.driver.set_window_position(0, 0)

    def test_dropdown(self):
        # show dropdown menu
        self.driver.find_element_by_xpath("//a[contains(text(),'Forms')]").click()
        self.eyes.check_window('Dropdown menu')

    def test_links(self):
        self.driver.find_element_by_xpath("//a[contains(text(),'Schedule R')]").click()

        assert(self.driver.current_url == "http://localhost:8000/requestform/")

        self.driver.find_element_by_xpath("//a[contains(text(),'Forms')]").click()
        self.eyes.check_window('Dropdown menu')

        self.driver.find_element_by_xpath("//a[contains(text(),'Input M')]").click()

        assert(self.driver.current_url == "http://localhost:8000/requestform/input-module-info")

        self.driver.find_element_by_xpath("//a[contains(text(),'Forms')]").click()
        self.eyes.check_window('Dropdown menu')

        self.driver.find_element_by_xpath("//a[contains(text(),'In-vivo')]").click()

        assert(self.driver.current_url == "http://localhost:8000/requestform/add-event")

        self.driver.find_element_by_xpath("//a[contains(text(),'View R')]").click()

        assert(self.driver.current_url == "http://localhost:8000/requestform/view-requests")

    def logout(self):
        self.driver.find_element_by_xpath('//a[text()="Logout"]').click()
        self.eyes.check_window("logged out")

    def end(self):
        self.eyes.close()
        self.driver.quit()
        # If the test was aborted before self.eyes.close was called, ends the test as aborted.
        self.eyes.abort_if_not_closed()
driver = webdriver.Chrome()

logger.set_logger(StdoutLogger())
eyes = Eyes()
eyes.api_key = os.environ['APPLITOOLS_API_KEY']
eyes.hide_scrollbars = True
# For browser which only take screenshot of the viewport, you can uncomment the setting below, and
# eyes will automatically create a full page screenshot.

# eyes.force_full_page_screenshot = True

try:
    driver = eyes.open(driver, "Python app", "applitools", {'width': 800, 'height': 600})
    driver.get('http://www.applitools.com')
    eyes.check_window("initial")

    pricing_element = driver.find_element_by_css_selector("li.pricing a")
    eyes.check_region_by_element(pricing_element, "pricing button")

    pricing_element.click()
    eyes.check_window("pricing page")

    driver.find_element_by_css_selector("li.contact-us a").click()
    eyes.check_window("contact us page")
    driver.find_element_by_class_name("input-name").send_keys("my name is what?")
    eyes.check_window("name input")
    eyes.close()
finally:
    driver.quit()
    eyes.abort_if_not_closed()
Esempio n. 25
0
class TestAuthenticationPages(BaseTest):
    def __init__(self, *args, **kwargs):
        super(TestAuthenticationPages, self).__init__(*args, **kwargs)
        self.__login = LoginPage()
        self.__register = RegisterPage()
        self.__forgot_password = ForgotPasswordPage()

        self.__data = DataGenerateUtils()
        self.valid_email = self.__data.create_email()
        self.valid_username = self.__data.create_name()
        self.valid_password = self.__data.create_password()

        self.bot_name = "Test"
        self.invalid_faq = "google.com"
        self.eyes = Eyes()
        self.eyes.api_key = YAML_CONFIG.get("eyes_api_key")

    def setUp(self):
        super().setUp()

    def test_login_page_appearance(self):
        try:
            self.eyes.open(driver=self.__login.driver.core_driver,
                           app_name='sample_app',
                           test_name='Login Page',
                           viewport_size={'width': 1440, 'height': 887})
            self.__login.open_login_page()
            self.__login.wait_for_log_in_page()
            self.eyes.check_window("Default Login Page")
            self.__login.check_remember_me(False)
            self.eyes.check_window("Login Page without remember me")
            self.__login.login_with_account("", "")
            self.eyes.check_window("Login Page with error message")
        finally:
            res = self.eyes.close(raise_ex=True)
            print(res)
            self.eyes.abort_if_not_closed()

    def test_register_page_appearance(self):
        try:
            self.eyes.open(driver=self.__login.driver.core_driver,
                           app_name='sample_app',
                           test_name='Register Page',
                           viewport_size={'width': 1440, 'height': 887})
            self.__register.open_register_page()
            self.__register.wait_for_register_page()
            self.eyes.check_window("Default Register Page")
            self.__register.txt_email.click()
            self.eyes.check_window("Register with tips for email")
            self.__register.txt_password.click()
            self.eyes.check_window("Register with tips for password")
            self.__register.login_with_new_account("", "", "")
            self.eyes.check_window("Register with error message")
        finally:
            res = self.eyes.close(raise_ex=True)
            print(res)
            self.eyes.abort_if_not_closed()

    def test_forgot_password_page_appearance(self):
        try:
            self.eyes.open(driver=self.__login.driver.core_driver,
                           app_name='sample_app',
                           test_name='Forgot Password Page',
                           viewport_size={'width': 1440, 'height': 887})
            self.__forgot_password.open_forgot_password_page()
            self.__forgot_password.wait_for_forgot_password_page()
            self.eyes.check_window("Default Forgot password page")
            self.__forgot_password.submit_email("")
            self.eyes.check_window("Submit empty email")
            self.__forgot_password.submit_email("*****@*****.**")
            self.eyes.check_window("Submit with wrong email format")
            self.__forgot_password.submit_email(YAML_CONFIG.get("sample_app_user"))
            self.eyes.check_window("Submit successfully")
        finally:
            res = self.eyes.close(raise_ex=True)
            print(res)
            self.eyes.abort_if_not_closed()

    def tearDown(self):
        super().tearDown()
def test_non_logged_in_users():
    eyes = Eyes()
    eyes.api_key = 'u51qaFo104ruwwox0ewoWiFZQpijro9Z47fYTk1iQTozU110'

    driver = webdriver.Firefox()
    driver.maximize_window()

    try:
        eyes.open(driver=driver, app_name='Applitools', test_name='TpT Non Logged In Pages')

        # Check HomePage
        driver.get('http://www.teacherspayteachers.com')
        eyes.check_window('Homepage')

        # Check Empty Cart Page
        driver.find_element_by_xpath("//div[@class='drop_down my_cart']/a").click()
        eyes.check_window("Empty Cart Page")
        driver.find_element_by_xpath("//a[@class='common_button green small continue_shopping_button']").click()

        # Check Product Page
        driver.get("https://www.teacherspayteachers.com/Product/Informational-Text-Structures-Task-Cards-1057257")
        eyes.check_window("Product Page")

        # Check cart page with products
        driver.find_element_by_xpath("//div[@class='prod_price_box_wrap']/div[1]/div[2]/div[1]/a").click()
        eyes.check_window("Cart Page")
        driver.find_element_by_xpath("//div[@class='checkout_flow_pages cart_page']/div[1]/div[1]/div[1]/a").click()

        # Check Store Page
        driver.find_element_by_xpath("//div[@class='r_side']/div[3]/div[1]/div[1]/a").click()
        eyes.check_window("Store Page")

        # Check Ratings & Comment Tab on store page
        driver.find_element_by_xpath("//a[@id='ui-id-2']").click()
        time.sleep(2)
        eyes.check_window("Store Page >> Ratings & Comment Tab")

        # Check Gift Cards Page
        driver.find_element_by_xpath("//div[@class='header_user_menu']/a[3]").click()
        eyes.check_window("Gift Card Page")

        # Check Login Page
        driver.find_element_by_class_name("js-login").click()
        eyes.check_window("Login Page")

        # Check Signup Page
        driver.find_element_by_xpath("//div[@class='btns']/a[2]").click()
        eyes.check_window("Signup Page")

        # Check publisher signup page
        driver.find_element_by_xpath("//div[@class='seller_publisher_block']/a").click()
        eyes.check_window("Publisher Signup Page")

        # Terms of Service
        driver.find_element_by_xpath("//div[@class='centered']/a[2]").click()
        eyes.check_window("Terms of service")

        # Privacy Policy
        driver.find_element_by_xpath("//div[@class='centered']/a[3]").click()
        eyes.check_window("Privacy policy")

        # Press
        driver.find_element_by_xpath("//div[@class='block left']/a[4]").click()
        eyes.check_window("Press")

        # Blog
        driver.find_element_by_xpath("//div[@class='block left']/a[5]").click()
        eyes.check_window("Blog")
        driver.back()

        # How to sell items
        driver.find_element_by_xpath("//div[@class='block left']/a[6]").click()
        eyes.check_window("How to sell items")

        # Copyright and trademark policies
        driver.find_element_by_xpath("//div[@class='centered']/a[4]").click()
        eyes.check_window("Copyright and trademark policies")

        # About us
        driver.find_element_by_xpath("//div[@class='centered']/a[5]").click()
        eyes.check_window("About us")

        # Contact us
        driver.find_element_by_xpath("//div[@class='centered']/a[6]").click()
        eyes.check_window("Contact us")

        # Careers
        driver.find_element_by_xpath("//div[@class='centered']/a[7]").click()
        eyes.check_window("Careers")


        #FAQ's and Helps
        driver.find_element_by_xpath("//div[@class='centered']/a[8]").click()
        eyes.check_window("FAQ's and Helps")
        driver.back()

        # Schools
        driver.find_element_by_xpath("//div[@class='header_user_menu']/a[2]").click()
        eyes.check_window("Schools")

        eyes.close()

    finally:
        driver.quit()
        eyes.abort_if_not_closed()
Esempio n. 27
0
from applitools import logger
from applitools.eyes import Eyes
import os

# Appium session configuration.
from applitools.logger import StdoutLogger

desired_capabilities = {
    'platformName': 'Android',
    'platformVersion': '4.2',
    'deviceName': 'Samsung Galaxy S5',
    'app': os.environ['ANDROID_NOTES_LIST_APP'],
    'app-package': 'com.example.android.notepad',
    'app-activity': '.NotesList',
    'newCommandTimeout': 300
}

# Assuming Appium is running on localhost.
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities)
driver.orientation = 'LANDSCAPE'
logger.set_logger(StdoutLogger())
eyes = Eyes()
eyes.api_key = os.environ['APPLITOOLS_API_KEY']
try:
    eyes.open(driver, 'Appium', 'Notes list')
    eyes.check_window('Opening screen')
    eyes.close()
finally:
    driver.quit()
    eyes.abort_if_not_closed()