def run_search_inbox_test(browser, conf, base_url, sauce_flag, browser_version, platform, testrail_run_id): "Login to Gmail using the page object model" # get the test account credentials from the .credentials file credentials_file = os.path.join(os.path.dirname(__file__), 'login.credentials') username = Conf_Reader.get_value(credentials_file, 'LOGIN_USER') password = Conf_Reader.get_value(credentials_file, 'LOGIN_PASSWORD') #Result flag used by TestRail result_flag = False #Setup a driver #create object of driver factory driver_obj = DriverFactory() driver = driver_obj.get_web_driver(browser, sauce_flag, browser_version, platform) driver.maximize_window() #Create a login page object login_obj = PageFactory.get_page_object("login", driver) if (login_obj.login(username, password)): msg = "Login was successful" result_flag = True login_obj.write(msg) else: msg = "Login failed" login_obj.write(msg) #Create an object for main page with header and menu main_obj = PageFactory.get_page_object("main", driver) main_obj.wait(3) #Search the inbox for message by subject 'POM' and open the message if main_obj.header_obj.search_by_subject('POM'): main_obj.write("Search successful") result_flag = True else: main_obj.write("Search text was not found") result_flag = False #Go to inbox main_obj.menu_obj.select_menu_item('inbox') #Update TestRail if testrail_run_id is not None: login_obj.write('About to update TestRail') case_id = 67 Test_Rail.update_testrail(case_id, testrail_run_id, result_flag, msg=msg) main_obj.teardown()
def get_testrail_conf(): "Get the testrail account credentials from the testrail.env file" testrail_file = os.path.join(os.path.dirname(__file__),'testrail.env') #TestRail Url testrail_url = Conf_Reader.get_value(testrail_file,'TESTRAIL_URL') client = testrail.APIClient(testrail_url) #TestRail User and Password client.user = Conf_Reader.get_value(testrail_file,'TESTRAIL_USER') client.password = Conf_Reader.get_value(testrail_file,'TESTRAIL_PASSWORD') return client
def get_testrail_conf(): "Get the testrail account credentials from the testrail.env file" testrail_file = os.path.join(os.path.dirname(__file__), 'testrail.env') #TestRail Url testrail_url = Conf_Reader.get_value(testrail_file, 'TESTRAIL_URL') client = testrail.APIClient(testrail_url) #TestRail User and Password client.user = Conf_Reader.get_value(testrail_file, 'TESTRAIL_USER') client.password = Conf_Reader.get_value(testrail_file, 'TESTRAIL_PASSWORD') return client
def run_search_inbox_test(browser, conf, base_url, sauce_flag, browser_version, platform, testrail_run_id): "Login to Gmail using the page object model" # get the test account credentials from the .credentials file credentials_file = os.path.join(os.path.dirname(__file__), "login.credentials") username = Conf_Reader.get_value(credentials_file, "LOGIN_USER") password = Conf_Reader.get_value(credentials_file, "LOGIN_PASSWORD") # Result flag used by TestRail result_flag = False # Setup a driver # create object of driver factory driver_obj = DriverFactory() driver = driver_obj.get_web_driver(browser, sauce_flag, browser_version, platform) driver.maximize_window() # Create a login page object login_obj = PageFactory.get_page_object("login", driver) if login_obj.login(username, password): msg = "Login was successful" result_flag = True login_obj.write(msg) else: msg = "Login failed" login_obj.write(msg) # Create an object for main page with header and menu main_obj = PageFactory.get_page_object("main", driver) main_obj.wait(3) # Search the inbox for message by subject 'POM' and open the message if main_obj.header_obj.search_by_subject("POM"): main_obj.write("Search successful") result_flag = True else: main_obj.write("Search text was not found") result_flag = False # Go to inbox main_obj.menu_obj.select_menu_item("inbox") # Update TestRail if testrail_run_id is not None: login_obj.write("About to update TestRail") case_id = 67 Test_Rail.update_testrail(case_id, testrail_run_id, result_flag, msg=msg) main_obj.teardown()
def run_demo_test(browser,conf,tconf,base_url,test_run_id=None,sauce_flag=None,browser_version=None,platform=None): "Demo Test Run" #Setup a driver driver_obj = DriverFactory() driver = driver_obj.get_web_driver(browser,sauce_flag,browser_version,platform) driver.implicitly_wait(10) # Some elements are taking long to load driver.maximize_window() #Result flag which will check if testrail.conf is present tconf_flag = check_file_exists(tconf) #Result flag used by TestRail result_flag = False #1. Create a home page object and choose Market #Create a login page object home_obj = PageFactory.get_page_object("home",driver) city_name = Conf_Reader.get_value(conf,'CITY_NAME') result_flag = home_obj.choose_market(city_name) if (result_flag): msg = "Market was set to %s"%city_name else: msg = "Could not set market to %s"%city_name home_obj.write(msg) #Update TestRail #Get the case id from tesrail.conf file if tconf_flag: case_id = Conf_Reader.get_value(tconf,'CHOOSE_MARKET') Test_Rail.update_testrail(case_id,test_run_id,result_flag,msg=msg) #2. Filter by size on office space page #Create project space page object office_space_obj = PageFactory.get_page_object("office-space",driver) min_sqft = Conf_Reader.get_value(conf,'MIN_SQFT') max_sqft = Conf_Reader.get_value(conf,'MAX_SQFT') expected_result =Conf_Reader.get_value(conf,'EXPECTED_RESULT_FOR_SIZE') result_flag = office_space_obj.filter_by_size(min_sqft,max_sqft,expected_result) if (result_flag): msg = "Search results for filter by size matched the expected result of %s space(s)"%expected_result else: msg = "Actual result did not match the expected result %s space"%expected_result office_space_obj.write(msg) #Update TestRail #Get the case id from tesrail.conf file if tconf_flag: case_id = Conf_Reader.get_value(tconf,'OFFICESPACE_FILTER_SIZE') Test_Rail.update_testrail(case_id,test_run_id,result_flag,msg=msg) #3.Open a listing on co-working page #Create co-working page object coworking_obj = PageFactory.get_page_object("coworking",driver) listing_name = Conf_Reader.get_value(conf,'LISTING_NAME_20MISSION') listing_href = Conf_Reader.get_value(conf,'LISTING_HREF_20MISSION') result_flag1 = coworking_obj.verify_listing(listing_name,listing_href) if result_flag1: result_flag2 = coworking_obj.click_listing(listing_href) if result_flag2: listing_obj = PageFactory.get_page_object("listing",driver) result_flag = listing_obj.verify_listing_name(listing_name) if (result_flag): msg = "Listing matched for %s"%listing_name else: msg = "Listing did not match or '0' coworking spaces" coworking_obj.write(msg) #Update TestRail #Get the case id from tesrail.conf file if tconf_flag: case_id = Conf_Reader.get_value(tconf,'COWORKING_LISTING') Test_Rail.update_testrail(case_id,test_run_id,result_flag,msg=msg) #Teardown home_obj.wait(3) home_obj.teardown() #You can use any page object to teardown
def run_demo_test(browser,config_file,base_url,test_run_id=None,sauce_flag=None,browser_version=None,platform=None): "Demo Test Run" #Setup a driver driver_obj = DriverFactory() driver = driver_obj.get_web_driver(browser,sauce_flag,browser_version,platform) #a) Login # get the test account credentials from the .credentials file PY_SCRIPTS_PATH=os.path.dirname(__file__) dotenv.load_dotenv(os.path.join(PY_SCRIPTS_PATH,"login.credentials")) USERNAME = os.environ['LOGIN_USER'] PASSWORD = os.environ['LOGIN_PASSWORD'] login_obj = PageFactory.get_page_object("login",driver) if login_obj.verify_header_text(): login_obj.write('PASS: Verifed the header text on login page') else: login_obj.write('FAIL: Header text is not matching on login page') if login_obj.login(USERNAME,PASSWORD): login_obj.write('PASS: Login was successful') else: login_obj.write('FAIL: Login failed') #Create a Bills Page object, verify all fields bills_obj = PageFactory.get_page_object('bills',driver) #b) Search for a category category_name = Conf_Reader.get_value(config_file,'CATEGORY') if bills_obj.search_bills(category_name): bills_obj.write('PASS: Searched for the bill category: %s.'%category_name) else: bills_obj.write('FAIL: Was not able to Search for the bill category: %s.'%category_name) #c) Go to a specific bill bill_number = Conf_Reader.get_value(config_file,'BILL_NUMBER') if bills_obj.goto_specific_bill(bill_number): bills_obj.write('PASS: Clicked on bill number: %s'%bill_number) else: bills_obj.write('FAIL: Unable to click on bill number: %s'%bill_number) #Verify the bill number if bills_obj.verify_bill_number(bill_number): bills_obj.write('PASS: Obtained the expected bill number: %s'%bill_number) else: bills_obj.write('FAIL: Obtained an unexpected bill number: %s'%bills_obj.get_bill_number()) bills_obj.write('\t\tEXPECTED: %s'%bill_number) #Verify the state name state_name = Conf_Reader.get_value(config_file,'STATE_NAME') if bills_obj.verify_state_name(state_name): bills_obj.write('PASS: Obtained the expected state name: %s'%state_name) else: bills_obj.write('FAIL: Obtained an unexpected state name: %s'%bills_obj.get_state_name()) bills_obj.write('\t\tEXPECTED: %s'%state_name) #Verify the session session_name = Conf_Reader.get_value(config_file,'SESSION') if bills_obj.verify_session_name(session_name): bills_obj.write('PASS: Obtained the expected session: %s'%session_name) else: bills_obj.write('FAIL: Obtained an unexpected session: %s'%bills_obj.get_session()) bills_obj.write('\t\tEXPECTED: %s'%session_name) #Verify the title title_name = Conf_Reader.get_value(config_file,'TITLE') if bills_obj.verify_title_name(title_name): bills_obj.write('PASS: Obtained the expected title: %s'%title_name) else: bills_obj.write('FAIL: Obtained an unexpected title: %s'%bills_obj.get_title()) bills_obj.write('\t\tEXPECTED: %s'%title_name) #Verify the description description_name = Conf_Reader.get_value(config_file,'DESCRIPTION') if bills_obj.verify_description_name(description_name): bills_obj.write('PASS: Obtained the expected description: %s'%description_name) else: bills_obj.write('FAIL: Obtained an unexpected description: %s'%bills_obj.get_description()) bills_obj.write('\t\tEXPECTED: %s'%description_name) #Verify the category category_name = Conf_Reader.get_value(config_file,'CATEGORIES') if bills_obj.verify_category_name(category_name): bills_obj.write('PASS: Obtained the expected category: %s'%category_name) else: bills_obj.write('FAIL: Obtained an unexpected category: %s'%bills_obj.get_category()) bills_obj.write('\t\tEXPECTED: %s'%category_name) #{?)Verify the forecast - we expect this to change #We wont know how to design a good check until we know the underlying algorithm fiscalnote_forecast = Conf_Reader.get_value(config_file,'FISCALNOTE_FORECAST') if bills_obj.verify_fiscalnote_forecast(fiscalnote_forecast): bills_obj.write('PASS: Obtained the expected forecast: %s'%fiscalnote_forecast) else: bills_obj.write('FAIL: Obtained an unexpected forecast: %s'%bills_obj.get_forecast()) bills_obj.write('\t\tEXPECTED: %s'%fiscalnote_forecast) #(?)Verify the floor - we expect this to change #We wont know how to design a good check until we know the underlying algorithm floor = Conf_Reader.get_value(config_file,'FLOOR') if bills_obj.verify_floor(floor): bills_obj.write('PASS: Obtained the expected floor: %s'%floor) else: bills_obj.write('FAIL: Obtained an unexpected floor: %s'%bills_obj.get_floor()) bills_obj.write('\t\tEXPECTED: %s'%floor) #W00t! Close the browser driver.quit()
"Set the username on login screen" self.set_text(self.login_email, username) def set_login_password(self, password): self.set_text(self.login_password, password) def submit_login(self): self.click_element(self.submit_button) self.wait(5) if __name__ == '__main__': # get the test account credentials from the .credentials file credentials_file = os.path.join(os.path.dirname(__file__), 'login.credentials') username = Conf_Reader.get_value(credentials_file, 'LOGIN_USER') password = Conf_Reader.get_value(credentials_file, 'LOGIN_PASSWORD') # create a login page object driver = webdriver.Firefox() login_obj = Signin_Page(driver, base_url="https://www.cleartrip.com/") if (login_obj.login(username, password)): msg = "Login was successful" login_obj.write(msg) else: msg = "Login failed" login_obj.write(msg)