How to use Driver method in chrominator

Best JavaScript code snippet using chrominator

dedupe_unit_test.py

Source:dedupe_unit_test.py Github

copy

Full Screen

...421 return suite422if __name__ == "__main__":423 runner = unittest.TextTestRunner(descriptions=True, failfast=True, verbosity=2)424 ret = not runner.run(suite()).wasSuccessful()425 BaseTestCase.tearDownDriver()...

Full Screen

Full Screen

dialysis_aut.py

Source:dialysis_aut.py Github

copy

Full Screen

1import os2from selenium import webdriver3from time import sleep4from selenium.webdriver import ActionChains5from selenium.webdriver.chrome.options import Options6from selenium.webdriver.support.ui import Select7from selenium.webdriver.support import expected_conditions as EC8from selenium.webdriver.common.by import By9from selenium.webdriver.support import expected_conditions10from selenium.webdriver.support.wait import WebDriverWait11from selenium.webdriver.common.keys import Keys12from selenium.common.exceptions import NoSuchElementException13from webdriver_manager.chrome import ChromeDriverManager14import urllib15import urllib.request16# functions17def check_exists_by_xpath(xpath):18 try:19 driver.find_element_by_xpath(xpath)20 except NoSuchElementException:21 return False22 return True23def check_exists_by_id(id):24 try:25 driver.find_element_by_id(id)26 except NoSuchElementException:27 return False28 return True29options = webdriver.ChromeOptions()30options.add_argument('--disable-notifications')31driver = webdriver.Chrome(ChromeDriverManager().install(),options=options)32driver.maximize_window()33driver.implicitly_wait(10)34w = WebDriverWait(driver,8)35# user = input('enter email or phone no')36# pswd = input('enter password')37driver.get('https://pmjaylive.sevensigma.in/home')38user_name = driver.find_element_by_name('User Name')39user_name.send_keys(8590050640)40password = driver.find_element_by_name('Password')41password.send_keys(50640)42driver.find_element_by_xpath('/html/body/div/div[2]/div/div/div[1]/div/div/form/div/div[3]/button').click()43sleep(3)44view_list = driver.find_element_by_xpath('//*[@id="out-table"]/div/div/div[4]/div/div[4]/div[2]/table/tbody/tr/td[5]/div/button[1]')45view_list.click()46sleep(3)47preauth = driver.find_element_by_xpath('/html/body/div/div[2]/div[2]/div/div/div[2]/div[2]/a/div/div[1]/div/div[2]/div/p[1]').click()48sleep(3)49driver.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div/div/div[1]/div/div[1]/div/div[2]/div/div/div[6]/div/div/div/div/div/div/input').send_keys('DIALYSIS')50sleep(10)51dialysis = driver.find_element_by_xpath('/html/body/div[2]/div[1]/div[1]/ul/li[1]/span')52dialysis.click()53sleep(3)54number_of_rows= len(driver.find_elements_by_xpath('//*[@id="out-table"]/div[1]/div/div[4]/div'))55print(number_of_rows)56id_list=[]# list creation57for i in range(1,number_of_rows+1):58 u=driver.find_elements_by_xpath("//*[@id='out-table']/div[1]/div/div[4]/div/div[3]/table/tbody/tr[' + str(i) + ']/td[3]")[0].text59 print(u)60 id_list.append(u)61 sleep(1)62 # reg_no = driver.find_element_by_xpath(63 # '/html/body/div[1]/div[2]/div[2]/div/div/div[1]/div/div[1]/div/div[4]/div/div[3]/table/tbody/tr[1]/td[3]/div')64 # reg = reg_no.get_attribute('innerHTML')65 ip_number = driver.find_element_by_xpath(66 '/html/body/div[1]/div[2]/div[2]/div/div/div[1]/div/div[1]/div/div[4]/div/div[3]/table/tbody/tr[1]/td[7]/div')67 ip_num = ip_number.get_attribute('innerHTML')68 print("ip_num", ip_num)69 view_profile = driver.find_element_by_xpath(70 '//*[@id="out-table"]/div[1]/div/div[4]/div/div[4]/div[2]/table/tbody/tr[1]/td[10]/div/button[2]/i')71 view_profile.click()72 treat_date = driver.find_element_by_xpath(73 '/html/body/div/div[2]/div[2]/div/div/div[1]/div/div[1]/div/div[4]/div/div[3]/table/tbody/tr/td[9]/div')74 treatment_d = treat_date.get_attribute('innerHTML')75 print("treatment_d", treatment_d)76 card_id = driver.find_element_by_xpath(77 '//*[@id="out-table"]/div[1]/div/div[4]/div/div[3]/table/tbody/tr[1]/td[4]/div')78 card = card_id.get_attribute('innerHTML')79 print(card)80 patient_name = driver.find_element_by_xpath('//*[@id="out-table"]/div[1]/div/div[4]/div/div[3]/table/tbody/tr[1]/td[5]/div')81 p_name = patient_name.get_attribute('innerHTML')82 print(p_name)83 # dep = driver.find_element_by_xpath('')84 # treat_photo = dep.get_attribute('innerHTML')85 pulse_rate = driver.find_element_by_xpath(86 '/html/body/div[1]/div[2]/div[2]/div/div/div[2]/div[1]/div/div[2]/div/div/div[3]/p[2]')87 pulse = pulse_rate.get_attribute('innerHTML')88 print(pulse)89 x = pulse[:3]90 print(x)91 y = pulse[4:6]92 print(y)93 # p_p = driver.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div/div/div[2]/div[1]/div/div[6]/div/div/div/div[2]/div/div/div/div[1]/div/div/div/img')94 # action = ActionChains(driver)95 # action.context_click(p_p).key_down (Keys.SHIFT).perform()96 p_chart1 = driver.find_element_by_xpath(97 '/html/body/div[1]/div[2]/div[2]/div/div/div[2]/div[1]/div/div[6]/div/div/div/div[2]/div/div/div/div[1]/div/div/div/img')98 src1 = p_chart1.get_attribute('src')99 print(src1)100 p_chart2 = driver.find_element_by_xpath(101 '/html/body/div[1]/div[2]/div[2]/div/div/div[2]/div[1]/div/div[6]/div/div/div/div[3]/div/div/div/div[1]/div/div/div/img')102 src2 = p_chart2.get_attribute('src')103 print(src2)104 p_patient = driver.find_element_by_xpath(105 '/html/body/div[1]/div[2]/div[2]/div/div/div[2]/div[1]/div/div[6]/div/div/div/div[4]/div/div/div/div[1]/div/div/div/img')106 src3 = p_patient.get_attribute('src')107 print(src3)108 def dl_img(url, file_path, file_name):109 filename = file_name+".jpeg"110 fullfilename = os.path.join(file_path, filename)111 # urllib.urlretrieve(url, fullfilename)112 urllib.request.urlretrieve(url, fullfilename)113 url = src1114 file_name = card115 dl_img(url, r'C:\Users\PC\Desktop\auto', file_name)116 # def dl_img(url, file_path, file_name):117 # full_path = file_path + file_name + '.jpg'118 # urllib.request.urlretrieve(url, full_path)119 url = src2120 file_name = p_name121 dl_img(url, r'C:\Users\PC\Desktop\certificate', file_name)122 sleep(2)123 url = src3124 file_name = ip_num125 dl_img(url, r'C:\Users\PC\Desktop\chart', file_name)126 sleep(3)127driver.get('http://tms.pmjay.gov.in/')128sleep(5)129def login_tms():130 username = driver.find_element_by_xpath('//*[@id="username"]')131 username.send_keys('KER002197')132 pas = driver.find_element_by_xpath('//*[@id="password"]')133 pas.send_keys('Automate@1')134 # driver.find_element_by_xpath('//*[@id="select2-userState-container"]').click()135 driver.find_element_by_xpath('//*[@id="select2-userState-container"]').click()136 driver.find_element_by_xpath('/html/body/span/span/span[1]/input').send_keys('KERALA')137 sleep(1)138 driver.find_element_by_xpath('/html/body/span/span/span[2]/ul/li').click()139 # captcha = input("enter captcha here")140 captcha_text = driver.find_element_by_xpath('//*[@id="reqCaptcha"]')141 captcha_text.click()142 sleep(15)143 captcha_text.send_keys(Keys.ENTER)144 driver.find_element_by_id('checkSubmit').click()145 login = driver.find_element_by_xpath('//*[@id="login-submit"]')146 login.click()147 sleep(2)148login_tms()149# to click on close session if it shows up150if (check_exists_by_xpath('/html/body/div[10]/div/div/div[3]/button[2]')):151 driver.find_element_by_xpath('/html/body/div[10]/div/div/div[3]/button[2]').click()152 sleep(2)153 driver.find_element_by_xpath('/html/body/div[10]/div/div/div[2]/button').click()154 sleep(2)155 login_tms()156close = driver.find_element_by_xpath('//*[@id="notificationModal"]/div/div/div[1]/button')157close.click()158sleep(5)159preauth = driver.find_element_by_link_text('Preauth')160preauth.click()161sleep(2)162preauth_ins = driver.find_element_by_xpath('//*[@id="childmenu3"]/li[1]/a/span[1]')163actions = ActionChains(driver)164actions.move_to_element(preauth_ins).click().perform()165sleep(2)166driver.switch_to.frame(0)167regg_no = driver.find_element_by_name('patientNo')168regg_no.send_keys(id_list)169search = driver.find_element_by_xpath('//*[@id="registeredCases"]/div/div[4]/button[1]')170search.click()171regno =driver.find_element_by_xpath('//*[@id="no-more-tables"]/table/tbody/tr/td[2]').click()172sleep(3)173driver.switch_to.default_content()174driver.switch_to.frame(driver.find_element_by_id("middleFrame"))175sleep(2)176try:177 ip = driver.find_element_by_id('patientTypeIP')178 ip.click()179 Ipop = driver.find_element_by_id('submitIpOp')180 Ipop.click()181 sleep(3)182 ok = driver.find_element_by_xpath('/html/body/div[26]/div/div/div[2]/button[2]')183 ok.click()184 sleep(5)185 print('try')186except:187 sleep(5)188 # driver.find_element_by_xpath('html/body/div[2]/div[1]/div[1]/div/div[2]/div[1]/div[1]/div/span/span[1]/span/span[1]').click()189print('true')190try:191 driver.find_element_by_xpath(192 '/html/body/div[2]/div[1]/div[1]/div/div[2]/div[1]/div[1]/div/span/span[1]/span/span[1]').click()193 print('except')194 driver.find_element_by_xpath('/html/body/span/span/span[2]/ul/li[2]').click()195 sleep(2)196 sleep(2)197 d_description = driver.find_element_by_xpath('//*[@id="diagDesc"]')198 d_description.send_keys('CKD')199 procedure = driver.find_element_by_xpath(200 '/html/body/div[2]/div[1]/div[2]/div/div[3]/div/div[1]/div[1]/div[2]/span/span[1]/span/span[2]')201 procedure.click()202 sleep(2)203 driver.find_element_by_xpath('/html/body/span/span/span[1]/input').send_keys('MG072A')204 sleep(1)205 sel_procedure = driver.find_element_by_xpath('/html/body/span/span/span[2]/ul/li')206 sel_procedure.click()207 sleep(2)208 speciality = driver.find_element_by_xpath(209 '/html/body/div[2]/div[1]/div[2]/div/div[3]/div/div[1]/div[1]/div[1]/span/span[1]/span/span[2]')210 speciality.click()211 sleep(2)212 driver.find_element_by_xpath('/html/body/span/span/span[2]/ul/li[2]').click()213 doctor = driver.find_element_by_xpath(214 '/html/body/div[2]/div[1]/div[2]/div/div[3]/div/div[1]/div[1]/div[5]/span/span[1]/span/span[2]')215 doctor.click()216 driver.find_element_by_xpath('/html/body/span/span/span[1]/input').send_keys(5697)217 sel_doc = driver.find_element_by_xpath('/html/body/span/span/span[2]/ul/li').click()218 sleep(5)219 add_pro = driver.find_element_by_id('addSpeciality')220 add_pro.click()221 sleep(2)222 ok = w.until(223 expected_conditions.presence_of_element_located((By.XPATH, '/html/body/div[26]/div/div/div[2]/button')))224 ok.click()225 sleep(2)226except:227 pass228close_b = w.until(229 expected_conditions.presence_of_element_located((By.XPATH, '//*[@id="notify"]/div/div/div[3]/button')))230close_b.click()231sleep(3)232seq = driver.find_elements_by_tag_name('iframe')233for num, frame in enumerate(seq):234 print(num, frame.get_attribute("id"))235print("No of frames present in the web page are: ", len(seq))236driver.switch_to.default_content()237sleep(5)238driver.switch_to.frame(driver.find_element_by_id('middleFrame'))239sleep(5)240try:241 driver.find_element_by_xpath('/html/body/div[26]/div/div/div[2]/button').click()242except:243 pass244driver.switch_to.default_content()245sleep(1)246driver.switch_to.frame(driver.find_element_by_id('middleFrame'))247sleep(2)248# driver.switch_to.frame(driver.find_element_by_id('iframe1'))249if check_exists_by_id("iframe1") and check_exists_by_id("iframe2"):250 # driver.switch_to.frame(driver.find_element_by_id('iframe1'))251 # upload_p = driver.find_element_by_id('invattachButton')252 # upload_p.send_keys(r'C:\Users\PC\Desktop\certificate\MUHAMMED ASHRAF .jpeg')253 driver.switch_to.frame(driver.find_element_by_id('iframe1'))254 upload = driver.find_element_by_xpath('//*[@id="invAttach"]')255 file_path = r'C:\Users\PC\Desktop\chart'256 filename = ip_num + ".jpeg"257 fullfilename = os.path.join(file_path, filename)258 upload.send_keys(fullfilename)259 driver.switch_to.parent_frame()260 driver.switch_to.frame(driver.find_element_by_id('iframe2'))261 upload_p = driver.find_element_by_xpath('//*[@id="invAttach"]')262 file_path = r'C:\Users\PC\Desktop\certificate'263 filename = p_name + ".jpeg"264 fullfilename = os.path.join(file_path, filename)265 upload_p.send_keys(fullfilename)266elif check_exists_by_id("iframe0") and check_exists_by_id("iframe1"):267 driver.switch_to.frame(driver.find_element_by_id('iframe0'))268 upload = driver.find_element_by_xpath('//*[@id="invAttach"]')269 file_path = r'C:\Users\PC\Desktop\chart'270 filename = ip_num + ".jpeg"271 fullfilename = os.path.join(file_path, filename)272 upload.send_keys(fullfilename)273 driver.switch_to.parent_frame()274 driver.switch_to.frame(driver.find_element_by_id('iframe1'))275 upload_p = driver.find_element_by_xpath('//*[@id="invAttach"]')276 file_path = r'C:\Users\PC\Desktop\certificate'277 filename = p_name + ".jpeg"278 fullfilename = os.path.join(file_path, filename)279 upload_p.send_keys(fullfilename)280 # # upload on iframe0 and then iframe1281 # print("uploaded")282else:283 print("something went wrong")284 exit()285driver.switch_to.default_content()286driver.switch_to.frame(driver.find_element_by_id("middleFrame"))287ip_no = driver.find_element_by_xpath('/html/body/div[2]/div[2]/div/div[2]/div[2]/div[1]/input')288ip_no.send_keys(ip_num)289admission_type = driver.find_element_by_xpath('/html/body/div[2]/div[2]/div/div[2]/div[2]/div[2]/select')290drop = Select(admission_type)291drop.select_by_visible_text('Planned')292sleep(2)293diagnosed_by = driver.find_element_by_xpath('/html/body/div[2]/div[2]/div/div[2]/div[2]/div[4]/select')294drop = Select(diagnosed_by)295drop.select_by_visible_text('Others')296doctor_name = driver.find_element_by_xpath('/html/body/div[2]/div[2]/div/div[2]/div[3]/div[2]/div[1]/input')297doctor_name.send_keys('DR PRADEEP K J')298alldate = driver.find_element_by_xpath('/html/body/div[2]/div[2]/div/div[2]/div[3]/div[3]/input')299print(treatment_d)300print(alldate)301alldate.send_keys(treatment_d)302sleep(2)303procedure_con = driver.find_element_by_xpath('//*[@id="procedureConsent"]')304procedure_con.click()305MLC = driver.find_element_by_xpath('/html/body/div[2]/div[2]/div/div[2]/div[4]/div[1]/input[2]')306MLC.click()307sleep(5)308general_find = driver.find_element_by_xpath('/html/body/div[1]/div[3]/form/div/div[8]/button[1]')309top = driver.find_element_by_xpath('/html/body/div[1]/div[3]/form/div/div[1]')310driver.execute_script("return arguments[0].scrollIntoView(true);",top)311sleep(10)312general_find.click()313sleep(20)314temperature = driver.find_element_by_xpath('/html/body/div[8]/div/div/div[2]/form/div[2]/div/div/div[2]/div[1]/div[11]/div[1]/input')315sleep(2)316temperature.click()317sleep(2)318f = driver.find_element_by_xpath('/html/body/div[8]/div/div/div[2]/form/div[2]/div/div/div[2]/div[1]/div[11]/div[2]/input[2]')319f.click()320sleep(5)321tmp = driver.find_element_by_name('GE11')322tmp.send_keys(str(98.6))323#sleep(3)324pulse = driver.find_element_by_xpath('/html/body/div[8]/div/div/div[2]/form/div[2]/div/div/div[2]/div[1]/div[12]/div[1]/input')325pulse.click()326#sleep(2)327pulse_r = driver.find_element_by_xpath('/html/body/div[8]/div/div/div[2]/form/div[2]/div/div/div[2]/div[1]/div[12]/div[2]/input')328pulse_r.send_keys(78)329sleep(1)330driver.find_element_by_xpath('/html/body/div[8]/div/div/div[2]/form/div[2]/div/div/div[2]/div[1]/div[14]/div[1]/input').click()331bp = driver.find_element_by_name('GE14')332bp.send_keys(x)333sleep(2)334bp_h = driver.find_element_by_name('BP1')335bp_h.send_keys(y)336sleep(5)337w.until(338 expected_conditions.presence_of_element_located((By.XPATH, '/html/body/div[8]/div/div/div[2]/form/div[2]/div/div/div[2]/div[2]/button'))).click()339sleep(5)340save_ok = w.until(341 expected_conditions.presence_of_element_located((By.XPATH, '/html/body/div[27]/div/div/div[2]/button')))342save_ok.click()343sleep(2)344close_save = driver.find_element_by_xpath('/html/body/div[8]/div/div/div[3]/button')345close_save.click()346sleep(2)347sleep(5)348pf_history = driver.find_element_by_xpath('/html/body/div[1]/div[3]/form/div/div[8]/button[3]')349topp = driver.find_element_by_xpath('/html/body/div[1]/div[3]/form/div')350driver.execute_script("return arguments[0].scrollIntoView(true);",topp)351sleep(10)352pf_history.click()353sleep(20)354not_applicable = driver.find_element_by_xpath('/html/body/div[8]/div/div/div[2]/form/div[1]/div[1]/div/div[2]/div[12]/div[1]/input')355not_applicable.click()356save_history = driver.find_element_by_xpath('/html/body/div[8]/div/div/div[2]/form/div[2]/button')357save_history.click()358sleep(3)359ok_history = driver.find_element_by_xpath('/html/body/div[27]/div/div/div[2]/button')360ok_history.click()361sleep(2)362close_history = driver.find_element_by_xpath('/html/body/div[8]/div/div/div[1]/button')363close_history.click()364sleep(3)365action_typ = driver.find_element_by_id('actionType')366drop = Select(action_typ)367drop.select_by_visible_text('Initiate Pre-auth')368sleep(2)369add_view = driver.find_element_by_id('btnattach')370add_view.click()371driver.switch_to.default_content()372sleep(1)373driver.switch_to.frame('middleFrame')374sleep(2)375driver.switch_to.frame(driver.find_element_by_id('modalattDivIframe'))376p_photo = driver.find_element_by_xpath('//*[@id="BPM1"]')377file_path = r'C:\Users\PC\Desktop\auto'378filename = card + ".jpeg"379full_filename = os.path.join(file_path, filename)380p_photo.send_keys(full_filename)381p_ok = driver.find_element_by_xpath('/html/body/div[1]/div/div/div[2]/button')382p_ok.click()383driver.switch_to.default_content()384driver.switch_to.frame(driver.find_element_by_id('middleFrame'))385p_close = driver.find_element_by_xpath('//*[@id="modalattachDiv"]/div/div/div[3]/button')386p_close.click()387# submit = driver.find_element_by_xpath('//*[@id="btnSubmit"]')388# submit.click()389# sleep(2)390# QA_button = driver.find_element_by_xpath('/html/body/div[26]/div/div/div[2]/button[2]')391# QA_button.click()392# sleep(2)393# Q1 = driver.find_element_by_xpath('//*[@id="triggerDetails"]/div/table/tbody/tr[1]/td[3]/label[1]/span[2]')394# Q1.click()395# Q2 = driver.find_element_by_xpath('//*[@id="triggerDetails"]/div/table/tbody/tr[2]/td[3]/label[1]/span[2]')396# Q2.click()397# Q3 = driver.find_element_by_xpath('//*[@id="triggerDetails"]/div/table/tbody/tr[3]/td[3]/label[1]/span[2]')398# Q3.click()399# Q4 = driver.find_element_by_xpath('//*[@id="triggerDetails"]/div/table/tbody/tr[4]/td[3]/label[1]/span[2]')400# Q4.click()401# Q5 = driver.find_element_by_xpath('//*[@id="triggerDetails"]/div/table/tbody/tr[5]/td[3]/label[1]/span[2]')402# Q5.click()403# sleep(3)404# Q_ok = driver.find_element_by_xpath('/html/body/div[4]/div/div/div[2]/button')405# Q_ok.click()406# Q_close = driver.find_element_by_xpath('//*[@id="questionaireModal"]/div/div/div[1]/button')407# Q_close.click()408# sleep(2)409# intiate = driver.find_element_by_xpath('/html/body/div[26]/div/div/div[2]/button[2]')410# intiate.click()411# sleep(5)412# case_id = driver.find_element_by_xpath('/html/body/form[1]/center[1]/font/div/div/div[2]/div/strong/b[2]')413# id_value = case_id.get_attribute('innerHTML')414# sleep(2)415# sub_id = driver.find_element_by_xpath('//*[@id="generateCasePrintPage"]')416# sub_id.click()417# sleep(10)418# case_sd = driver.find_element_by_xpath('//*[@id="childmenu3"]/li[2]/a/span[1]')419# case_sd.click()420# sleep(2)421# case_no = driver.find_element_by_name('caseNo')422# case_no.send_keys(id_value)423# search_no = driver.find_element_by_xpath('//*[@id="preauthForApproval"]/div[3]/button[1]')424# search_no.click()425# sleep(3)426# caseno = driver.find_element_by_xpath('//*[@id="no-more-tables"]/table/tbody/tr/td[2]/b/u/a')427# caseno.click()428# close_n = driver.find_element_by_xpath('//*[@id="notify"]/div/div/div[3]/button')429# close_n.click()430#431# # authonticate432#433# covid_case = driver.find_element_by_xpath('//*[@id="covidNo"]')434# covid_case.click()435# sleep(1)436# t_dr = driver.find_element_by_xpath('//*[@id="collapseTrtDr"]/div[1]/span/span[1]/span/span[2]')437# t_dr.click()438# driver.find_element_by_xpath('/html/body/span/span/span[1]/input').send_keys('Specialist')439# specialist = driver.find_element_by_xpath('//*[@id="select2-docType-result-ib3j-D"]')...

