How to use cliquer method in SeleniumBase

Best Python code snippet using SeleniumBase

Cliquer_file.py

Source:Cliquer_file.py Github

copy

Full Screen

1import pandas as pd2import numpy as np3import multiprocessing4import time 5import os6import argparse7#Path1 = '/home/rhuang06/Documents/Annotation_pipeline/Proccessed_Data/ORTH'8#Path2 = "/home/rhuang06/Documents/Annotation_pipeline"9#ori_Path = Path2 + "/" +"Proccessed_Data" + "/" + "Fuse_Orth_file" + "/" + "Fuse_orth_file.csv"10#index_Path = Path2 + "/" +"Proccessed_Data" + "/" + "Fuse_Orth_file" + "/" + "Cliquer_index_file.csv"11#Path3 = Path2 + "/" +"Proccessed_Data" + "/" + "Fuse_Orth_file"12# parsing the arguments and warning message13ap = argparse.ArgumentParser(description="Translate Ortholog gene ID to number index based on index file with multipleprocessing")14ap.add_argument("-path",required=False,15 help="Path of folder that containing all folders that have all Orthologues")16ap.add_argument("-outpath",required=False,17 help="Path of directory you want to put output files")18ap.add_argument("-n", required = False, help = "Number of processes for multiple processing")19args = vars(ap.parse_args())20Path1 = args["path"]21Path2 = args["outpath"]22Path1 = '/home/rhuang06/Documents/Annotation_pipeline/Proccessed_Data/ORTH'23Path2 = "/home/rhuang06/Documents/Annotation_pipeline"24Path3 = Path2 + "/" +"Proccessed_Data" + "/" + "Fuse_Orth_file"25#Transfer ortholog ID to number index based on index file26def transfer(item): 27 Path = Path328 index_df = pd.read_csv(Path + "/Cliquer_index_file.csv", engine= "python")29 index_dict = dict(zip(index_df["Gene stable ID"],index_df["Number"]))30 file_list = os.listdir(Path + "/Reduced_orth")31 file_abspath_list = list()32 for f in file_list:33 f_absname = Path + "/Reduced_orth/" + f34 file_abspath_list.append(f_absname) 35 print("Processing " + "file " + os.path.basename(file_abspath_list[item]))36 with open(file_abspath_list[item],"r") as h:37 ori_file = h.readlines()38 #ori_df = pd.read_csv(file_abspath_list[item], engine= "python")39 name = os.path.basename(file_abspath_list[item])40 #number_list = []41 '''for id in range(ori_df.shape[0]):42 orth = list(ori_df.iloc[id,:])43 index1 = index_df.loc[index_df["Gene stable ID"] == orth[0]]44 index2 = index_df.loc[index_df["Gene stable ID"] == orth[1]]45 index1 = index1.values46 index1 = index1.tolist()47 index2 = index2.values48 index2 = index2.tolist()49 number = ["e",index1[0][1],index2[0][1]] #1:gene id 2:orth gene id 50 number_list.append(number)''' 51 cliq_file = open(Path + "/" + "file" + "/Cliquer_temp_" + name, "w+")52 for num,id in enumerate(ori_file):53 id_line = id.split(",")54 id_line = [id_line[0],id_line[1].strip("\n")]55 #print(id_line)56 if num != 0:57 cliq_line = "e,{},{}\n".format(index_dict[id_line[0]],index_dict[id_line[1]])58 else:59 cliq_line = ""60 cliq_file.write(cliq_line)61 cliq_file.close()62 63 #number_df = pd.DataFrame(number_list)64 #number_df.to_csv(Path + "/" + "file" + "/Cliquer_temp_" + name,index = None, header= False)65 print("file" + os.path.basename(file_abspath_list[item]) +" finished")66#Transfer ortholog ID to number index based on index file67def transfer_one(item): 68 Path = Path369 index_df = pd.read_csv(Path + "/Cliquer_index_one_file.csv", engine= "python")70 index_dict = dict(zip(index_df["Gene stable ID"],index_df["Number"]))71 file_list = os.listdir(Path + "/Reduced_one2one_orth")72 file_abspath_list = list()73 for f in file_list:74 f_absname = Path + "/Reduced_one2one_orth/" + f75 file_abspath_list.append(f_absname)76 print("Processing " + "file " + os.path.basename(file_abspath_list[item]))77 with open(file_abspath_list[item],"r") as h:78 ori_file = h.readlines()79 name = os.path.basename(file_abspath_list[item])80 cliq_file = open(Path + "/" + "one_file" + "/Cliquer_one_temp_" + name, "w+")81 for num,id in enumerate(ori_file):82 id_line = id.split(",")83 id_line = [id_line[0],id_line[1].strip("\n")]84 #print(id_line)85 if num != 0:86 cliq_line = "e,{},{}\n".format(index_dict[id_line[0]],index_dict[id_line[1]])87 else:88 cliq_line = ""89 cliq_file.write(cliq_line)90 cliq_file.close() 91 #number_df = pd.DataFrame(number_list)92 #number_df.to_csv(Path + "/" + "one_file" + "/Cliquer_one_temp_" + name,index = None, header= False)93 print("file " + os.path.basename(file_abspath_list[item]) +" finished")94def fuse_file(path,mode):95 if mode == "all":96 files = os.listdir(path + "/" + "file")97 files.sort()98 fuse = pd.DataFrame()99 print("\nFuse files")100 for file in files:101 df = pd.read_csv(path + "/" + "file" + "/" + file, header= None)102 fuse = fuse.append(df)103 fuse.to_csv(path + "/" + "Cliquer_temp_file.csv", index = False, header = False)104 elif mode == "one":105 files = os.listdir(path + "/" + "one_file")106 files.sort()107 fuse = pd.DataFrame()108 print("\nFuse files")109 for file in files:110 df = pd.read_csv(path + "/" + "one_file" + "/" + file, header= None)111 fuse = fuse.append(df)112 fuse.to_csv(path + "/" + "Cliquer_temp_one_file.csv", index = False, header = False)113def top_line(path,out,mode):114 if mode == "all":115 df = pd.read_csv(path, header = None)116 column1 = df.iloc[:,1]117 column2 = df.iloc[:,2]118 column = column1.append(column2)119 column = column.drop_duplicates()120 number_node = column.shape[0]121 number_edge = df.shape[0]122 df2 = pd.DataFrame([["p",number_node,number_edge]])123 df2 = df2.append(df)124 df2.to_csv(out + "/" + "Final_Cliquer_file.csv", index = None, header =False)125 elif mode == "one":126 df = pd.read_csv(path, header = None)127 column1 = df.iloc[:,1]128 column2 = df.iloc[:,2]129 column = column1.append(column2)130 column = column.drop_duplicates()131 number_node = column.shape[0]132 number_edge = df.shape[0]133 df2 = pd.DataFrame([["p",number_node,number_edge]])134 df2 = df2.append(df)135 df2.to_csv(out + "/" + "Final_Cliquer_one_file.csv", index = None, header =False)136 137def final_process(path,mode):138 if mode == "all":139 file = open(path + "/" + "Final_Cliquer_file.csv", "r")140 data = file.read()141 data = data.replace(","," ")142 with open(path + "/" + "Final_Cliquer_file.csv", "w+") as f:143 f.write(data)144 os.rename(path + "/" + "Final_Cliquer_file.csv", path + "/" + "Final_Cliquer_file.txt")145 elif mode == "one":146 file = open(path + "/" + "Final_Cliquer_one_file.csv", "r")147 data = file.read()148 data = data.replace(","," ")149 with open(path + "/" + "Final_Cliquer_one_file.csv", "w+") as f:150 f.write(data)151 os.rename(path + "/" + "Final_Cliquer_one_file.csv", path + "/" + "Final_Cliquer_one_file.txt")152def add_name(path,mode):153 if mode == "all":154 file = open(path + "/" + "Final_Cliquer_file.txt", "r")155 data = file.readline()156 data = data.split(" ")157 data.insert(1,"animal")158 data[0] = data[0] + " "159 data[1] = data[1] + " "160 data[2] = data[2] + " "161 data = "".join(data)162 oline = file.readlines()163 oline.insert(0,data)164 file = open(path + "/" + "Final_Cliquer_file.txt", "w")165 file.writelines(oline)166 file.close()167 elif mode == "one":168 file = open(path + "/" + "Final_Cliquer_one_file.txt", "r")169 data = file.readline()170 data = data.split(" ")171 data.insert(1,"animal")172 data[0] = data[0] + " "173 data[1] = data[1] + " "174 data[2] = data[2] + " "175 data = "".join(data)176 oline = file.readlines()177 oline.insert(0,data)178 file = open(path + "/" + "Final_Cliquer_one_file.txt", "w")179 file.writelines(oline)180 file.close()181#code for all orthologs182'''if __name__ == '__main__':183 start_time = time.time()184 length = os.listdir(Path3 + "/Reduced_orth")185 if not os.path.exists(Path3 + "/" + "file"):186 os.mkdir(Path3 + "/" + "file")187 pool = multiprocessing.Pool(processes=8) 188 pool.map(transfer,range(len(length)))189 pool.close()190 fuse_file(Path3,"all")191 top_line(Path3 + "/" + "Cliquer_temp_file.csv", Path3,"all")192 final_process(Path3,"all")193 add_name(Path3,"all")194 end_time = time.time() - start_time195 print("In total cost " + str((end_time/60)) + " mins")'''196#code for one to one orthologs197if __name__ == '__main__':198 start_time = time.time()199 length = os.listdir(Path3 + "/Reduced_one2one_orth")200 if not os.path.exists(Path3 + "/" + "one_file"):201 os.mkdir(Path3 + "/" + "one_file")202 pool = multiprocessing.Pool(processes=7) 203 pool.map(transfer_one,range(len(length)))204 pool.close()205 fuse_file(Path3,"one")206 top_line(Path3 + "/" + "Cliquer_temp_one_file.csv", Path3, "one")207 final_process(Path3,"one")208 add_name(Path3,"one")209 if os.path.exists(Path3 + "/" + "Cliquer_temp_one_file.csv") is True:210 os.remove(Path3 + "/" + "Cliquer_temp_one_file.csv")211 if os.path.exists(Path3 + "/" + "Cliquer_temp_file.csv") is True:212 os.remove(Path3 + "/" + "Cliquer_temp_file.csv")213 end_time = time.time() - start_time...

