How to use frame_switch method in SeleniumBase

Best Python code snippet using SeleniumBase

GUI.py

Source:GUI.py Github

copy

Full Screen

...8 self.title("Protein Synthesis Master")9 self.geometry("650x225")10 self.resizable(False, False)11 self._frame = None12 self.frame_switch(MainPage)13 def frame_switch(self, frame):14 """Destroys current frame and replaces it with a new one."""15 new_frame = frame(self)16 if self._frame is not None:17 self._frame.destroy()18 self._frame = new_frame19 self._frame.pack()20 def copy_to_clipboard(self, text):21 """Copies text to clipboard"""22 tk.Tk.clipboard_clear(self)23 tk.Tk.clipboard_append(self, text)24 tk.Tk.update(self)25class MainPage(tk.Frame):26 def __init__(self, master):27 tk.Frame.__init__(self, master)28 tk.Label(self, text="Welcome to the Protein Synthesis Master!") \29 .pack(side="top", fill="x", pady=20)30 tk.Button(self, text="Get the complementary DNA pair of a DNA sequence",31 command=lambda: master.frame_switch(DNAtoDNA)).pack()32 tk.Button(self, text="Convert DNA sequence to its matching "33 "complementary mRNA sequence",34 command=lambda: master.frame_switch(DNAtoRNA)).pack()35 tk.Button(self, text="Convert RNA sequence to its "36 "matching complementary DNA sequence",37 command=lambda: master.frame_switch(RNAtoDNA)).pack()38 tk.Button(self, text="Find the polypeptide chain for a DNA sequence",39 command=lambda: master.frame_switch(DNAtoProtein)).pack()40 tk.Button(self, text="Sequence Alignment",41 command=lambda:42 master.frame_switch(SequenceComparison)).pack()43class DNAtoDNA(tk.Frame):44 def __init__(self, master):45 dm = DnaManager()46 rm = RnaManager()47 pm = ProteinManager()48 ps = ProteinSystem(dm, rm, pm)49 tk.Frame.__init__(self, master)50 tk.Label(self, text="Input DNA sequence without any spaces").pack(51 side="top",52 pady=20)53 entry = tk.Entry(self, width=50)54 entry.pack()55 label = tk.Label(self, text="", state="normal")56 label.pack()57 convert = tk.Button(self, text="Convert",58 command=lambda:59 [label.config(text=ps.dna_pairing(entry.get()),60 wraplengt=500),61 copied.config(text="")])62 convert.pack()63 copy = tk.Button(self, text="Copy",64 command=lambda: [master.copy_to_clipboard(65 label.cget("text")),66 copied.config(text="Copied to Clipboard")])67 copy.pack()68 tk.Button(self, text="Return to main page",69 command=lambda: master.frame_switch(MainPage)).pack()70 copied = tk.Label(self, text="")71 copied.pack(pady=10)72class DNAtoRNA(tk.Frame):73 def __init__(self, master):74 dm = DnaManager()75 rm = RnaManager()76 pm = ProteinManager()77 ps = ProteinSystem(dm, rm, pm)78 tk.Frame.__init__(self, master)79 tk.Label(self, text="Input DNA sequence without any spaces").pack(80 side="top",81 pady=20)82 entry = tk.Entry(self, width=50)83 entry.pack()84 label = ttk.Label(self, text="")85 label.pack()86 convert = tk.Button(self, text="Convert",87 command=lambda:88 [label.config(text=ps.get_mrna(entry.get()),89 wraplengt=500),90 copied.config(text="")])91 convert.pack()92 copy = tk.Button(self, text="Copy",93 command=lambda: [master.copy_to_clipboard(94 label.cget("text")),95 copied.config(text="Copied to Clipboard")])96 copy.pack()97 tk.Button(self, text="Return to main page",98 command=lambda: master.frame_switch(MainPage)).pack()99 copied = tk.Label(self, text="")100 copied.pack(pady=10)101class RNAtoDNA(tk.Frame):102 def __init__(self, master):103 dm = DnaManager()104 rm = RnaManager()105 pm = ProteinManager()106 ps = ProteinSystem(dm, rm, pm)107 tk.Frame.__init__(self, master)108 tk.Label(self, text="Input RNA sequence without any spaces").pack(109 side="top",110 pady=20)111 entry = tk.Entry(self, width=50)112 entry.pack()113 label = ttk.Label(self, text="")114 label.pack()115 convert = tk.Button(self, text="Convert",116 command=lambda:117 [label.config(text=ps.get_dna(entry.get()),118 wraplengt=500),119 copied.config(text="")])120 convert.pack()121 copy = tk.Button(self, text="Copy",122 command=lambda: [master.copy_to_clipboard(123 label.cget("text")),124 copied.config(text="Copied to Clipboard")])125 copy.pack()126 tk.Button(self, text="Return to main page",127 command=lambda: master.frame_switch(MainPage)).pack()128 copied = tk.Label(self, text="")129 copied.pack(pady=10)130class DNAtoProtein(tk.Frame):131 def __init__(self, master):132 dm = DnaManager()133 rm = RnaManager()134 pm = ProteinManager()135 ps = ProteinSystem(dm, rm, pm)136 tk.Frame.__init__(self, master)137 tk.Label(self, text="Input DNA sequence without any spaces").pack(138 side="top",139 pady=20)140 entry = tk.Entry(self, width=50)141 entry.pack()142 label = ttk.Label(self, text="")143 label.pack()144 convert = tk.Button(self, text="Convert",145 command=lambda:146 [label.config(text=ps.get_protein(entry.get()),147 wraplengt=500),148 copied.config(text="")])149 convert.pack()150 copy = tk.Button(self, text="Copy",151 command=lambda: [master.copy_to_clipboard(152 label.cget("text")),153 copied.config(text="Copied to Clipboard")])154 copy.pack()155 tk.Button(self, text="Return to main page",156 command=lambda: master.frame_switch(MainPage)).pack()157 copied = tk.Label(self, text="")158 copied.pack(pady=10)159class SequenceComparison(tk.Frame):160 def __init__(self, master):161 tk.Frame.__init__(self, master)162 tk.Label(self, text="Choose the type of sequence you would like to "163 "compare through global alignment"164 "").pack(side="top", fill="x", pady=20)165 tk.Button(self, text="DNA",166 command=lambda: master.frame_switch(DNACompare)).pack()167 tk.Button(self, text="RNA",168 command=lambda: master.frame_switch(RNACompare)).pack()169 tk.Button(self, text="Protein",170 command=lambda: master.frame_switch(ProteinCompare)).pack()171 tk.Button(self, text="Return to main page",172 command=lambda: master.frame_switch(MainPage)).pack()173class DNACompare(tk.Frame):174 def __init__(self, master):175 label_font = tk.font.Font(family="Courier New", size=8)176 dm = DnaManager()177 rm = RnaManager()178 pm = ProteinManager()179 ps = ProteinSystem(dm, rm, pm)180 tk.Frame.__init__(self, master)181 tk.Label(self, text="Input 1st DNA sequence without any spaces").pack(182 side="top",183 pady=10)184 entry1 = tk.Entry(self, width=50)185 entry1.pack()186 tk.Label(self, text="Input 2nd DNA sequence without any spaces").pack(187 side="top",188 pady=10)189 entry2 = tk.Entry(self, width=50)190 entry2.pack()191 label = ttk.Label(self, text="")192 label.pack(anchor='w')193 label.config(font=label_font)194 align = tk.Button(self, text="Align",195 command=lambda:196 [label.config(197 text=ps.compare_dna(entry1.get(),198 entry2.get(199 )),200 wraplengt=500)])201 align.pack()202 tk.Button(self, text="Return to main page",203 command=lambda: master.frame_switch(MainPage)).pack()204class RNACompare(tk.Frame):205 def __init__(self, master):206 label_font = tk.font.Font(family="Courier New", size=8)207 dm = DnaManager()208 rm = RnaManager()209 pm = ProteinManager()210 ps = ProteinSystem(dm, rm, pm)211 tk.Frame.__init__(self, master)212 tk.Label(self, text="Input 1st RNA sequence without any spaces").pack(213 side="top",214 pady=10)215 entry1 = tk.Entry(self, width=50)216 entry1.pack()217 tk.Label(self, text="Input 2nd RNA sequence without any spaces").pack(218 side="top",219 pady=10)220 entry2 = tk.Entry(self, width=50)221 entry2.pack()222 label = ttk.Label(self, text="")223 label.pack(anchor='w')224 label.config(font=label_font)225 align = tk.Button(self, text="Align",226 command=lambda:227 [label.config(228 text=ps.compare_rna(entry1.get(),229 entry2.get(230 )),231 wraplengt=500)])232 align.pack()233 tk.Button(self, text="Return to main page",234 command=lambda: master.frame_switch(MainPage)).pack()235class ProteinCompare(tk.Frame):236 def __init__(self, master):237 label_font = tk.font.Font(family="Courier New", size=8)238 dm = DnaManager()239 rm = RnaManager()240 pm = ProteinManager()241 ps = ProteinSystem(dm, rm, pm)242 tk.Frame.__init__(self, master)243 tk.Label(self, text="Input 1st protein sequence without any"244 " spaces").pack(245 side="top",246 pady=10)247 entry1 = tk.Entry(self, width=50)248 entry1.pack()249 tk.Label(self, text="Input 2nd protein sequence without any "250 "spaces").pack(251 side="top",252 pady=10)253 entry2 = tk.Entry(self, width=50)254 entry2.pack()255 label = ttk.Label(self, text="")256 label.pack(anchor='w')257 label.config(font=label_font)258 align = tk.Button(self, text="Align",259 command=lambda:260 [label.config(261 text=ps.compare_protein(entry1.get(),262 entry2.get(263 )),264 wraplengt=500)])265 align.pack()266 tk.Button(self, text="Return to main page",267 command=lambda: master.frame_switch(MainPage)).pack()268if __name__ == "__main__":269 app = MainApp()...