Full Screen

Full Screen

dfp.py

Source:dfp.py Github

copy

Full Screen

1from selenium import webdriver 2import unittest3from selenium.webdriver.common.by import By4from selenium.webdriver.support.ui import WebDriverWait as W5from selenium.webdriver.support import expected_conditions as E6from webdriver_manager.chrome import ChromeDriverManager7from selenium.webdriver.chrome.options import Options8import time9chrome_options = Options()10chrome_options.headless = True11chrome_options.add_argument("--headless") 12#driver = webdriver.Chrome(options=chrome_options) 13driver = webdriver.Chrome(ChromeDriverManager().install(),options=chrome_options)14class dfp(unittest.TestCase): 15 16 def test_dfpnews(self):17 18 self.driver = driver19 driver.maximize_window()20 driver.get("https:www.collegedekho.com/news?magicflag=1")21 print("----------------------------------------------News Listing---------------------------------")22 print("current url = " + driver.current_url)23 print("current title = " + driver.title)24 frames = driver.find_elements_by_tag_name("iframe")25 print("There are ", len(frames),"frames on this webpage") 26 for f in frames:27 print("frame ID:", f.get_attribute('id'), "frame Name:", f.get_attribute('name'), "frame width:", f.get_attribute('width'),28 "frame height:", f.get_attribute('height'))29 30 elm = driver.find_element_by_id("google_ads_iframe_/99910373/CLD_College_NEWS_Home_Page_Header_LeaderBoard_0")31 elm.click()32 time.sleep(5)33 childwindow = driver.window_handles[1]34 driver.switch_to_window(childwindow)35 print("current url =" + driver.current_url)36 print("current title = " + driver.title)37 parentwindow = driver.window_handles[0]38 driver.switch_to_window(parentwindow)39 driver.quit()40 41 def test_dfpstream(self):42 self.driver = driver43 driver.maximize_window()44 driver.get("https://www.collegedekho.com/engineering-stream/?magicflag=1")45 print("----------------------------------------------Stream ---------------------------------")46 print("current url = " + driver.current_url)47 print("current title = " + driver.title)48 frames = driver.find_elements_by_tag_name("iframe")49 print("There are ", len(frames),"frames on this webpage") 50 for f in frames:51 print("frame ID:", f.get_attribute('id'), "frame Name:", f.get_attribute('name'), "frame width:", f.get_attribute('width'),52 "frame height:", f.get_attribute('height'))53 54 elm = driver.find_element_by_id("google_ads_iframe_/99910373/CLD_Stream_Template_Leaderboard_0")55 elm.click()56 time.sleep(5)57 childwindow = driver.window_handles[1]58 driver.switch_to_window(childwindow)59 print("current url =" + driver.current_url)60 print("current title = " + driver.title)61 parentwindow = driver.window_handles[0]62 driver.switch_to_window(parentwindow)63 driver.quit()64 def test_dfpcourses(self):65 self.driver = driver66 driver.maximize_window()67 print("----------------------------------------------Course Listing---------------------------------")68 driver.get("https://www.collegedekho.com/courses/?magicflag=1")69 print("current url = " + driver.current_url)70 print("current title = " + driver.title)71 frames = driver.find_elements_by_tag_name("iframe")72 print("There are ", len(frames),"frames on this webpage") 73 for f in frames:74 print("frame ID:", f.get_attribute('id'), "frame Name:", f.get_attribute('name'), "frame width:", f.get_attribute('width'),75 "frame height:", f.get_attribute('height'))76 77 elm = driver.find_element_by_id("google_ads_iframe_/99910373/CLD_Course_Listing_Leaderboard_0")78 elm.click()79 time.sleep(5)80 childwindow = driver.window_handles[1]81 driver.switch_to_window(childwindow)82 print("current url =" + driver.current_url)83 print("current title = " + driver.title)84 parentwindow = driver.window_handles[0]85 driver.switch_to_window(parentwindow)86 driver.quit()87 def test_dfpcoursesdetail(self):88 self.driver = driver89 driver.maximize_window()90 print("--------------------------------Course Detail------------------------------------------")91 time.sleep(2)92 driver.get("https://www.collegedekho.com/courses/btech/?magicflag=1")93 print("current url = " + driver.current_url)94 print("current title = " + driver.title)95 frames = driver.find_elements_by_tag_name("iframe")96 print("There are ", len(frames),"frames on this webpage") 97 for f in frames:98 print("frame ID:", f.get_attribute('id'), "frame Name:", f.get_attribute('name'), "frame width:", f.get_attribute('width'),99 "frame height:", f.get_attribute('height'))100 101 elm = driver.find_element_by_id("google_ads_iframe_/99910373/CLD_Course_Detail_Leaderboard_0")102 elm.click()103 time.sleep(5)104 childwindow = driver.window_handles[1]105 driver.switch_to_window(childwindow)106 print("current url =" + driver.current_url)107 print("current title = " + driver.title)108 parentwindow = driver.window_handles[0]109 driver.switch_to_window(parentwindow)110 driver.quit()111 def test_dfpexamlisting(self):112 self.driver = driver113 driver.maximize_window()114 print("----------------------------------------------Exam Listing---------------------------------")115 driver.get("https://www.collegedekho.com/test-preparation/?magicflag=1")116 print("current url = " + driver.current_url)117 print("current title = " + driver.title)118 frames = driver.find_elements_by_tag_name("iframe")119 print("There are ", len(frames),"frames on this webpage") 120 for f in frames:121 print("frame ID:", f.get_attribute('id'), "frame Name:", f.get_attribute('name'), "frame width:", f.get_attribute('width'),122 "frame height:", f.get_attribute('height'))123 124 elm = driver.find_element_by_id("google_ads_iframe_/99910373/CLD_Home_Exam_Listing_Leaderboard_0")125 elm.click()126 time.sleep(5)127 childwindow = driver.window_handles[1]128 driver.switch_to_window(childwindow)129 print("current url =" + driver.current_url)130 print("current title = " + driver.title)131 parentwindow = driver.window_handles[0]132 driver.switch_to_window(parentwindow)133 driver.quit()134 def test_dfpQnalisting(self):135 self.driver = driver136 driver.maximize_window()137 print("----------------------------------------------Qna Listing---------------------------------")138 driver.get("https://www.collegedekho.com/qna/?magicflag=1")139 print("current url = " + driver.current_url)140 print("current title = " + driver.title)141 frames = driver.find_elements_by_tag_name("iframe")142 print("There are ", len(frames),"frames on this webpage") 143 for f in frames:144 print("frame ID:", f.get_attribute('id'), "frame Name:", f.get_attribute('name'), "frame width:", f.get_attribute('width'),145 "frame height:", f.get_attribute('height'))146 elm = driver.find_element_by_id("google_ads_iframe_/99910373/CLD_College_QNA_Header_LeaderBoard_0")147 elm.click()148 time.sleep(5)149 childwindow = driver.window_handles[1]150 driver.switch_to_window(childwindow)151 print("current url =" + driver.current_url)152 print("current title = " + driver.title)153 parentwindow = driver.window_handles[0]154 driver.switch_to_window(parentwindow)155 driver.quit()156 def test_dfpQnadetail(self):157 self.driver = driver158 driver.maximize_window()159 print("----------------------------------------------Qna Detail---------------------------------")160 driver.get("https://www.collegedekho.com/qna/i-want-to-know-about-the-eligibility-requirements-for-pursuing-btech-at-alliance-university")161 print("current url = " + driver.current_url)162 print("current title = " + driver.title)163 frames = driver.find_elements_by_tag_name("iframe")164 print("There are ", len(frames),"frames on this webpage") 165 for f in frames:166 print("frame ID:", f.get_attribute('id'), "frame Name:", f.get_attribute('name'), "frame width:", f.get_attribute('width'),167 "frame height:", f.get_attribute('height'))168 elm = driver.find_element_by_id("google_ads_iframe_/99910373/CLD_College_QNA_Detail_Header_LeaderBoard_0")169 elm.click()170 time.sleep(5)171 childwindow = driver.window_handles[1]172 driver.switch_to_window(childwindow)173 print("current url =" + driver.current_url)174 print("current title = " + driver.title)175 parentwindow = driver.window_handles[0]176 driver.switch_to_window(parentwindow)177 def test_dfpcollegelisting(self):178 self.driver = driver179 driver.maximize_window()180 print("----------------------------------------------College Lising---------------------------------")181 driver.get("https://www.collegedekho.com/colleges-in-india/?magicflag=1")182 print("current url = " + driver.current_url)183 print("current title = " + driver.title)184 frames = driver.find_elements_by_tag_name("iframe")185 print("There are ", len(frames),"frames on this webpage") 186 for f in frames:187 print("frame ID:", f.get_attribute('id'), "frame Name:", f.get_attribute('name'), "frame width:", f.get_attribute('width'),188 "frame height:", f.get_attribute('height'))189 elm = driver.find_element_by_id("google_ads_iframe_/99910373/CLD_College_List_Page_Body1_LeaderBoard_0")190 elm.click()191 time.sleep(5)192 childwindow = driver.window_handles[1]193 driver.switch_to_window(childwindow)194 print("current url =" + driver.current_url)195 print("current title = " + driver.title)196 parentwindow = driver.window_handles[0]197 driver.switch_to_window(parentwindow)198 driver.quit()199 def test_dfpcollegedetail(self):200 self.driver = driver201 driver.maximize_window()202 print("----------------------------------------------College Detail---------------------------------")203 driver.get("https://www.collegedekho.com/colleges/iima?magicflag=1")204 print("current url = " + driver.current_url)205 print("current title = " + driver.title)206 frames = driver.find_elements_by_tag_name("iframe")207 print("There are ", len(frames),"frames on this webpage") 208 for f in frames:209 print("frame ID:", f.get_attribute('id'), "frame Name:", f.get_attribute('name'), "frame width:", f.get_attribute('width'),210 "frame height:", f.get_attribute('height'))211 elm = driver.find_element_by_id("google_ads_iframe_/99910373/CLD_College_Detail_Overview_Page_Header_Leaderboard_0__container__")212 elm.click()213 time.sleep(5)214 childwindow = driver.window_handles[1]215 driver.switch_to_window(childwindow)216 print("current url =" + driver.current_url)217 print("current title = " + driver.title)218 parentwindow = driver.window_handles[0]219 driver.switch_to_window(parentwindow)220 driver.quit()221 def tearDown(self):222 self.driver.quit()223if __name__ == '__main__':...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