Full Screen

Full Screen

GestionAlertes.py

Source:GestionAlertes.py Github

copy

Full Screen

1# Test Cases2# 1- Importer webdriver3# 2- Créer une instance de Chrome et agrandir la fenêtre4# 3- Ouvrir la page https://the-internet.herokuapp.com/javascript_alerts5# 4- Fenêtre principale : Cliquer sur le bouton Alert6# 5- Passer à la fenêtre d'Alerte7# 6- Alerte : Récupérer le message de la fenêtre d'Alerte8# 7- Alerte : Cliquer sur OK9# 8- Fenêtre principale : Imprimer le message affiché result10# 9- Fenêtre principale : Cliquer sur le 2ième bouton11# 10- Passer à la fenêtre de Confirmation12# 11- Confirmation : Récupérer le message de la fenêtre de Confirmation13# 12- Confirmation : Cliquer sur Annuler14# 13- Fenêtre principale : Imprimer le message affiché result15# 14- Fenêtre principale : Cliquer sur le bouton dont le texte est 'Click for JS Prompt'16# 15- Passer à la fenêtre de Prompt17# 16- Prompt : Récupérer le message de la fenêtre de prompt18# 17- Prompt : Saisir 'hoooohooooo'19# 18- Prompt : accepter20# 19- Fenêtre principale : Imprimer le message affiché result21# 20- Fermer toutes les fenêtres22import time23# 1- Importer webdriver24from selenium import webdriver25from selenium.webdriver.common.by import By26# 2- Créer une instance de Chrome et agrandir la fenêtre27driver = webdriver.Chrome()28driver.maximize_window()29# 3- Ouvrir la page https://the-internet.herokuapp.com/javascript_alerts30driver.get('https://the-internet.herokuapp.com/javascript_alerts')31# 4- Fenêtre principale : Cliquer sur le bouton Alert32driver.find_element(By.XPATH, "//button[contains(text(), 'Alert')]").click()33# 5- Passer à la fenêtre d'Alerte34alert_window = driver.switch_to.alert35# 6- Alerte : Récupérer le message de la fenêtre d'Alerte36print("le texte de l'alerte est : ", alert_window.text)37time.sleep(1)38# 7- Alerte : Cliquer sur OK39alert_window.accept()40# 8- Fenêtre principale : Imprimer le message affiché result41print(driver.find_element(By.ID, "result").text)42time.sleep(1)43# 9- Fenêtre principale : Cliquer sur le 2ième bouton44driver.find_element(By.XPATH, "(//button)[2]").click()45# 10- Passer à la fenêtre de Confirmation46confirm_window = driver.switch_to.alert47# 11- Confirmation : Récupérer le message de la fenêtre de Confirmation48print("texte de la confirmation : ", confirm_window.text)49time.sleep(1)50# 12- Confirmation : Cliquer sur Annuler51confirm_window.dismiss()52time.sleep(1)53# 13- Fenêtre principale : Imprimer le message affiché result54print(driver.find_element(By.ID, "result").text)55# 14- Fenêtre principale : Cliquer sur le bouton dont le texte est 'Click for JS Prompt'56driver.find_element(By.XPATH, "//button[text()='Click for JS Prompt']").click()57# 15- Passer à la fenêtre de Prompt58prompt_window = driver.switch_to.alert59# 16- Prompt : Récupérer le message de la fenêtre de prompt60print("message prompt : ", prompt_window.text)61# 17- Prompt : Saisir 'hoooohooooo'62prompt_window.send_keys('hoooohooooo')63time.sleep(2)64# 18- Prompt : accepter65prompt_window.accept()66# 19- Fenêtre principale : Imprimer le message affiché result67print(driver.find_element(By.ID, "result").text)68time.sleep(2)69# 20- Fermer toutes les fenêtres...

