How to use alert_accept method in Airtest

Best Python code snippet using Airtest

noteFeedback.py

Source:noteFeedback.py Github

copy

Full Screen

1import subprocess2from selenium import webdriver3from selenium.webdriver.common.by import By4import time5from selenium.webdriver.chrome.service import Service6from webdriver_manager.chrome import ChromeDriverManager7# 학생 연구노트 제출8class Test2:9 txt = "동해 물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라 만세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세. 남산 위에 저 소나무, 철갑을 두른 듯 바람 서리 불변함은 우리 기상일세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세. 가을 하늘 공활한데 높고 구름 없이 밝은 달은 우리 가슴 일편단심일세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세. 이 기상과 이 맘으로 충성을 다하여 괴로우나 즐거우나 나라 사랑하세. 무궁화 삼천리 화려 강산 대한 사람, 대한으로 길이 보전하세."10 def __int__(self, address: str):11 #self.driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") # 드라이버12 #self.driver.get(address) # 주소 입력13 #self.driver.maximize_window() # 전체 화면14 chrome_options = webdriver.ChromeOptions()15 self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)16 self.driver.get(address)17 self.driver.maximize_window()18 # 로그인19 def LogIn(self):20 self.driver.find_element(By.ID, "mui-1").send_keys("씨큐브학생") # 아이디 입력21 self.driver.find_element(By.ID, "mui-2").send_keys("1234") # 비밀번호 입력22 self.driver.find_element(By.CLASS_NAME, "MuiButton-root").click() # 로그인 버튼 클릭23 def WriteNoteW1(self):24 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[1]/div/div[2]/div[1]/button").click()25 time.sleep(1)26 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()27 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)28 time.sleep(1)29 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()30 time.sleep(1)31 self.Alert_Accept()32 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[1]/div/div[2]/div[2]/button").click()33 time.sleep(1)34 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()35 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)36 time.sleep(1)37 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()38 time.sleep(1)39 self.Alert_Accept()40 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[1]/div/div[2]/div[3]/button").click()41 time.sleep(1)42 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()43 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)44 time.sleep(1)45 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()46 time.sleep(1)47 self.Alert_Accept()48 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[1]/div/div[2]/div[4]/button").click()49 time.sleep(1)50 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").clear()51 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").send_keys(self.txt)52 time.sleep(1)53 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[1]/button").click()54 time.sleep(1)55 self.Alert_Accept()56 def WriteNoteW2(self):57 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[2]/div/div[2]/div[1]/button").click()58 time.sleep(1)59 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()60 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)61 time.sleep(1)62 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()63 time.sleep(1)64 self.Alert_Accept()65 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[2]/div/div[2]/div[2]/button").click()66 time.sleep(1)67 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()68 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)69 time.sleep(1)70 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()71 time.sleep(1)72 self.Alert_Accept()73 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[2]/div/div[2]/div[3]/button").click()74 time.sleep(1)75 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()76 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)77 time.sleep(1)78 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()79 time.sleep(1)80 self.Alert_Accept()81 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[2]/div/div[2]/div[4]/button").click()82 time.sleep(1)83 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").clear()84 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").send_keys(self.txt)85 time.sleep(1)86 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[1]/button").click()87 time.sleep(1)88 self.Alert_Accept()89 def WriteNoteW3(self):90 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[3]/div/div[2]/div[1]/button").click()91 time.sleep(1)92 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()93 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)94 time.sleep(1)95 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()96 time.sleep(1)97 self.Alert_Accept()98 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[3]/div/div[2]/div[2]/button").click()99 time.sleep(1)100 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()101 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)102 time.sleep(1)103 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()104 time.sleep(1)105 self.Alert_Accept()106 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[3]/div/div[2]/div[3]/button").click()107 time.sleep(1)108 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()109 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)110 time.sleep(1)111 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()112 time.sleep(1)113 self.Alert_Accept()114 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[3]/div/div[2]/div[4]/button").click()115 time.sleep(1)116 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").clear()117 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").send_keys(self.txt)118 time.sleep(1)119 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[1]/button").click()120 time.sleep(1)121 self.Alert_Accept()122 def WriteNoteW4(self):123 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[4]/div/div[2]/div[1]/button").click()124 time.sleep(1)125 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()126 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)127 time.sleep(1)128 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()129 time.sleep(1)130 self.Alert_Accept()131 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[4]/div/div[2]/div[2]/button").click()132 time.sleep(1)133 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()134 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)135 time.sleep(1)136 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()137 time.sleep(1)138 self.Alert_Accept()139 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[4]/div/div[2]/div[3]/button").click()140 time.sleep(1)141 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()142 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)143 time.sleep(1)144 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()145 time.sleep(1)146 self.Alert_Accept()147 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[4]/div/div[2]/div[4]/button").click()148 time.sleep(1)149 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").clear()150 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").send_keys(self.txt)151 time.sleep(1)152 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[1]/button").click()153 time.sleep(1)154 self.Alert_Accept()155 def WriteNoteW5(self):156 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[5]/div/div[2]/div[1]/button").click()157 time.sleep(1)158 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()159 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)160 time.sleep(1)161 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()162 time.sleep(1)163 self.Alert_Accept()164 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[5]/div/div[2]/div[2]/button").click()165 time.sleep(1)166 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()167 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)168 time.sleep(1)169 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()170 time.sleep(1)171 self.Alert_Accept()172 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[5]/div/div[2]/div[3]/button").click()173 time.sleep(1)174 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()175 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)176 time.sleep(1)177 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()178 time.sleep(1)179 self.Alert_Accept()180 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[5]/div/div[2]/div[4]/button").click()181 time.sleep(1)182 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").clear()183 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").send_keys(self.txt)184 time.sleep(1)185 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[1]/button").click()186 time.sleep(1)187 self.Alert_Accept()188 def WriteNoteW6(self):189 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[6]/div/div[2]/div[1]/button").click()190 time.sleep(1)191 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()192 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)193 time.sleep(1)194 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()195 time.sleep(1)196 self.Alert_Accept()197 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[6]/div/div[2]/div[2]/button").click()198 time.sleep(1)199 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()200 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)201 time.sleep(1)202 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()203 time.sleep(1)204 self.Alert_Accept()205 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[6]/div/div[2]/div[3]/button").click()206 time.sleep(1)207 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()208 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)209 time.sleep(1)210 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()211 time.sleep(1)212 self.Alert_Accept()213 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[6]/div/div[2]/div[4]/button").click()214 time.sleep(1)215 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").clear()216 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").send_keys(self.txt)217 time.sleep(1)218 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[1]/button").click()219 time.sleep(1)220 self.Alert_Accept()221 def WriteNoteW7(self):222 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[7]/div/div[2]/div[1]/button").click()223 time.sleep(1)224 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()225 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)226 time.sleep(1)227 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()228 time.sleep(1)229 self.Alert_Accept()230 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[7]/div/div[2]/div[2]/button").click()231 time.sleep(1)232 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()233 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)234 time.sleep(1)235 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()236 time.sleep(1)237 self.Alert_Accept()238 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[7]/div/div[2]/div[3]/button").click()239 time.sleep(1)240 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()241 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)242 time.sleep(1)243 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()244 time.sleep(1)245 self.Alert_Accept()246 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[7]/div/div[2]/div[4]/button").click()247 time.sleep(1)248 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").clear()249 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").send_keys(self.txt)250 time.sleep(1)251 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[1]/button").click()252 time.sleep(1)253 self.Alert_Accept()254 def WriteNoteW8(self):255 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[8]/div/div[2]/div[1]/button").click()256 time.sleep(1)257 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()258 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)259 time.sleep(1)260 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()261 time.sleep(1)262 self.Alert_Accept()263 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[8]/div/div[2]/div[2]/button").click()264 time.sleep(1)265 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()266 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)267 time.sleep(1)268 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()269 time.sleep(1)270 self.Alert_Accept()271 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[8]/div/div[2]/div[3]/button").click()272 time.sleep(1)273 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()274 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)275 time.sleep(1)276 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()277 time.sleep(1)278 self.Alert_Accept()279 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[8]/div/div[2]/div[4]/button").click()280 time.sleep(1)281 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").clear()282 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").send_keys(self.txt)283 time.sleep(1)284 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[1]/button").click()285 time.sleep(1)286 self.Alert_Accept()287 def WriteNoteW9(self):288 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[9]/div/div[2]/div[1]/button").click()289 time.sleep(1)290 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()291 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)292 time.sleep(1)293 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()294 time.sleep(1)295 self.Alert_Accept()296 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[9]/div/div[2]/div[2]/button").click()297 time.sleep(1)298 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()299 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)300 time.sleep(1)301 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()302 time.sleep(1)303 self.Alert_Accept()304 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[9]/div/div[2]/div[3]/button").click()305 time.sleep(1)306 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()307 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)308 time.sleep(1)309 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()310 time.sleep(1)311 self.Alert_Accept()312 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[9]/div/div[2]/div[4]/button").click()313 time.sleep(1)314 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").clear()315 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").send_keys(self.txt)316 time.sleep(1)317 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[1]/button").click()318 time.sleep(1)319 self.Alert_Accept()320 def WriteNoteW10(self):321 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[10]/div/div[2]/div[1]/button").click()322 time.sleep(1)323 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()324 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)325 time.sleep(1)326 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()327 time.sleep(1)328 self.Alert_Accept()329 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[10]/div/div[2]/div[2]/button").click()330 time.sleep(1)331 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()332 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)333 time.sleep(1)334 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()335 time.sleep(1)336 self.Alert_Accept()337 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[10]/div/div[2]/div[3]/button").click()338 time.sleep(1)339 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()340 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)341 time.sleep(1)342 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()343 time.sleep(1)344 self.Alert_Accept()345 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[10]/div/div[2]/div[4]/button").click()346 time.sleep(1)347 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").clear()348 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").send_keys(self.txt)349 time.sleep(1)350 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[1]/button").click()351 time.sleep(1)352 self.Alert_Accept()353 def WriteNoteW11(self):354 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[11]/div/div[2]/div[1]/button").click()355 time.sleep(1)356 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()357 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)358 time.sleep(1)359 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()360 time.sleep(1)361 self.Alert_Accept()362 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[11]/div/div[2]/div[2]/button").click()363 time.sleep(1)364 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()365 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)366 time.sleep(1)367 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()368 time.sleep(1)369 self.Alert_Accept()370 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[11]/div/div[2]/div[3]/button").click()371 time.sleep(1)372 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()373 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)374 time.sleep(1)375 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()376 time.sleep(1)377 self.Alert_Accept()378 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[11]/div/div[2]/div[4]/button").click()379 time.sleep(1)380 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").clear()381 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").send_keys(self.txt)382 time.sleep(1)383 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[1]/button").click()384 time.sleep(1)385 self.Alert_Accept()386 def WriteNoteW12(self):387 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[12]/div/div[2]/div[1]/button").click()388 time.sleep(1)389 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()390 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)391 time.sleep(1)392 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()393 time.sleep(1)394 self.Alert_Accept()395 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[12]/div/div[2]/div[2]/button").click()396 time.sleep(1)397 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()398 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)399 time.sleep(1)400 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()401 time.sleep(1)402 self.Alert_Accept()403 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[12]/div/div[2]/div[3]/button").click()404 time.sleep(1)405 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").clear()406 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[2]/div/div[2]/div/p[4]").send_keys(self.txt)407 time.sleep(1)408 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div/div/div[1]/button").click()409 time.sleep(1)410 self.Alert_Accept()411 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div[2]/div[12]/div/div[2]/div[4]/button").click()412 time.sleep(1)413 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").clear()414 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[2]/div/div[2]/div/p[2]").send_keys(self.txt)415 time.sleep(1)416 self.driver.find_element(By.XPATH, "//*[@id='root']/div/div/main/div/div/div/div/div[1]/button").click()417 time.sleep(1)418 self.Alert_Accept()419 # 팝업창 > 승인420 def Alert_Accept(self):421 from selenium.webdriver.common.alert import Alert422 da = Alert(self.driver)423 da.accept()424 def do(self):425 self.__int__("http://49.247.24.46:7001/")426 time.sleep(1)427 self.LogIn()428 time.sleep(1)429 self.WriteNoteW1()430 time.sleep(1)431 self.WriteNoteW2()432 time.sleep(1)433 self.WriteNoteW3()434 time.sleep(1)435 self.WriteNoteW4()436 time.sleep(1)437 self.WriteNoteW5()438 time.sleep(1)439 self.WriteNoteW6()440 time.sleep(1)441 self.WriteNoteW7()442 time.sleep(1)443 self.WriteNoteW8()444 time.sleep(1)445 self.WriteNoteW9()446 time.sleep(1)447 self.WriteNoteW10()448 time.sleep(1)449 self.WriteNoteW11()450 time.sleep(1)451 self.WriteNoteW12()452 time.sleep(1)453if __name__ == '__main__':454 a = Test2()455 a.do()...