1import time2import random3import names4from selenium import webdriver5from selenium.webdriver.common.by import By6from selenium.webdriver.support.ui import WebDriverWait7from selenium.webdriver.support import expected_conditions as EC8from selenium.webdriver.common.keys import Keys9PATH = "C:\Program Files (x86)\chromedriver.exe"10URL = "https://localhost:8091"11PRODUCTS_NUM = 212FIRST_CATEGORY_PRODUCTS_NUM = 113FIRST_CATEGORY = '/index.php?id_category=17&controller=category'14SECOND_CATEGORY = '/index.php?id_category=24&controller=category'15#FIRST_CATEGORY = '/index.php?id_category=7&controller=category'16#SECOND_CATEGORY = '/index.php?id_category=15&controller=category'17class Test:18 def __init__(self, driver, url, products_num, first_category_products_num, first_category, second_category):19 self.driver = driver20 self.url = url21 self.products_num = products_num22 self.first_category_products_num = first_category_products_num23 self.second_category_products_num = products_num - first_category_products_num24 self.first_category_url = url + '/' + first_category25 self.second_category_url = url + '/' + second_category26 def test(self):27 self.fill_cart(self.first_category_products_num, self.first_category_url)28 self.fill_cart(self.second_category_products_num, self.second_category_url)29 selected_product_index = random.randint(0,self.products_num - 1)30 self.remove_product(selected_product_index)31 self.create_account()32 self.fill_order_form()33 def fill_cart(self, products_num, category_url):34 added_products = 035 current_page_number = 136 while(added_products<products_num):37 self.driver.get(category_url + '?page=' + str(current_page_number))38 try:39 products_on_page = len(WebDriverWait(driver, 10).until(40 EC.presence_of_all_elements_located((By.CLASS_NAME, 'product'))41 ))42 except Exception:43 print('Not enough products for this category: ' + category_url)44 return45 for product_index in range(products_on_page):46 if (added_products >= products_num):47 break48 products = WebDriverWait(driver, 10).until(49 EC.presence_of_all_elements_located((By.CLASS_NAME, 'product'))50 )51 products[product_index].click()52 added_products += self.add_one_product()53 self.driver.get(category_url + '?page=' + str(current_page_number))54 current_page_number += 155 def add_one_product(self):56 NOT_ADDED = 057 ADDED = 158 try:59 product_quantities = WebDriverWait(driver, 10).until(60 EC.presence_of_element_located((By.CSS_SELECTOR, '.product-quantities > span'))61 )62 except Exception:63 return NOT_ADDED64 quantity = product_quantities.get_attribute('data-stock')65 if int(quantity) == 0:66 return NOT_ADDED67 selected_quantity = random.randint(1,int(quantity))68 driver.find_element_by_id('quantity_wanted').clear()69 driver.find_element_by_id('quantity_wanted').send_keys(Keys.BACK_SPACE)70 driver.find_element_by_id('quantity_wanted').send_keys(selected_quantity)71 driver.find_element_by_css_selector('.add > button').click()72 btn = WebDriverWait(driver, 10).until(73 EC.element_to_be_clickable((By.CSS_SELECTOR,'.cart-content-btn > button'))74 )75 btn.click()76 return ADDED77 def remove_product(self, selected_product_index):78 cart_link = WebDriverWait(driver, 10).until(79 EC.presence_of_element_located((By.CSS_SELECTOR, '.header > a'))80 )81 cart_link.click()82 remove_links = WebDriverWait(driver, 10).until(83 EC.presence_of_all_elements_located((By.CSS_SELECTOR, 'a.remove-from-cart'))84 )85 remove_links[selected_product_index].click()86 cart_itmes = WebDriverWait(driver, 10).until(87 EC.presence_of_all_elements_located((By.CSS_SELECTOR, '.cart-item'))88 )89 def create_account(self):90 FIRST_NAME = 'Luke'91 LAST_NAME = 'Skywalker'92 EMAIL = names.get_last_name()+'luukeskywalker2@gmail.com'93 PASSWORD = 'LeiaOrgana123321'94 MALE = 095 self.driver.get(self.url)96 sign_in_link = WebDriverWait(driver, 10).until(97 EC.presence_of_element_located((By.CSS_SELECTOR, '.user-info > a'))98 )99 sign_in_link.click()100 create_account_link = WebDriverWait(driver, 10).until(101 EC.presence_of_element_located((By.CSS_SELECTOR, '.no-account > a'))102 )103 create_account_link.click()104 WebDriverWait(driver, 10).until(105 EC.presence_of_element_located((By.CSS_SELECTOR, '#customer-form'))106 )107 gender_radio_btn = self.driver.find_elements_by_css_selector('label.radio-inline')108 gender_radio_btn[MALE].click()109 name_field = self.driver.find_element_by_css_selector('#field-firstname')110 name_field.send_keys(FIRST_NAME)111 last_name_field = self.driver.find_element_by_css_selector('#field-lastname')112 last_name_field.send_keys(LAST_NAME)113 email_field = self.driver.find_element_by_css_selector('#field-email')114 email_field.send_keys(EMAIL)115 password_field = self.driver.find_element_by_css_selector('#field-password')116 password_field.send_keys(PASSWORD)117 customer_privacy_checkbox = self.driver.find_element_by_css_selector\118 ('.custom-checkbox > label > input[name=customer_privacy]')119 customer_privacy_checkbox.click()120 psgdpr_checkbox = self.driver.find_element_by_css_selector \121 ('.custom-checkbox > label > input[name=psgdpr]')122 psgdpr_checkbox.click()123 submit_btn = self.driver.find_element_by_css_selector\124 ('button.btn.btn-primary.form-control-submit.float-xs-right')125 submit_btn.click()126 personal_info = WebDriverWait(driver, 10).until(127 EC.presence_of_element_located((By.CSS_SELECTOR, '.hidden-sm-down'))128 ).text129 def fill_order_form(self):130 cart_link = WebDriverWait(driver, 10).until(131 EC.presence_of_element_located((By.CSS_SELECTOR, '.header > a'))132 )133 cart_link.click()134 order_form_link = WebDriverWait(driver, 10).until(135 EC.presence_of_element_located((By.CSS_SELECTOR, '.text-sm-center > a'))136 )137 order_form_link.click()138 self.fill_address()139 self.choose_delivery_method()140 self.choose_payment_method()141 self.check_status()142 def fill_address(self):143 CITY = 'GDANSK'144 POSTAL_CODE = '80-223'145 ADDRESS = 'Gabriela Narutowicza 11/12'146 WebDriverWait(driver, 10).until(147 EC.presence_of_element_located((By.CSS_SELECTOR, '.js-address-form'))148 )149 addres_field = self.driver.find_element_by_css_selector('#field-address1')150 addres_field.send_keys(ADDRESS)151 postal_code_field = self.driver.find_element_by_css_selector('#field-postcode')152 postal_code_field.send_keys(POSTAL_CODE)153 city_field = self.driver.find_element_by_css_selector('#field-city')154 city_field.send_keys(CITY)155 continue_btn = self.driver.find_element_by_css_selector\156 ('.form-footer.clearfix > button[name=confirm-addresses]')157 continue_btn.click()158 def choose_delivery_method(self):159 delivery_option = WebDriverWait(driver, 10).until(160 EC.presence_of_element_located((By.CSS_SELECTOR, '#delivery_option_2'))161 )162 delivery_option.click()163 subbmit_bttn = WebDriverWait(driver, 10).until(164 EC.presence_of_element_located((By.NAME, 'confirmDeliveryOption'))165 )166 subbmit_bttn.click()167 def choose_payment_method(self):168 delivery_option = WebDriverWait(driver, 10).until(169 EC.presence_of_element_located((By.CSS_SELECTOR, '#payment-option-2'))170 )171 delivery_option.click()172 self.driver.find_element_by_id('conditions_to_approve[terms-and-conditions]').click()173 subbmit_bttn = WebDriverWait(driver, 10).until(174 EC.presence_of_element_located((By.XPATH, "//*[contains(text(), 'Złóż zamówienie')]"))175 )176 subbmit_bttn.click()177 def check_status(self):178 try:179 WebDriverWait(driver, 10).until(180 EC.presence_of_element_located((By.XPATH, "//*[contains(text(), 'Płatność przy odbiorze')]"))181 )182 except Exception:183 print("TEST FAILED")184 self.driver.get(self.url+'/index.php?controller=history')185 try:186 WebDriverWait(driver, 10).until(187 EC.presence_of_element_located((By.XPATH, "//*[contains(text(), 'Przygotowanie w toku')]"))188 )189 except Exception:190 print("TEST FAILED")191if __name__ == "__main__":192 driver = webdriver.Chrome(PATH)193 driver.maximize_window()194 #driver.find_element_by_class_name()195 test = Test(driver, URL, PRODUCTS_NUM, FIRST_CATEGORY_PRODUCTS_NUM, FIRST_CATEGORY, SECOND_CATEGORY)...

