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()
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()
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 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()
def test_server_connector(driver): eyes = Eyes('https://localhost.applitools.com') driver = eyes.open(driver, "Python SDK", "TestDelete", {'width': 800, 'height': 599}) driver.get("https://applitools.com/helloworld") eyes.check("Hello", Target.window()) results = eyes.close() results.delete() eyes.abort_if_not_closed()
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()
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()
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()
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()
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()
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() driver.find_element_by_xpath(xpaths['bckWOWP_accounts_searchType']).click() driver.find_element_by_xpath(xpaths['bckWOWP_accounts_searchValue']).send_keys(accountNameSearch) driver.find_element_by_xpath(xpaths['bckWOWP_accounts_searchStart']).click() eyes.check_window('Accounts. Some value found') driver.find_element_by_xpath(xpaths['bckWOWP_accounts_firstLink']).click() eyes.check_window('Account. Manage WOWP page') # Some Account check driver.find_element_by_xpath(xpaths['bckWOWP_account_gold']).click() eyes.check_window('Gold. Manage gold of user') driver.find_element_by_xpath(xpaths['bckWOWP_gold_amount']).send_keys(password) driver.find_element_by_xpath(xpaths['bckWOWP_gold_comment']).send_keys(password) driver.find_element_by_xpath(xpaths['bckWOWP_gold_submit']).click() # 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() eyes.abort_if_not_closed()
#downloads driver.find_element_by_xpath("//div[@class='content my-orders']/ul/li[2]/a").click() #eyes.check_window("downloads") driver.back() time.sleep(3) #your reward points driver.find_element_by_xpath("//div[@class='content my-orders']/ul/li[3]/a").click() #eyes.check_window("your reward points") driver.back() time.sleep(3) #view your return requests driver.find_element_by_xpath("//div[@class='content my-orders']/ul/li[4]/a").click() #eyes.check_window("view your return requests") driver.back() time.sleep(3) #your transactions driver.find_element_by_xpath("//div[@class='content my-orders']/ul/li[5]/a").click() #eyes.check_window("your transactions") driver.back() time.sleep(3) #Recurring payments driver.find_element_by_xpath("//div[@class='content my-orders']/ul/li[6]/a").click() #eyes.check_window("Recurring payments") driver.back() time.sleep(3) driver.find_element_by_class_name("secondary-menu-item-2").click() eyes.close() finally: driver.quit() eyes.abort_if_not_closed()
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()
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') # eyes.check_window("initial") results = eyes.close(False) print(results) finally: driver.quit() eyes.abort_if_not_closed()
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()
class TestAdminPages(BaseTest): def __init__(self, *args, **kwargs): super(TestAdminPages, self).__init__(*args, **kwargs) self.__data = DataGenerateUtils() self.__login = LoginPage() self.__create_bot = CreateBotPage() self.__register = RegisterPage() self.__dashboard = DashboardPage() self.__appearance = AppearancePage() self.__create_bot_validation = CreateBotValidation() self.__drop_down_list = DropDownList() self.__change_password = ChangePasswordPage() self.__knowledge = KnowledgePage() self.__data_set = DataUtils() self.__faq_knowledge_data_table_component = FaqKnowledgeDataTableComponent( ) 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") self.eyes.force_full_page_screenshot = True self.eyes.stitch_mode = StitchMode.CSS def setUp(self): super().setUp() self.sign_in_for_ui_test( email=YAML_CONFIG.get("visual_test_user"), password=YAML_CONFIG.get("visual_test_password"), # Use is_debugging flag to login instead of register new account is_debugging=True) def test_for_bot_knowledge_appearance(self): try: self.eyes.open(driver=self.__login.driver.core_driver, app_name='sample_app', test_name='Bot Knowledge Page', viewport_size={ 'width': 1440, 'height': 887 }) self.__knowledge.open_knowledge_page() self.__knowledge.wait_for_create_page() # self.eyes.check_window("Default state of Knowledge Page") self.eyes.check_region_by_selector( By.XPATH, "//*[contains(@class,'two')]/div", "Default state") self.__knowledge.btn_add_knowledge.click() self.eyes.check_region_by_selector( by=By.CSS_SELECTOR, value="#add-knowledge-dropdown > div", tag="Add knowledge dropdown") self.__knowledge.btn_from_faq_url.click() # self.eyes.check_window("Knowledge page when adding faq url") self.eyes.check_region_by_selector( By.XPATH, "//*[contains(@class,'two')]/div", "Adding FAQ URL") self.__knowledge.init_manual_question_pair_table() # self.eyes.check_window("Knowledge page when init manual faq table") self.eyes.check_region_by_selector( By.XPATH, "//*[contains(@class,'two')]/div", "Initiated manual FAQ") manual_section = FaqKnowledgeDataTableComponent.get_table_component_with_group_faqs( "Manual Q&A") manual_section.collapse_section() self.eyes.check_region_by_element( manual_section.base_component_element( SeleniumElement).get_wrapper_element, "Manual section after collapsing") web_content_section = FaqKnowledgeDataTableComponent.get_table_component_with_group_faqs( "Web Content") web_content_section.open_section() # TODO(namndoan): capture full element self.eyes.check_region_by_element( web_content_section.base_component_element( SeleniumElement).get_wrapper_element, "Web content section after open") web_content_section.collapse_section() # self.eyes.check_window("Knowledge page after closing Web Content section") self.eyes.check_region_by_selector( By.XPATH, "//*[contains(@class,'two')]/div", "Closed Web Content section") self.eyes.check_region_by_selector( By.XPATH, "//*[contains(@class,'two')]/div[2]", "Chat box in knowledge") finally: res = self.eyes.close(raise_ex=True) print(res) self.eyes.abort_if_not_closed() def tearDown(self): super().tearDown()
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()
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) driver = eyes.open(driver=driver, app_name='Home Reach', test_name='Login to Dash', viewport_size={'width': 1024, 'height': 600}) # 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') 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-trialsbeta1") 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() #selenium.webdriver.support.expected_conditions.invisibility_of_element_located(locator) #element = WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.ID, "divFlashVersion")) element = WebDriverWait(driver, 15).until(EC.invisibility_of_element_located((By.ID, "divFlashVersion"))) try: for i in range(20): try: flashCheck = driver.find_element_by_id("divFlashVersion") print flashCheck if flashCheck != driver.find_element_by_id("divFlashVersion"): print "Flash version check" print flashCheck time.sleep(1) continue elif flashCheck == driver.find_element_by_id("divFlashVersion"): print "No Flash check" print flashCheck if driver.find_element_by_id("flashImg1"): # Visual validation point #2 #eyes.check_window('Dashboard') print "Found flashImg1" driver.find_element_by_link_text("Logout").click() print 'Logging out' break except Exception as e: print e print 'Wait..' time.sleep(1) # End visual testing. Validate visual correctness. eyes.close() except Exception as e: print e finally: driver.quit() eyes.abort_if_not_closed()