Best Python code snippet using locust
base_page.py
Source:base_page.py
1# coding=UTF-82import logging,os,settings3from datetime import datetime4from selenium.common.exceptions import NoSuchElementException, TimeoutException, InvalidElementStateException5from selenium.webdriver.common.by import By6from selenium.webdriver.support import expected_conditions as expected7from selenium.webdriver.support.wait import WebDriverWait8from settings import WAIT_TIME9logger = logging.getLogger(__name__)10def fail_on_screenshot(function):11 def get_snapshot_directory():12 if not os.path.exists(settings.SNAPSHOT_DIRECTORY):13 os.mkdir(settings.SNAPSHOT_DIRECTORY)14 return settings.SNAPSHOT_DIRECTORY15 def get_current_time_str():16 return datetime.strftime(datetime.now(), "%Y%m%d%H%M%S%f")17 def wrapper(*args, **kwargs):18 instance, selector = args[0], args[1]19 try:20 return function(*args, **kwargs)21 except (TimeoutException, NoSuchElementException, InvalidElementStateException) as ex:22 logger.error("Could not find the selector: [{}].".format(selector))23 filename = "{}.png".format(get_current_time_str())24 screenshot_path = os.path.join(get_snapshot_directory(), filename)25 logger.debug(instance.selenium.page_source)26 instance.selenium.save_screenshot(screenshot_path)27 raise ex28 return wrapper29class BasePage(object):30 url = ""31 base_url = settings.WEB_TEST_BASE_URL32 def __init__(self, selenium, url_params=None):33 if not url_params:34 url_params = []35 self.selenium = selenium36 self.url_params = url_params37 self.go_to()38 def go_to(self):39 logger.debug("Goto page: [{}]".format(self.get_page_url()))40 return self._selenium_get_url(self.get_page_url())41 def refresh(self):42 self.selenium.refresh()43 def navigate_back(self):44 self.selenium.back()45 def _selenium_get_url(self, url):46 try:47 self.selenium.get('about:blank')48 self.selenium.get(str(url))49 except Exception as ex:50 logger.error("Can not open the url:[{}]".format(url))51 raise ex52 return self53 def get_page_url(self):54 if not self.url:55 raise RuntimeError("no url been set")56 return self._get_url(self.url)57 def _get_url(self, url):58 format_url = url.format(*self.url_params)59 return "{0}{1}".format(self.base_url, format_url)60 def get_current_page_url(self):61 return self.selenium.current_url62 def get_page_title(self):63 return self.selenium.title64 def get_cookie_value(self):65 return self.selenium.get_cookie('client_identity')['value']66 def get_current_window_handle(self):67 return self.selenium.current_window_handle68 def get_window_handles(self):69 return self.selenium.window_handles70 def choose_window_handle(self, handle):71 self.selenium.switch_to.window(handle)72 return self73 # å·æ°é¡µé¢74 def refresh_page(self):75 self.selenium.refresh()76 return self77 # æ§å¶js78 def execute_script(self):79 js = "window.scrollTo(0,0)"80 self.selenium.execute_script(js)81 # ---------------------------------------------------------------------------------------------------------------82 '''å¤ææ个å
ç´ æ¯å¦è¢«æ·»å å°äºdomé并ä¸å¯è§ï¼å¯è§ä»£è¡¨å
ç´ å¯æ¾ç¤ºä¸å®½åé«é½å¤§äº0'''83 @fail_on_screenshot84 def find_element_by_css(self, selector, wait_time=WAIT_TIME):85 return WebDriverWait(self.selenium, wait_time).until(86 expected.visibility_of_element_located((By.CSS_SELECTOR, selector)))87 @fail_on_screenshot88 def find_element_by_link_text(self, selector, wait_time=WAIT_TIME):89 return WebDriverWait(self.selenium, wait_time).until(90 expected.visibility_of_element_located((By.LINK_TEXT, selector)))91 @fail_on_screenshot92 def find_element_by_partial_link_text(self, selector, wait_time=WAIT_TIME):93 return WebDriverWait(self.selenium, wait_time).until(94 expected.visibility_of_element_located((By.PARTIAL_LINK_TEXT, selector)))95 @fail_on_screenshot96 def find_element_by_id(self, selector, wait_time=WAIT_TIME):97 return WebDriverWait(self.selenium, wait_time).until(98 expected.visibility_of_element_located((By.ID, selector)))99 @fail_on_screenshot100 def find_element_by_xpath(self, selector, wait_time=WAIT_TIME):101 return WebDriverWait(self.selenium, wait_time).until(102 expected.visibility_of_element_located((By.XPATH, selector)))103 @fail_on_screenshot104 def find_element_by_name(self, selector, wait_time=WAIT_TIME):105 return WebDriverWait(self.selenium, wait_time).until(106 expected.visibility_of_element_located((By.NAME, selector)))107 @fail_on_screenshot108 def find_element_by_class_name(self, selector, wait_time=WAIT_TIME):109 return WebDriverWait(self.selenium, wait_time).until(110 expected.visibility_of_element_located((By.CLASS_NAME, selector)))111 @fail_on_screenshot112 def find_element_by_tag_name(self, selector, wait_time=WAIT_TIME):113 return WebDriverWait(self.selenium, wait_time).until(114 expected.visibility_of_element_located((By.TAG_NAME, selector)))115 # ----------------------------------------------------------------------------------------------------------------116 '''å¤ææ¯å¦è³å°æ1个å
ç´ åå¨äºdomæ ä¸ï¼å¦æå®ä½å°å°±è¿åå表'''117 @fail_on_screenshot118 def find_elements_by_css(self, selector, wait_time=WAIT_TIME):119 return WebDriverWait(self.selenium, wait_time).until(120 expected.presence_of_all_elements_located((By.CSS_SELECTOR, selector)))121 @fail_on_screenshot122 def find_elements_by_class_name(self, selector, wait_time=WAIT_TIME):123 return WebDriverWait(self.selenium, wait_time).until(124 expected.presence_of_all_elements_located((By.CLASS_NAME, selector)))125 @fail_on_screenshot126 def find_elements_by_link_text(self, selector, wait_time=WAIT_TIME):127 return WebDriverWait(self.selenium, wait_time).until(128 expected.presence_of_all_elements_located((By.LINK_TEXT, selector)))129 @fail_on_screenshot130 def find_elements_by_xpath(self, selector, wait_time=WAIT_TIME):131 return WebDriverWait(self.selenium, wait_time).until(132 expected.presence_of_all_elements_located((By.XPATH, selector)))133 @fail_on_screenshot134 def find_elements_by_name(self, selector, wait_time=WAIT_TIME):135 return WebDriverWait(self.selenium, wait_time).until(136 expected.presence_of_all_elements_located((By.NAME, selector)))137 # -------------------------------------------------------------------------------------------------------------138 '''å¤ææ个å
ç´ å¨æ¯å¦åå¨äºdomæä¸å¯è§,å¦æå¯è§è¿åFalse,ä¸å¯è§è¿åè¿ä¸ªå
ç´ '''139 @fail_on_screenshot140 def invisible_element_by_id(self, selector, wait_time=WAIT_TIME):141 return WebDriverWait(self.selenium, wait_time).until(142 expected.invisibility_of_element_located((By.ID, selector)))143 @fail_on_screenshot144 def invisible_element_by_xpath(self, selector, wait_time=WAIT_TIME):145 return WebDriverWait(self.selenium, wait_time).until(146 expected.invisibility_of_element_located((By.XPATH, selector)))147 @fail_on_screenshot148 def invisible_element_by_css(self, selector, wait_time=WAIT_TIME):149 return WebDriverWait(self.selenium, wait_time).until(150 expected.invisibility_of_element_located((By.CSS_SELECTOR, selector)))151 @fail_on_screenshot152 def invisible_element_by_link_text(self, selector, wait_time=WAIT_TIME):153 return WebDriverWait(self.selenium, wait_time).until(154 expected.invisibility_of_element_located((By.LINK_TEXT, selector)))155 @fail_on_screenshot156 def invisible_element_by_name(self, selector, wait_time=WAIT_TIME):157 return WebDriverWait(self.selenium, wait_time).until(158 expected.invisibility_of_element_located((By.NAME, selector)))159 @fail_on_screenshot160 def invisible_element_by_class_name(self, selector, wait_time=WAIT_TIME):161 return WebDriverWait(self.selenium, wait_time).until(162 expected.invisibility_of_element_located((By.CLASS_NAME, selector)))163 @fail_on_screenshot164 def invisible_element_by_tag_name(self, selector, wait_time=WAIT_TIME):165 return WebDriverWait(self.selenium, wait_time).until(166 expected.invisibility_of_element_located((By.TAG_NAME, selector)))167 @fail_on_screenshot168 def invisible_element_by_partial_link_text(self, selector, wait_time=WAIT_TIME):169 return WebDriverWait(self.selenium, wait_time).until(170 expected.invisibility_of_element_located((By.PARTIAL_LINK_TEXT, selector)))171 # -----------------------------------------------------------------------------------------------------------------172 '''å¤ææå®çå
ç´ ä¸æ¯å¦å
å«äºé¢æçå符串ï¼è¿åå¸å°å¼'''173 @fail_on_screenshot174 def text_to_be_present_in_element_by_id(self, selector, wait_time=WAIT_TIME,text=None):175 return WebDriverWait(self.selenium, wait_time).until(176 expected.text_to_be_present_in_element((By.ID, selector),text))177 @fail_on_screenshot178 def text_to_be_present_in_element_by_name(self, selector, wait_time=WAIT_TIME,text=None):179 return WebDriverWait(self.selenium, wait_time).until(180 expected.text_to_be_present_in_element((By.NAME, selector),text))181 @fail_on_screenshot182 def text_to_be_present_in_element_by_class_name(self, selector, wait_time=WAIT_TIME,text=None):183 return WebDriverWait(self.selenium, wait_time).until(184 expected.text_to_be_present_in_element((By.CLASS_NAME, selector),text))185 @fail_on_screenshot186 def text_to_be_present_in_element_by_xpath(self, selector, wait_time=WAIT_TIME,text=None):187 return WebDriverWait(self.selenium, wait_time).until(188 expected.text_to_be_present_in_element((By.XPATH, selector),text))189 @fail_on_screenshot190 def text_to_be_present_in_element_by_tag_name(self, selector, wait_time=WAIT_TIME,text=None):191 return WebDriverWait(self.selenium, wait_time).until(192 expected.text_to_be_present_in_element((By.TAG_NAME, selector),text))193 @fail_on_screenshot194 def text_to_be_present_in_element_by_css(self, selector, wait_time=WAIT_TIME,text=None):195 return WebDriverWait(self.selenium, wait_time).until(196 expected.text_to_be_present_in_element((By.CSS_SELECTOR, selector),text))197 # -----------------------------------------------------------------------------------------------------------------198 '''å¤ææå®å
ç´ çå±æ§å¼ä¸æ¯å¦å
å«äºé¢æçå符串ï¼è¿åå¸å°å¼'''199 @fail_on_screenshot200 def text_to_be_present_in_element_value_by_css(self, selector, wait_time=WAIT_TIME,text=None):201 return WebDriverWait(self.selenium, wait_time).until(202 expected.text_to_be_present_in_element_value((By.CSS_SELECTOR, selector),text))203 @fail_on_screenshot204 def text_to_be_present_in_element_value_by_id(self, selector, wait_time=WAIT_TIME,text=None):205 return WebDriverWait(self.selenium, wait_time).until(206 expected.text_to_be_present_in_element_value((By.ID, selector),text))207 @fail_on_screenshot208 def text_to_be_present_in_element_value_by_name(self, selector, wait_time=WAIT_TIME,text=None):209 return WebDriverWait(self.selenium, wait_time).until(210 expected.text_to_be_present_in_element_value((By.NAME, selector),text))211 @fail_on_screenshot212 def text_to_be_present_in_element_value_by_css_name(self, selector, wait_time=WAIT_TIME,text=None):213 return WebDriverWait(self.selenium, wait_time).until(214 expected.text_to_be_present_in_element_value((By.CLASS_NAME, selector),text))215 @fail_on_screenshot216 def text_to_be_present_in_element_value_by_xpath(self, selector, wait_time=WAIT_TIME,text=None):217 return WebDriverWait(self.selenium, wait_time).until(218 expected.text_to_be_present_in_element_value((By.XPATH, selector),text))219 @fail_on_screenshot220 def text_to_be_present_in_element_value_by_tag_name(self, selector, wait_time=WAIT_TIME,text=None):221 return WebDriverWait(self.selenium, wait_time).until(222 expected.text_to_be_present_in_element_value((By.TAG_NAME, selector),text))223 # -----------------------------------------------------------------------------------------------------------------224 '''å¤ætitle,è¿åå¸å°å¼'''225 @fail_on_screenshot226 def page_title_is(self, title, wait_time=WAIT_TIME):227 return WebDriverWait(self.selenium, wait_time).until(expected.title_is(title))228 @fail_on_screenshot229 def page_title_contains(self, title, wait_time=WAIT_TIME):230 return WebDriverWait(self.selenium, wait_time).until(expected.title_contains(title))231 # -----------------------------------------------------------------------------------------------------------------232 '''å¤ææ个å
ç´ ä¸æ¯å¦å¯è§å¹¶ä¸æ¯enableçï¼ä»£è¡¨å¯ç¹å»'''233 @fail_on_screenshot234 def element_to_be_click_able_by_id(self, selector, wait_time=WAIT_TIME):235 return WebDriverWait(self.selenium, wait_time).until(236 expected.element_to_be_clickable((By.ID, selector)))237 @fail_on_screenshot238 def element_to_be_click_able_by_name(self, selector, wait_time=WAIT_TIME):239 return WebDriverWait(self.selenium, wait_time).until(240 expected.element_to_be_clickable((By.NAME, selector)))241 @fail_on_screenshot242 def element_to_be_click_able_by_class_name(self, selector, wait_time=WAIT_TIME):243 return WebDriverWait(self.selenium, wait_time).until(244 expected.element_to_be_clickable((By.CLASS_NAME, selector)))245 @fail_on_screenshot246 def element_to_be_click_able_by_css(self, selector, wait_time=WAIT_TIME):247 return WebDriverWait(self.selenium, wait_time).until(248 expected.element_to_be_clickable((By.CSS_SELECTOR, selector)))249 @fail_on_screenshot250 def element_to_be_click_able_by_tag_name(self, selector, wait_time=WAIT_TIME):251 return WebDriverWait(self.selenium, wait_time).until(252 expected.element_to_be_clickable((By.TAG_NAME, selector)))253 @fail_on_screenshot254 def element_to_be_click_able_by_xpath(self, selector, wait_time=WAIT_TIME):255 return WebDriverWait(self.selenium, wait_time).until(256 expected.element_to_be_clickable((By.XPATH, selector)))257 @fail_on_screenshot258 def element_to_be_click_able_by_link_text(self, selector, wait_time=WAIT_TIME):259 return WebDriverWait(self.selenium, wait_time).until(260 expected.element_to_be_clickable((By.LINK_TEXT, selector)))261 # -----------------------------------------------------------------------------------------------------------------262 '''å¤æå
ç´ æ¯å¦å¯è§ï¼å¦æå¯è§å°±è¿åè¿ä¸ªå
ç´ ï¼ä¸å¯è§è¿åFalse'''263 @fail_on_screenshot264 def visibility_of_element_by_id(self, selector, wait_time=WAIT_TIME):265 return WebDriverWait(self.selenium, wait_time).until(266 expected.visibility_of_element_located((By.ID, selector)))267 @fail_on_screenshot268 def visibility_of_element_by_name(self, selector, wait_time=WAIT_TIME):269 return WebDriverWait(self.selenium, wait_time).until(270 expected.visibility_of_element_located((By.NAME, selector)))271 @fail_on_screenshot272 def visibility_of_element_by_class_name(self, selector, wait_time=WAIT_TIME):273 return WebDriverWait(self.selenium, wait_time).until(274 expected.visibility_of_element_located((By.CLASS_NAME, selector)))275 @fail_on_screenshot276 def visibility_of_element_by_css(self, selector, wait_time=WAIT_TIME):277 return WebDriverWait(self.selenium, wait_time).until(278 expected.visibility_of_element_located((By.CSS_SELECTOR, selector)))279 @fail_on_screenshot280 def visibility_of_element_by_xpath(self, selector, wait_time=WAIT_TIME):281 return WebDriverWait(self.selenium, wait_time).until(282 expected.visibility_of_element_located((By.XPATH, selector)))283 @fail_on_screenshot284 def visibility_of_element_by_tag_name(self, selector, wait_time=WAIT_TIME):285 return WebDriverWait(self.selenium, wait_time).until(286 expected.visibility_of_element_located((By.TAG_NAME, selector)))287 def get_cookie_by_name(self, name):288 cookie = self.selenium.get_cookie(name)289 return cookie['value']290 def get_session_id(self):291 return self.get_cookie_by_name("TSID")292class UserBasePage(BasePage):...
test_script.py
Source:test_script.py
1# Generated by Selenium IDE2import pytest3import time4import json5from selenium import webdriver6from selenium.webdriver.common.by import By7from selenium.webdriver.common.action_chains import ActionChains8from selenium.webdriver.support import expected_conditions9from selenium.webdriver.support.wait import WebDriverWait10from selenium.webdriver.common.keys import Keys11from selenium.webdriver.common.desired_capabilities import DesiredCapabilities12WAIT_TIME = 513class TestTest1():14 def setup_method(self):15 self.driver = webdriver.Firefox()16 self.vars = {}17 18 def teardown_method(self):19 self.driver.quit()20 21 def test_test1(self):22 self.driver.get("https://localhost/prestashop/5-botki")23 self.driver.set_window_size(1360, 665)24 self.driver.find_element(By.LINK_TEXT, "Botki Jenny Fairy WS3987-01 Czarny").click()25 time.sleep(WAIT_TIME)26 self.driver.find_element(By.CSS_SELECTOR, ".exclusive > span").click()27 time.sleep(WAIT_TIME)28 self.driver.find_element(By.CSS_SELECTOR, ".continue > span").click()29 time.sleep(WAIT_TIME)30 self.driver.find_element(By.CSS_SELECTOR, "span:nth-child(5) span").click()31 time.sleep(WAIT_TIME)32 self.driver.find_element(By.LINK_TEXT, "Botki Lasocki RST-2159-03 Czarny").click()33 time.sleep(WAIT_TIME)34 self.driver.find_element(By.CSS_SELECTOR, ".icon-plus").click()35 time.sleep(WAIT_TIME)36 self.driver.find_element(By.CSS_SELECTOR, ".icon-plus").click()37 time.sleep(WAIT_TIME)38 self.driver.find_element(By.CSS_SELECTOR, ".icon-plus").click()39 time.sleep(WAIT_TIME)40 self.driver.find_element(By.CSS_SELECTOR, ".icon-plus").click()41 time.sleep(WAIT_TIME)42 self.driver.find_element(By.CSS_SELECTOR, ".exclusive > span").click()43 time.sleep(WAIT_TIME)44 self.driver.find_element(By.CSS_SELECTOR, ".continue > span").click()45 time.sleep(WAIT_TIME)46 self.driver.find_element(By.CSS_SELECTOR, "span:nth-child(5) span").click()47 time.sleep(WAIT_TIME)48 self.driver.find_element(By.CSS_SELECTOR, ".block_content > .tree > li:nth-child(2) > .grower").click()49 time.sleep(WAIT_TIME)50 self.driver.find_element(By.CSS_SELECTOR, ".block_content li:nth-child(2) .last > .grower").click()51 time.sleep(WAIT_TIME)52 self.driver.find_element(By.CSS_SELECTOR, ".block_content > .tree > li:nth-child(2) li:nth-child(2) > a").click()53 time.sleep(WAIT_TIME)54 self.driver.find_element(By.LINK_TEXT, "Obuwie sportowe SPRANDI URBAN...").click()55 time.sleep(WAIT_TIME)56 self.driver.find_element(By.ID, "group_2").click()57 time.sleep(WAIT_TIME)58 dropdown = self.driver.find_element(By.ID, "group_2")59 time.sleep(WAIT_TIME)60 dropdown.find_element(By.XPATH, "//option[. = '41']").click()61 time.sleep(WAIT_TIME)62 self.driver.find_element(By.CSS_SELECTOR, "option:nth-child(2)").click()63 time.sleep(WAIT_TIME)64 self.driver.find_element(By.CSS_SELECTOR, ".exclusive > span").click()65 time.sleep(WAIT_TIME)66 self.driver.find_element(By.CSS_SELECTOR, ".continue > span").click()67 time.sleep(WAIT_TIME)68 self.driver.find_element(By.CSS_SELECTOR, "span:nth-child(5) span").click()69 time.sleep(WAIT_TIME)70 self.driver.find_element(By.LINK_TEXT, "Obuwie sportowe ADIDAS BRAVADA FW2887 BiaÅy").click()71 time.sleep(WAIT_TIME)72 self.driver.find_element(By.CSS_SELECTOR, ".icon-plus").click()73 time.sleep(WAIT_TIME)74 self.driver.find_element(By.CSS_SELECTOR, ".icon-plus").click()75 time.sleep(WAIT_TIME)76 self.driver.find_element(By.CSS_SELECTOR, ".icon-plus").click()77 time.sleep(WAIT_TIME)78 self.driver.find_element(By.CSS_SELECTOR, ".columns-container").click()79 time.sleep(WAIT_TIME)80 self.driver.find_element(By.CSS_SELECTOR, ".exclusive > span").click()81 time.sleep(WAIT_TIME)82 self.driver.find_element(By.CSS_SELECTOR, ".button-medium > span").click()83 time.sleep(WAIT_TIME)84 self.driver.find_element(By.CSS_SELECTOR, "#\\31_351_0_0 > .icon-trash").click()85 time.sleep(WAIT_TIME)86 self.driver.find_element(By.CSS_SELECTOR, ".standard-checkout > span").click()87 time.sleep(WAIT_TIME)88 self.driver.find_element(By.ID, "email_create").click()89 time.sleep(WAIT_TIME)90 self.driver.find_element(By.ID, "email_create").send_keys("paulinaborys98@gmail.com")91 time.sleep(WAIT_TIME)92 self.driver.find_element(By.CSS_SELECTOR, "#SubmitCreate > span").click()93 time.sleep(WAIT_TIME)94 self.driver.find_element(By.ID, "id_gender2").click()95 time.sleep(WAIT_TIME)96 self.driver.find_element(By.ID, "customer_firstname").click()97 time.sleep(WAIT_TIME)98 self.driver.find_element(By.ID, "customer_firstname").send_keys("Paulina")99 time.sleep(WAIT_TIME)100 self.driver.find_element(By.ID, "customer_lastname").click()101 time.sleep(WAIT_TIME)102 self.driver.find_element(By.ID, "customer_lastname").send_keys("Borys")103 time.sleep(WAIT_TIME)104 self.driver.find_element(By.ID, "passwd").click()105 time.sleep(WAIT_TIME)106 self.driver.find_element(By.ID, "passwd").send_keys("haslo")107 time.sleep(WAIT_TIME)108 self.driver.find_element(By.ID, "newsletter").click()109 time.sleep(WAIT_TIME)110 self.driver.find_element(By.CSS_SELECTOR, "#submitAccount > span").click()111 time.sleep(WAIT_TIME)112 self.driver.find_element(By.ID, "address1").click()113 time.sleep(WAIT_TIME)114 self.driver.find_element(By.ID, "address1").send_keys("Brzechwy 27")115 time.sleep(WAIT_TIME)116 self.driver.find_element(By.ID, "postcode").click()117 time.sleep(WAIT_TIME)118 self.driver.find_element(By.ID, "postcode").send_keys("81-198")119 time.sleep(WAIT_TIME)120 self.driver.find_element(By.ID, "city").click()121 time.sleep(WAIT_TIME)122 self.driver.find_element(By.ID, "city").send_keys("Suchy Dwor")123 time.sleep(WAIT_TIME)124 self.driver.find_element(By.ID, "phone").click()125 time.sleep(WAIT_TIME)126 self.driver.find_element(By.ID, "phone").send_keys("600500400")127 time.sleep(WAIT_TIME)128 self.driver.find_element(By.CSS_SELECTOR, ".clearfix:nth-child(11)").click()129 time.sleep(WAIT_TIME)130 self.driver.find_element(By.ID, "alias").click()131 time.sleep(WAIT_TIME)132 self.driver.find_element(By.ID, "adress_alias").click()133 time.sleep(WAIT_TIME)134 self.driver.find_element(By.CSS_SELECTOR, "#submitAddress > span").click()135 time.sleep(WAIT_TIME)136 self.driver.find_element(By.CSS_SELECTOR, ".button:nth-child(4) > span").click()137 # time.sleep(WAIT_TIME+55)138 # self.driver.find_element(By.ID, "delivery_option_10_2").click()139 time.sleep(WAIT_TIME)140 self.driver.find_element(By.ID, "cgv").click()141 time.sleep(WAIT_TIME)142 self.driver.find_element(By.CSS_SELECTOR, ".standard-checkout > span").click()143 time.sleep(WAIT_TIME)144 self.driver.find_element(By.CSS_SELECTOR, ".cash").click()145 time.sleep(WAIT_TIME)146 self.driver.find_element(By.CSS_SELECTOR, "#cart_navigation span").click()147 time.sleep(WAIT_TIME)148 self.driver.find_element(By.LINK_TEXT, "Zobacz historiÄ swoich zamówieÅ").click()149 time.sleep(WAIT_TIME)150if __name__ == "__main__":151 t1 = TestTest1()152 t1.setup_method()153 print('START TESTU')154 t1.test_test1()155 t1.teardown_method()...
EPStest.py
Source:EPStest.py
1from eps_driver import EPS_driver2import time3debug = 14EPS = EPS_driver(debug)5print("\n\n---*** BEGINNING EPS STATUS TEST ***---")6time.sleep(1)7wait_time = .28while(1):9 ##########################10 print("\nVOLTAGE BUSES HEALTH INFO")11 '''12 print("***12 VOLT BUS***")13 EPS.Pow_12v()14 time.sleep(wait_time)15 print("***5 VOLT BUS***")16 EPS.Pow_5v()17 time.sleep(wait_time)18 print("***3.3 VOLT BUS***")19 EPS.Pow_3v3()20 time.sleep(wait_time)21 '''22 print("***RAW BATT BUS***")23 EPS.Pow_Batt()24 time.sleep(wait_time)25 '''26 print("***BUS CURRENT DRAW***")27 EPS.currentDraw_5v()28 time.sleep(wait_time)29 EPS.currentDraw_3v3()30 time.sleep(wait_time)31 '''32 '''33 #########################34 print("\nBCR HEALTH INFO")35 print("***BCR 1***")36 EPS.BCR_voltage(1) # 137 time.sleep(wait_time)38 EPS.BCR_currentA(1)39 time.sleep(wait_time)40 EPS.BCR_currentB(1)41 time.sleep(wait_time)42 EPS.BCR_tempA(1)43 time.sleep(wait_time)44 EPS.BCR_tempB(1)45 time.sleep(wait_time)46 EPS.BCR_SunA(1)47 time.sleep(wait_time)48 EPS.BCR_SunB(1)49 time.sleep(wait_time)50 print("***BCR 2***")51 EPS.BCR_voltage(2) # 252 time.sleep(wait_time)53 EPS.BCR_currentA(2)54 time.sleep(wait_time)55 EPS.BCR_currentB(2)56 time.sleep(wait_time)57 EPS.BCR_tempA(2)58 time.sleep(wait_time)59 EPS.BCR_tempB(2)60 time.sleep(wait_time)61 EPS.BCR_SunA(2)62 time.sleep(wait_time)63 EPS.BCR_SunB(2)64 time.sleep(wait_time)65 '''66 print("***BCR 3***")67 EPS.BCR3_voltage() # 368 time.sleep(wait_time)69 EPS.BCR_currentA(3)70 time.sleep(wait_time)71 EPS.BCR_currentB(3)72 time.sleep(wait_time)73 '''74 EPS.BCR_tempA(3)75 time.sleep(wait_time)76 EPS.BCR_tempB(3)77 time.sleep(wait_time)78 EPS.BCR_SunA(3)79 time.sleep(wait_time)80 EPS.BCR_SunB(3)81 time.sleep(wait_time)82 '''83 '''84 #####################85 print("\nGENERAL BOARD INFO")86 EPS.daughterBoard_temp()87 time.sleep(wait_time)88 EPS.motherBoard_temp()89 time.sleep(wait_time)90 '''91 print("\n\n---*** END EPS STATUS TEST ***---")92 print("***WILL REPEAT INDEFINITELY - CTRL C TO EXIT***")...
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!!