Full Screen

Full Screen

login_mail.py

Source:login_mail.py Github

copy

Full Screen

1import time2import selenium3from util import explicit_wait4from receiveEmail import get_confirm_url5def login_yahoo(driver, email, email_pwd, paypal_pwd, step_flag, paypal_type):6 time.sleep(5)7 paypal_confirm_url = get_confirm_email(email, email_pwd)8 if not paypal_confirm_url and paypal_type == 1:9 print('Not email url, Send again!')10 paypal_confirm_url = paypal_personal_send_email_again(driver, step_flag)11 elif not paypal_confirm_url and paypal_type == 2:12 print('Not email url, Send again!')13 paypal_confirm_url = paypal_here_send_email_again(driver, step_flag)14 if paypal_confirm_url:15 js = 'window.open("%s");' % paypal_confirm_url16 driver.execute_script(js)17 windows = driver.window_handles18 # Gets the new page handle19 driver.switch_to.window(windows[1])20 time.sleep(3)21 step_flag = activate(driver, email, paypal_pwd, step_flag)22 else:23 step_flag = 024 return step_flag25def paypal_personal_send_email_again(driver, step_flag):26 print('Send email again!')27 try:28 driver.find_element_by_xpath('//div[@class="myAccount"]/a').click()29 time.sleep(3)30 except:31 pass32 email_flag_XP = '//a[@data-name="confirm_your_email"]'33 email_flag_exist = explicit_wait(driver, "VOEL", [email_flag_XP, "XPath"], 30, False)34 if email_flag_exist:35 email_flag = driver.find_element_by_xpath(email_flag_XP)36 (ActionChains(driver)37 .move_to_element(email_flag)38 .click()39 .perform())40 click_send_button_XP = '//button[@id="js_unconfirmedEmail"]'41 click_send_button_flag = explicit_wait(driver, "VOEL", [click_send_button_XP, "XPath"], 30, False)42 if click_send_button_flag:43 click_send_button = driver.find_element_by_xpath(click_send_button_XP)44 (ActionChains(driver)45 .move_to_element(click_send_button)46 .click()47 .perform())48 else:49 driver.refresh()50 click_send_button_XP = '//button[@id="js_unconfirmedEmail"]'51 click_send_button_flag = explicit_wait(driver, "VOEL", [click_send_button_XP, "XPath"], 30, False)52 if click_send_button_flag:53 click_send_button = driver.find_element_by_xpath(click_send_button_XP)54 (ActionChains(driver)55 .move_to_element(click_send_button)56 .click()57 .perform())58 else:59 step_flag = 060 if step_flag == 1:61 time.sleep(10)62 paypal_confirm_url = get_confirm_email(email, email_pwd)63 else:64 step_flag = 065 return paypal_confirm_url66def paypal_here_send_email_again(driver, step_flag):67 driver.get('https://www.paypal.com/businessprofile/settings/email')68 email_edit_XP = '//span[@class="links"]//a[1]'69 email_edit_flag = explicit_wait(driver, "VOEL", [email_edit_XP, "XPath"], 10, False)70 if email_edit_flag:71 driver.find_element_by_xpath(email_edit_XP).click()72 email_confirm_XP = '//a[@class="confirm"]'73 email_confirm_flag = explicit_wait(driver, "VOEL", [email_confirm_XP, "XPath"], 10, False)74 if email_confirm_flag:75 driver.find_element_by_xpath(email_confirm_XP).click()76 time.sleep(5)77 paypal_confirm_url = get_confirm_email(email, email_pwd)78 step_flag = 079 else:80 step_flag = 081 return paypal_confirm_url82def login_gmail(driver, conn, email, email_pwd, paypal_pwd, recovery_email):83 js = 'window.open("https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&sacu=1&rip=1");'84 driver.execute_script(js)85 windows = driver.window_handles86 # Gets the new page handle87 driver.switch_to.window(windows[1])88 time.sleep(3)89 if driver.page_source.find('This site can’t be reached') > -1:90 print('Net Error!')91 driver.refence()92 time.sleep(5)93 try:94 # element = WebDriverWait(driver, 10).until(95 # EC.presence_of_element_located((By.ID, 'identifierId')))96 # element.send_keys(email)97 driver.find_element_by_id('identifierId').send_keys(email)98 time.sleep(1)99 driver.find_element_by_id('identifierNext').click()100 time.sleep(5)101 except Exception as e:102 pass103 try:104 driver.find_element_by_name('password').send_keys(email_pwd)105 driver.find_element_by_id('passwordNext').click()106 time.sleep(3)107 error_info = driver.find_element_by_xpath(108 '//div[@class="GQ8Pzc"]')109 if error_info:110 print('Password error!')111 except Exception as e:112 pass113 try:114 time.sleep(5)115 element1 = WebDriverWait(driver, 10).until(116 EC.presence_of_element_located((By.XPATH, '//li[@class="C5uAFc"]/div')))117 element1.click()118 time.sleep(3)119 element2 = WebDriverWait(driver, 10).until(120 EC.presence_of_element_located((By.ID, 'identifierId')))121 element2.send_keys(recovery_email)122 driver.find_element_by_xpath(123 '//div[@class="qhFLie"]/div').click()124 except Exception as e:125 pass126 try:127 element3 = WebDriverWait(driver, 5).until(128 EC.presence_of_element_located((By.XPATH, '//div[@class="N4lOwd"]')))129 time.sleep(3)130 driver.find_element_by_xpath(131 '//div[@class="yKBrKe"]/div').click()132 except Exception as e:133 pass134 try:135 element = WebDriverWait(driver, 10).until(136 EC.presence_of_element_located((By.XPATH, '//div[@class="tbyFuf"]//a[2]')))137 element.click()138 time.sleep(3)139 except Exception as e:140 pass141 try:142 driver.find_element_by_xpath(143 '//button[@name="welcome_dialog_next"]').click()144 time.sleep(2)145 driver.find_element_by_xpath('//button[@name="ok"]').click()146 time.sleep(2)147 except:148 pass149 try:150 email_element = driver.find_elements_by_xpath(151 '//div[@class="yW"]//span[@name="service@paypal.com"]')152 email_element[0].click()153 time.sleep(3)154 except:155 pass156 while True:157 link_element = ''158 try:159 link_element = driver.find_element_by_xpath(160 '//a[text()="Confirm My Email"]')161 except:162 pass163 if link_element:164 link_element.click()165 time.sleep(5)166 break167 windows = driver.window_handles168 # Gets the new page handle169 driver.switch_to.window(windows[2])170 time.sleep(3)171 activate(driver, email, paypal_pwd, created_flag)172def activate(driver, email, paypal_pwd, step_flag):173 input_password_XP = '//input[@id="password"]'174 input_password_flag = explicit_wait(175 driver, "VOEL", [input_password_XP, "XPath"], 30, False)176 if input_password_flag:177 time.sleep(8)178 driver.find_element_by_xpath(input_password_XP).send_keys(paypal_pwd)179 time.sleep(1)180 driver.find_element_by_xpath('//button[@id="btnLogin"]').click()181 time.sleep(1)182 not_now_button_XP = '//p[@class="secondaryLink"]/a'183 not_now_button_flag = explicit_wait(184 driver, "VOEL", [not_now_button_XP, "XPath"], 10, False)185 if not_now_button_flag:186 not_now_button = driver.find_element_by_xpath(not_now_button_XP)187 (ActionChains(driver)188 .move_to_element(not_now_button)189 .click()190 .perform())191 else:192 try_times = 0193 while True:194 msg_code = ''195 try:196 msg_code = driver.find_element_by_xpath(197 '//form/div[1]/p').text198 except:199 pass200 if msg_code == 'Your email is all set!':201 # Not now202 driver.find_element_by_xpath(203 '//button[@id="/appData/action"]').click()204 break205 else:206 try_times += 1207 time.sleep(3)208 if try_times > 5:209 step_flag = 0210 break211 else:212 step_flag = 0...