Full Screen

Full Screen

exercice01.py

Source:exercice01.py Github

copy

Full Screen

1# test case2# 1 lancer navigateur3# 2 acceder a l adresse "https://www.saucedemo.com/"4# 3 saisir username5# 4 saisir password6# 5 cliquer sur login7# 6 cliquer sur add to cart8# 7 cliquer sur panier9# 8 cliquer sur ckekout10# 9 saisir firstname11# 10 saisir last name12# 11 saisir code postal13# 12 cliquer sur cancel14import time15from selenium import webdriver16#instance vide de chrome17from selenium.webdriver.common.by import By18# 1 lancer le navigateur19driver = webdriver.Chrome()20#ouvrir la fenetre en plein ecran21driver.maximize_window()22# 2 acceder a l "adresse https://www.saucedemo.com/"23driver.get("https://www.saucedemo.com/")24# 3 saisir username25driver.find_element(By.ID, "user-name").send_keys("standard_user")26# 4 saisir password27driver.find_element(By.NAME, "password").send_keys("secret_sauce")28# 5 cliquer sur login29driver.find_element(By.NAME, "login-button").submit()30# 6 cliquer sur add to cart31driver.find_element(By.ID, "add-to-cart-sauce-labs-backpack").click()32# 7 cliquer sur panier33driver.find_element(By.CLASS_NAME, "shopping_cart_link").click()34# 8 cliquer sur ckekout35driver.find_element(By.NAME, "checkout").click()36# 9 saisir firstname37driver.find_element(By.ID, "first-name").send_keys("Ines")38# 10 saisir last name39driver.find_element(By.ID, "last-name").send_keys("ksibi")40# 11 saisir code postal41driver.find_element(By.NAME, "postalCode").send_keys("J4W2W5")42# 12 cliquer sur cancel43driver.find_element(By.NAME, "cancel").click()44#mettre du temps d arret45time.sleep(4)46#fermeture du navigateu...

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