Full Screen

Full Screen

reservation_TKB_selenium2.0.py

Source:reservation_TKB_selenium2.0.py Github

copy

Full Screen

...2324 browser.get('https://bookseat.tkblearning.com.tw/book-seat/student/login/toLogin')25 sleep(2)2627 if alert_accept():28 print("alert showed")29 else :30 print("no alert")3132 input = wait.until(EC.presence_of_element_located(33 (By.XPATH, '//*[@id="id"]')))34 input.send_keys('your account')35 input = wait.until(EC.presence_of_element_located(36 (By.XPATH, '//*[@id="pwd"]')))37 input.send_keys('your password')38 submit = wait.until(EC.element_to_be_clickable(39 (By.XPATH, '/html/body/form/div/div/div/table/tbody/tr[4]/td[2]/div[1]/a')))40 submit.click() # 點選登入按鈕41 42 sleep(3)4344 ##確認彈出訊息視窗兩次45 if alert_accept():46 print("alert showed")47 else :48 print("no alert")49 50 if alert_accept():51 print("alert showed")52 else :53 print("no alert")545556 #選擇課程57 slect_class = Select(browser.find_element_by_id("class_selector"))#找到選單58 slect_class.select_by_value("V5<6>KM:;<=>?A=BD@EGCI")#定位課程59 #選擇日期60 select_date = Select(browser.find_element_by_id("date_selector"))#找到選單61 select_date.select_by_value(today)#定位日期62 #選擇地區63 select_city = Select(browser.find_element_by_id("branch_selector"))#找到選單64 select_city.select_by_value("WA")#定位地區65 sleep(3)6667 reserve_check = 068 try:69 browser.find_element_by_css_selector('input[value="1"]').click()70 print("成功選取"+today+"第一場次")71 except:72 reserve_check += 173 print("第一場次無法選取")7475 try:76 browser.find_element_by_css_selector('input[value="2"]').click()77 print("成功選取"+today+"第二場次")78 except:79 reserve_check += 280 print("第二場次無法選取")8182 if reserve_check < 1:83 submit = wait.until(EC.element_to_be_clickable(84 (By.XPATH, '/html/body/div[3]/div[3]/div/div[2]/section/article/table/tbody/tr[6]/td[2]/div[1]/a')))85 submit.click() # 點選送出按鈕86 print("預約 場次一、場次二 成功")87 elif reserve_check < 2:88 submit = wait.until(EC.element_to_be_clickable(89 (By.XPATH, '/html/body/div[3]/div[3]/div/div[2]/section/article/table/tbody/tr[6]/td[2]/div[1]/a')))90 submit.click() # 點選送出按鈕91 print("預約 場次二 成功")92 elif reserve_check < 3:93 submit = wait.until(EC.element_to_be_clickable(94 (By.XPATH, '/html/body/div[3]/div[3]/div/div[2]/section/article/table/tbody/tr[6]/td[2]/div[1]/a')))95 submit.click() # 點選送出按鈕96 print("預約 場次一 成功")97 else :98 print("預約失敗")99 sleep(3)100101 if alert_accept():102 print("alert showed")103 else :104 print("no alert")105106 if alert_accept():107 print("alert showed")108 else :109 print("no alert") 110111112def alert_accept():113 try:114 alert = browser.switch_to.alert115 print(alert.text)116 alert.accept()117 sleep(2)118 return alert 119 except:120 return False121122123if __name__=="__main__":124125 login()126

Full Screen

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 Airtest 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