Full Screen

Full Screen

FlightPages.py

Source:FlightPages.py Github

copy

Full Screen

1import time2from calendar import Calendar3from selenium.webdriver.support.ui import Select4from selenium import webdriver5from selenium.webdriver.common.by import By6from selenium.webdriver.support.ui import WebDriverWait7from selenium.webdriver.support import expected_conditions as EC8from selenium.webdriver.common.action_chains import ActionChains9from selenium.webdriver.common.keys import Keys10from selenium.webdriver.common.action_chains import ActionChains11from selenium.common.exceptions import NoAlertPresentException, NoSuchWindowException, NoSuchFrameException, StaleElementReferenceException12from FlightLocators import FlightLocators13from FlightData import FlightData14class BaseFlightPage():15 def __init__(self,driver):16 self.driver = driver17 def click(self,by_locator):18 WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator)).click()19 def assert_element_text(self, by_locator, element_text):20 web_element = WebDriverWait(self.driver,10).until(EC.visibility_of_element_located(by_locator))21 assert web_element.text == element_text22 def enter_keys(self,by_locator,text):23 return WebDriverWait(self.driver,10).until(EC.visibility_of_element_located(by_locator)).send_keys(text)24 def is_enabled(self,by_locator):25 return WebDriverWait(self.driver,10).until(EC.visibility_of_element_located(by_locator))26 def is_visible(self,by_locator):27 element = WebDriverWait(self.driver,10).until(EC.visibility_of_element_located(by_locator))28 return bool (element)29 def hover_to(self,by_locator):30 element = WebDriverWait(self.driver,10).until(EC.visibility_of_element_located(by_locator))31 ActionChains(self.driver).move_to_element(element).perform()32class FlightHomePage(BaseFlightPage):33 def __init__(self, driver):34 super().__init__(driver)35 self.driver.get(FlightData.BASE_URL)36 def select_round_trip(self):37 self.driver.find_element(*FlightLocators.RoundTrip).click()38class SelectDestinations(BaseFlightPage):39 def __init__(self, driver):40 super().__init__(driver)41 def select_destinations(self):42 self.driver.find_element(*FlightLocators.From).send_keys("Mumbai")43 self.driver.find_element(*FlightLocators.Select_Mumbai).click()44 self.driver.find_element(*FlightLocators.To).send_keys("Delhi")45 self.driver.find_element(*FlightLocators.Select_Delhi).click()46class SelectDateRange(BaseFlightPage):47 def __init__(self, driver):48 super().__init__(driver)49 def select_daterange(self):50 calendar = self.driver.find_element(*FlightLocators.select_calendar)51 calendar.click()52 picker = self.driver.find_element(*FlightLocators.DatePicker)53 actions = ActionChains(self.driver)54 actions.move_to_element(picker)55 # perform the operation on the element56 actions.perform()57 fromdate = self.driver.find_element(*FlightLocators.From_Date)58 fromdate.click()59 todate = self.driver.find_element(*FlightLocators.To_Date)60 todate.click()61class SelectPassengerInfo(BaseFlightPage):62 def __init__(self, driver):63 super().__init__(driver)64 def select_passengers(self):65 selectadult = self.driver.find_element(*FlightLocators.Adults)66 adultcount = Select(selectadult)67 adultcount.select_by_value("2")68 selectchild = self.driver.find_element(*FlightLocators.Child)69 childcount = Select(selectchild)70 childcount.select_by_value("1")71class SearchFlight(BaseFlightPage):72 def __init__(self, driver):73 super().__init__(driver)74 def search_flight(self):75 self.driver.find_element(*FlightLocators.SearchFlight).click()76 time.sleep(3)77class BookFlight(BaseFlightPage):78 def __init__(self, driver):79 super().__init__(driver)80 def book_flight(self):81 #self.driver.find_element(*FlightLocators.BookButton).click()82 parent_window_handle = self.driver.current_window_handle83 print("Parent Window Handle is - ", parent_window_handle)84 book_flight = self.driver.find_element(*FlightLocators.BookButton)85 book_flight.click()86 time.sleep(5)87 try:88 self.driver.switch_to.window(self.driver.window_handles[1])89 except NoSuchWindowException:90 print("No Such Window Present")91 def standard_fare(self):92 time.sleep(6)93 self.driver.execute_script("window.scrollTo(0, 300)")94 self.driver.find_element(*FlightLocators.StandardFare).click()95 self.driver.execute_script("window.scrollTo(0, 1400)")96 time.sleep(3)97 self.driver.find_element(*FlightLocators.Continue).click()98 time.sleep(3)99 self.driver.find_element(*FlightLocators.select_seats).click()100class FlightDetails(BaseFlightPage):101 def __init__(self, driver):102 super().__init__(driver)103 def select_seats(self):104 time.sleep(3)105 seats = self.driver.find_elements(*FlightLocators.Seat)106 selectseats = []107 for x in (seats):108 selectseats.append(x)109 if len(selectseats)==3:110 break111 for y in selectseats:112 y.click()113 print("hello")114 time.sleep(4)115 self.driver.find_element(*FlightLocators.Done).click()116 self.driver.find_element(*FlightLocators.SaveNextSeats).click()117 def select_meals(self):118 time.sleep(3)119 self.driver.find_element(*FlightLocators.Meals).click()120 self.driver.find_element(*FlightLocators.MealsNext).click()121 self.driver.find_element(*FlightLocators.Next_menu).click()122 self.driver.find_element(*FlightLocators.MealsDone).click()123 self.driver.find_element(*FlightLocators.SaveNext).click()124 def select_baggage(self):125 time.sleep(3)126 self.driver.find_element(*FlightLocators.Baggage).click()127 self.driver.find_element(*FlightLocators.AddedLuggage).click()128 self.driver.find_element(*FlightLocators.LuggageDone).click()129 self.driver.find_element(*FlightLocators.SaveAndExit).click()130 self.driver.find_element(*FlightLocators.ContinueAfterLuggage).click()131 def contact_details(self):132 time.sleep(4)133 self.driver.find_element(*FlightLocators.MobileNumber).send_keys("9096914627")134 self.driver.find_element(*FlightLocators.Email).send_keys("isha.rth@gmail.com")135 time.sleep(3)136 self.driver.find_element(*FlightLocators.ContinueAfterContact).click()137 def traveler_details(self):138 time.sleep(3)139 self.driver.find_element(*FlightLocators.Adult1FN).send_keys("Mark")140 self.driver.find_element(*FlightLocators.Adult1LN).send_keys("Zuck")141 self.driver.find_element(*FlightLocators.Adult1G).click()142 self.driver.find_element(*FlightLocators.GenderM).click()143 self.driver.find_element(*FlightLocators.Adult2FN).send_keys("Mary")144 self.driver.find_element(*FlightLocators.Adult2LN).send_keys("Lane")145 self.driver.find_element(*FlightLocators.Adult2G).click()146 self.driver.find_element(*FlightLocators.GenderF).click()147 self.driver.find_element(*FlightLocators.ChildFN).send_keys("Rob")148 self.driver.find_element(*FlightLocators.ChildLN).send_keys("Zuck")149 self.driver.find_element(*FlightLocators.ChildG).click()150 self.driver.find_element(*FlightLocators.GenderM).click()151 self.driver.find_element(*FlightLocators.BirthD).send_keys("01/01/2012")152 time.sleep(2)153 self.driver.execute_script("window.scrollTo(0, 3000)")154 try :155 a = self.driver.find_element_by_xpath("//label/p[contains(text(),'Use GSTIN details for this booking')]/parent::label/following-sibling::div[3]/div/button")156 time.sleep(2)157 a.click()158 except StaleElementReferenceException as e :...