Full Screen

Full Screen

11st.py

Source:11st.py Github

copy

Full Screen

...7from selenium.webdriver.support import expected_conditions as EC8from selenium.webdriver.support.ui import WebDriverWait9from tqdm import tqdm10from util.driver import driver11def frame_switch(name: str) -> None:12 while True:13 try:14 if name == "default":15 driver.switch_to.default_content()16 else:17 driver.switch_to.frame(name)18 break19 except:20 pass21def make_folder():22 global save_dir23 save_dir = os.path.join("data", os.getenv("NAME"))24 if not os.path.isdir(save_dir):25 os.makedirs(save_dir)26def image_confirm(img_url: str):27 image_nparray = np.asarray(bytearray(requests.get(img_url).content), dtype=np.uint8)28 image = cv2.imdecode(image_nparray, cv2.IMREAD_COLOR)29 if image.shape[0] > 1280 or image.shape[1] > 720:30 image_resize = cv2.resize(image, dsize=(0, 0), fx=0.5, fy=0.5, interpolation=cv2.INTER_LINEAR)31 image = image_resize32 cv2.imshow("Image", image)33 input = cv2.waitKey(0)34 if input == int(os.getenv("KEY")):35 dirListing = os.listdir(save_dir)36 cv2.imwrite(os.path.join(save_dir, f"{str(len(dirListing)+1)}.png"), image)37def main():38 driver.get(os.getenv("KEYWORD")) # 크롤링 링크39 time.sleep(3)40 frame_switch("ifrmReview")41 add_more = driver.find_element(By.XPATH, '//*[@id="allPhotoReviewList"]')42 driver.execute_script("arguments[0].click();", add_more)43 frame_switch("default")44 followers_panel = driver.find_element(By.XPATH, '//*[@id="photo-review-scroll"]')45 count = 046 while True:47 try:48 img_datas = driver.find_elements(By.XPATH, '//*[@id="photo-review-paged-list"]/li/button')49 before = len(img_datas)50 if count > 5:51 break52 driver.execute_script("arguments[0].scrollTop = arguments[0].scrollHeight", followers_panel)53 time.sleep(0.1)54 img_datas = driver.find_elements(By.XPATH, '//*[@id="photo-review-paged-list"]/li/button')55 if len(img_datas) <= before:56 count += 157 else:...

Full Screen

Full Screen

meteor.py

Source:meteor.py Github

copy

Full Screen

1import pygame2from enemy_object import EnemyObject,resize3import os4def get_meteor_images(size=100):5 directory = os.path.join('assets','meteor_images')6 7 images = []8 for file_ in os.listdir(directory):9 full_path = os.path.join(directory,file_)10 image = pygame.image.load(full_path).convert_alpha()11 image = pygame.transform.scale(image,(size,size))12 images.append(image)13 return images14class Meteor(EnemyObject):15 images = get_meteor_images()16 def __init__(self,screen_width,screen_height,speed=4,frame_switch=10,damage=20,size=-1,hits=4):17 self.image = self.images[0]18 super().__init__(screen_width,screen_height,speed,damage,hits)19 self.image_index = 020 self.frame_count = 021 self.frame_switch = frame_switch22 self.damage = damage23 def update(self):24 super().update()25 self.frame_count += 126 if self.frame_count == self.frame_switch:27 self.frame_count = 028 self.image_index = (self.image_index + 1) % len(self.images)...

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