Best Python code snippet using ATX
main.py
Source: main.py
...9 brow, page = browser.create_web('', '')10 browser.goto(page, 'https://www.xdraco.com/nft/list')11 print('goto')12 browser.wait_selector(page, 'button.btn-open-list.btn-language')13 selector = browser.find_selector(page, 'button.btn-open-list.btn-language')14 browser.click_selector(page, selector)15 selectors = browser.find_selectors(page, '.v-list-item.v-list-item--link.theme--light')16 selector = selectors[19]17 print(browser.text_selector(page, selector))18 browser.click_selector(page, selector)19 browser.wait_selector(page, 'div.v-select__selections')20 selectors = browser.find_selectors(page, 'div.v-select__selections')21 selector_1, selector_2 = selectors22 browser.click_selector(page, selector_1)23 browser.wait_selector(page, 'div.v-list-item__title')24 selectors = browser.find_selectors(page, 'div.v-list-item__title')25 for selector in selectors:26 if browser.text_selector(page, selector) == pers_class:27 browser.click_selector(page, selector)28 print(browser.text_selector(page, selector))29 break30 browser.click_selector(page, selector_2)31 browser.wait_selector(page, 'div.v-list-item__title')32 selectors = browser.find_selectors(page, 'div.v-list-item__title')33 for selector in selectors:34 if browser.text_selector(page, selector) == 'Цена: Ð¡Ð°Ð¼Ð°Ñ Ð½Ð¸Ð·ÐºÐ°Ñ':35 browser.click_selector(page, selector)36 print(browser.text_selector(page, selector))37 break38 while True:39 check = browser.wait_selector(page, 'button.btn-viewmore')40 if check is None:41 break42 selector = browser.find_selector(page, 'button.btn-viewmore')43 if selector is None:44 break45 browser.click_selector(page, selector)46 item_list = browser.find_selectors(page, 'ul.list-item')[-1]47 if len(browser.find_selectors(item_list, 'a.link')) > 20:48 break49 print(len(browser.find_selectors(item_list, 'a.link')))50 browser.wait_selector(page, 'ul.list-item')51 item_list = browser.find_selectors(page, 'ul.list-item')[-1]52 last_items = [browser.href_selector(page, i)53 for i54 in browser.find_selectors(item_list, 'a.link')]55 items = []56 for item in last_items:57 if item not in items:58 items.append(item)59 items = ['https://www.xdraco.com/nft/trade/422626']60 for item in items:61 browser.goto(page, item)62 browser.wait_selector(page, 'div.v-slide-group__content.v-tabs-bar__content')63 main_selector = browser.find_selector(page, 'div.v-slide-group__content.v-tabs-bar__content')64 selector = browser.find_selectors(main_selector, 'div')[-1]65 text = browser.text_selector(page, selector)66 time_start = time.perf_counter()67 while text != 'ÐоÑÑÑпнÑе дÑÑ
и':68 text = browser.text_selector(page, selector)69 main_selector = browser.find_selector(page, 'div.v-slide-group__content.v-tabs-bar__content')70 selector = browser.find_selectors(main_selector, 'div')[-1]71 if time.perf_counter() - time_start > 15:72 break73 browser.click_selector(page, selector)74 """while len(selectors) < 7:75 time.sleep(1)76 selectors = browser.find_selectors(page, '.tab-spirit-item.v-tab')77 print(len(selectors))78 selector = selectors[5]79 browser.click_selector(page, selector)"""80 browser.wait_selector(page, 'div.v-window-item.wrap-item-square')81 selector = browser.find_selector(page, 'div.v-window-item.wrap-item-square')82 # browser.wait_selector(selector, 'img')83 selectors = browser.find_selectors(selector, 'img')84 item_names = [browser.alt_selector(page, i)85 for i86 in selectors]87 if spirits[0] in item_names \88 and spirits[1] in item_names \89 and spirits[2] in item_names \90 and spirits[3] in item_names \91 and spirits[4] in item_names:92 name = browser.find_selector(page, 'h3.item-title')93 name = browser.text_selector(page, name)94 price = browser.find_selector(page, 'strong.ico-wemixcredit.ico-ss.add-inside')95 price = browser.text_selector(page, price)96 lvl = browser.find_selector(page, 'li.level')97 lvl = browser.find_selector(lvl, 'strong')98 lvl = browser.text_selector(page, lvl)99 print('ÐÑÑÑ: %s' % item)100 print(name)101 print(price)102 print(lvl)103 id = create_db.create_id()104 print(id)105 create_db.insert_item(id, item, name, price, lvl)106 else:107 print('ÐеÑ: %s' % item)...
formPage.py
Source: formPage.py
...3 def __init__(self, driver, config): # , config):4 self.driver = driver5 self.config = config6 def verifyElementPage(self):7 title = self.driver.find_element(By.CSS_SELECTOR, find_selector("elementTitle"))8 # self.betterIdea(10, title.text)9 assert title.text == "Elements"10 print("Element page is displayed.")11 def clickOnForm(self):12 self.driver.find_element(By.CSS_SELECTOR, find_selector("textBoxBtn")).click()13 def fillName(self):14 full_name = self.driver.find_element(By.CSS_SELECTOR, find_selector("fullNameInput"))15 full_name.send_keys("Elia")16 def fillEmail(self):17 self.driver.find_element(By.CSS_SELECTOR, find_selector("emailInput")).send_keys("elia@elia.com")18 def fillCurrentAddress(self):19 self.driver.find_element(By.CSS_SELECTOR, find_selector("currentAdressInput")).send_keys("dirección")20 def clickSubmitButton(self):21 if self.config['browser'] == 'Firefox':22 element = return_web_element(self.driver, "submitBtb")23 self.driver.execute_script("arguments[0].scrollIntoView();", element)24 self.driver.find_element(By.CSS_SELECTOR, find_selector("submitBtb")).click()25 def verify(self):26 verify = self.config['verify']27 if verify == 'name':28 self.verifyNameIsDisplayed()29 elif verify == 'email':30 self.verifyEmailIsDisplayed()31 elif verify == 'address':32 self.verifyCurrentAddressIsDisplayed()33 else:34 assert False, "The element to verify is unknown."35 def verifyNameIsDisplayed(self):36 name = self.driver.find_element(By.CSS_SELECTOR, find_selector("nameTxt"))37 if "Elia" not in name.text:38 assert False, "The name is not displayed"39 else:40 print(f'The name {name.text} is displayed')41 def verifyEmailIsDisplayed(self):42 email = self.driver.find_element(By.CSS_SELECTOR, find_selector("emailTxt"))43 assert email.text == "Email:elia@elia.com"44 print(f'The email {email.text} is displayed.')45 def verifyCurrentAddressIsDisplayed(self):46 address = self.driver.find_element(By.CSS_SELECTOR, find_selector("currentAdressTxt"))47 if "dirección" not in address.text:48 assert False, "The current address is not displayed."49 else:50 print(f'The current address {address.text} is displayed.')51"""52 def terribleIdea(self, time):53 time.sleep(time)54 def betterIdea(self, time, text):55 from selenium.webdriver.support.ui import WebDriverWait56 from selenium.webdriver.support import expected_conditions as EC57 WebDriverWait(self.driver, time).until(EC.title_is(text))...
formPage2.py
Source: formPage2.py
2class Form:3 def __init__(self, driver):4 self.driver = driver5 def verifyElementPage(self):6 title = self.driver.find_element(By.CSS_SELECTOR, find_selector("elementTitle"))7 # self.betterIdea(10, title.text)8 assert title.text == "Elements"9 print("Element page is displayed.")10 def clickOnForm(self):11 self.driver.find_element(By.CSS_SELECTOR, find_selector("textBoxBtn")).click()12 def fillName(self):13 full_name = self.driver.find_element(By.CSS_SELECTOR, find_selector("fullNameInput"))14 full_name.send_keys("Elia")15 def fillEmail(self):16 self.driver.find_element(By.CSS_SELECTOR, find_selector("emailInput")).send_keys("elia@elia.com")17 def fillCurrentAddress(self):18 self.driver.find_element(By.CSS_SELECTOR, find_selector("currentAdressInput")).send_keys("dirección")19 def clickSubmitButton(self):20 element = return_web_element(self.driver, "submitBtb")21 self.driver.execute_script("arguments[0].scrollIntoView();", element)22 self.driver.find_element(By.CSS_SELECTOR, find_selector("submitBtb")).click()23 def verify(self, verify):24 if verify == 'name':25 self.verifyNameIsDisplayed()26 elif verify == 'email':27 self.verifyEmailIsDisplayed()28 elif verify == 'address':29 self.verifyCurrentAddressIsDisplayed()30 else:31 assert False, "The element to verify is unknown."32 def verifyNameIsDisplayed(self):33 name = self.driver.find_element(By.CSS_SELECTOR, find_selector("nameTxt"))34 if "Elia" not in name.text:35 assert False, "The name is not displayed"36 else:37 print(f'The name {name.text} is displayed')38 def verifyEmailIsDisplayed(self):39 email = self.driver.find_element(By.CSS_SELECTOR, find_selector("emailTxt"))40 assert email.text == "Email:elia@elia.com"41 print(f'The email {email.text} is displayed.')42 def verifyCurrentAddressIsDisplayed(self):43 address = self.driver.find_element(By.CSS_SELECTOR, find_selector("currentAdressTxt"))44 if "dirección" not in address.text:45 assert False, "The current address is not displayed."46 else:47 print(f'The current address {address.text} is displayed.')48"""49 def terribleIdea(self, time):50 time.sleep(time)51 def betterIdea(self, time, text):52 from selenium.webdriver.support.ui import WebDriverWait53 from selenium.webdriver.support import expected_conditions as EC54 WebDriverWait(self.driver, time).until(EC.title_is(text))...
Check out the latest blogs from LambdaTest on this topic:
As part of one of my consulting efforts, I worked with a mid-sized company that was looking to move toward a more agile manner of developing software. As with any shift in work style, there is some bewilderment and, for some, considerable anxiety. People are being challenged to leave their comfort zones and embrace a continuously changing, dynamic working environment. And, dare I say it, testing may be the most ‘disturbed’ of the software roles in agile development.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Manual cross browser testing is neither efficient nor scalable as it will take ages to test on all permutations & combinations of browsers, operating systems, and their versions. Like every developer, I have also gone through that ‘I can do it all phase’. But if you are stuck validating your code changes over hundreds of browsers and OS combinations then your release window is going to look even shorter than it already is. This is why automated browser testing can be pivotal for modern-day release cycles as it speeds up the entire process of cross browser compatibility.
Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.
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!!