Full Screen

Full Screen

Engagement_unit_test.py

Source:Engagement_unit_test.py Github

copy

Full Screen

...79 return suite80if __name__ == "__main__":81 runner = unittest.TextTestRunner(descriptions=True, failfast=True, verbosity=2)82 ret = not runner.run(suite()).wasSuccessful()83 BaseTestCase.tearDownDriver()...

Full Screen

Full Screen

smoke_test.py

Source:smoke_test.py Github

copy

Full Screen

...86 return suite87if __name__ == "__main__":88 runner = unittest.TextTestRunner(descriptions=True, failfast=True, verbosity=2)89 ret = not runner.run(suite()).wasSuccessful()90 BaseTestCase.tearDownDriver()...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var chrominator = require('chrominator');2var driver = chrominator.driver;3var By = chrominator.By;4var until = chrominator.until;5var fs = chrominator.fs;6var assert = chrominator.assert;7var should = chrominator.should;8var chai = chrominator.chai;9var expect = chrominator.expect;10driver.findElement(By.name('q')).sendKeys('webdriver');11driver.findElement(By.name('btnG')).click();12driver.wait(until.titleIs('webdriver - Google Search'), 1000);13driver.quit();14var chrominator = require('chrominator');15var driver = chrominator.driver;16var By = chrominator.By;17var until = chrominator.until;18var fs = chrominator.fs;19var assert = chrominator.assert;20var should = chrominator.should;21var chai = chrominator.chai;22var expect = chrominator.expect;23driver.findElement(By.name('q')).sendKeys('webdriver');24driver.findElement(By.name('btnG')).click();25driver.wait(until.titleIs('webdriver - Google Search'), 1000);26driver.quit();27var chrominator = require('chrominator');28var driver = chrominator.driver;29var By = chrominator.By;30var until = chrominator.until;31var fs = chrominator.fs;32var assert = chrominator.assert;33var should = chrominator.should;34var chai = chrominator.chai;35var expect = chrominator.expect;36driver.findElement(By.name('q')).sendKeys('webdriver');37driver.findElement(By.name('btnG')).click();38driver.wait(until.titleIs('webdriver - Google Search'), 1000);39driver.quit();40var chrominator = require('chrominator');41var driver = chrominator.driver;42var By = chrominator.By;43var until = chrominator.until;44var fs = chrominator.fs;45var assert = chrominator.assert;46var should = chrominator.should;47var chai = chrominator.chai;48var expect = chrominator.expect;49driver.findElement(By.name('q')).sendKeys('webdriver');50driver.findElement(By.name('btnG

Full Screen

Using AI Code Generation

copy

Full Screen

1var chrominator = require("chrominator");2chrominator.init({headless: false, browser: "chrome"})3chrominator.type("input[name='q']", "chrominator")4chrominator.click("input[value='Google Search']")5chrominator.screenshot("google.png")6chrominator.end()

Full Screen

Using AI Code Generation

copy

Full Screen

1var chrominator = require('chrominator');2chrominator({3 browser: function(browser, done){4 done();5 }6});7var chrominator = require('chrominator');8chrominator({9 browser: function(browser, done){10 done();11 }12});13var chrominator = require('chrominator');14chrominator({15 browser: function(browser, done){16 done();17 }18});19var chrominator = require('chrominator');

Full Screen

Using AI Code Generation

copy

Full Screen

1var browser = chrominator.createBrowser();2var page = chrominator.createPage();3var page = chrominator.createPage();4var page = chrominator.createPage();5var page = chrominator.createPage();6var page = chrominator.createPage();7var page = chrominator.createPage();8var page = chrominator.createPage();9var page = chrominator.createPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const driver = Driver('chrome', '/Users/yourname/Downloads/chromedriver');2Type(driver, 'input[title="Search"]', 'Chrominator');3Click(driver, 'input[value="Google Search"]');4Close(driver);5{6 "scripts": {7 },8 "dependencies": {9 }10}

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run chrominator automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful