Best Python code snippet using toolium_python
careers_page.py
Source:careers_page.py
1from selenium.webdriver.common.by import By2from config.config import TestData3from pages.base_page import BasePage4class CareersPage(BasePage):5 TARGET_URL = TestData.CAREERS_URL6 """General Locators for the Careers page"""7 TAB_ONE = (By.XPATH, "//li[@data-tab='Xenetaisone-1']")8 TAB_TWO = (By.XPATH, "//li[@data-tab='Modernizationthroughdata-2']")9 TAB_THREE = (By.XPATH, "//li[@data-tab='VarietyandFairness-3']")10 TAB_FOUR = (By.XPATH, "//li[@data-tab='TransparencybuildsTrust-4']")11 BOX_ONE = (By.CSS_SELECTOR, "#Xenetaisone-1 h2")12 BOX_TWO = (By.CSS_SELECTOR, "#Modernizationthroughdata-2 h2")13 BOX_THREE = (By.CSS_SELECTOR, "#VarietyandFairness-3 h2")14 BOX_FOUR = (By.CSS_SELECTOR, "#TransparencybuildsTrust-4 h2")15 CARD_OSLO = (By.CSS_SELECTOR, "#slick-slide00 .card-image.section-bg")16 CARD_NEW_YORK = (By.CSS_SELECTOR, "#slick-slide01 .card-image.section-bg")17 CARD_HAMBURG = (By.CSS_SELECTOR, "#slick-slide02 .card-image.section-bg")18 BUTTON_OSLO = (By.XPATH, "//a[contains(@href,'oslo') and @class='cta_button']")19 BUTTON_NEW_YORK = (By.XPATH, "//a[contains(@href,'new-york') and @class='cta_button']")20 BUTTON_HAMBURG = (By.XPATH, "//a[contains(@href,'hamburg') and @class='cta_button']")21 JOBS_URL_COUNT = (By.CSS_SELECTOR, ".subscription-model-inner a")22 JOBS_ROLES_COUNT = (By.CSS_SELECTOR, ".accordion_group")23 #######################################################################################24 """Tab one related methods"""25 # .lower() is used to avoid letter case issue26 # in is used to avoid empty space27 def click_tab_one(self):28 return self.do_click(self.TAB_ONE, 'click_tab_one')29 def check_tab_one(self):30 return self.is_visible(self.BOX_ONE, 'check_tab_one')31 def compare_info_tab_one(self):32 tab = self.get_element_text(self.TAB_ONE)33 box = self.get_element_text(self.BOX_ONE)34 return tab.lower() in box.lower()35 #######################################################################################36 """Tab two related methods"""37 # .lower() is used to avoid letter case issue38 # in is used to avoid empty space39 def click_tab_two(self):40 return self.do_click(self.TAB_TWO, 'click_tab_two')41 def check_tab_two(self):42 return self.is_visible(self.BOX_TWO, 'check_tab_two')43 def compare_info_tab_two(self):44 tab = self.get_element_text(self.TAB_TWO, 'get_element_tab')45 box = self.get_element_text(self.BOX_TWO, 'get_element_box')46 return tab.lower() in box.lower()47 #######################################################################################48 """Tab three related methods"""49 # .lower() is used to avoid letter case issue50 # in is used to avoid empty space51 def click_tab_three(self):52 return self.do_click(self.TAB_THREE, 'click_tab_three')53 def check_tab_three(self):54 return self.is_visible(self.BOX_THREE, 'check_tab_three')55 def compare_info_tab_three(self):56 tab = self.get_element_text(self.TAB_THREE, 'get_element_tab')57 box = self.get_element_text(self.BOX_THREE, 'get_element_box')58 return tab.lower() in box.lower()59 #######################################################################################60 """Tab four related methods"""61 # .lower() is used to avoid letter case issue62 # in is used to avoid empty space63 def click_tab_four(self):64 return self.do_click(self.TAB_FOUR, 'click_tab_four')65 def check_tab_four(self):66 return self.is_visible(self.BOX_FOUR, 'check_tab_four')67 def compare_info_tab_four(self):68 tab = self.get_element_text(self.TAB_FOUR, 'get_element_tab')69 box = self.get_element_text(self.BOX_FOUR, 'get_element_box')70 return tab.lower() in box.lower()71 #######################################################################################72 """Xeneta Offices related methods"""73 # Oslo Office74 def click_oslo_card(self):75 return self.do_click(self.CARD_OSLO, 'click_card_oslo')76 def check_oslo_url(self):77 return self.get_link(TestData.OSLO_URL, 'check_oslo_url')78 def click_oslo_button(self):79 return self.do_click(self.BUTTON_OSLO, 'click_oslo_button')80 # New York Office81 def click_new_york_card(self):82 return self.do_click(self.CARD_NEW_YORK, 'click_card_new_york')83 def check_new_york_url(self):84 return self.get_link(TestData.NEW_YORK_URL, 'check_new_york_url')85 def click_new_york_button(self):86 return self.do_click(self.BUTTON_NEW_YORK, 'click_new_york_button')87 # Hamburg Office88 def click_hamburg_card(self):89 return self.do_click(self.CARD_HAMBURG, 'click_card_hamburg')90 def check_hamburg_url(self):91 return self.get_link(TestData.HAMBURG_URL, 'check_hamburg_url')92 def click_hamburg_button(self):93 return self.do_click(self.BUTTON_HAMBURG, 'click_hamburg_button')94 #######################################################################################95 """Open Roles Card"""96 def count_open_roles(self):97 return self.count_elements_not_visible(self.JOBS_ROLES_COUNT, 'count_open_roles')98 def count_url_roles(self):...
screenshot.py
Source:screenshot.py
...27 image.save(f"images/{save_name}.png")28 return f"images/{save_name}.png"29 else:30 return None31def get_element_box(driver):32 try:33 e = driver.find_element_by_class_name("item-box")34 except NoSuchElementException:35 return None36 if not e or (not e.size["width"] and not e.size["height"]): # Check if item-box is hidden37 e = driver.find_element_by_class_name("infocard")38 else:39 return None40 return e41def get_image(item):42 if config.browser == "chrome":43 options = Options()44 options.set_headless(True)45 driver = webdriver.Chrome(executable_path=config.driver_executable, chrome_options=options)46 elif config.browser == "phantomjs":47 driver = webdriver.PhantomJS()48 driver.set_window_size(config.browser_width,config.browser_height)49 item = quote(item) # urllib.parse: Converts special characters to html safe encodings e.g. ' ' --> %2050 driver.get(config.wiki.format(item))...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!