Best Python code snippet using webdriver_manager
driver_cache.py
Source: driver_cache.py
...21 archive = save_file(file, path)22 files = archive.unpack(path)23 binary = self.__get_binary(files, driver_name)24 binary_path = os.path.join(path, binary)25 self.__save_metadata(browser_version, driver_name, os_type, driver_version, binary_path)26 log(f"Driver has been saved in cache [{path}]")27 return binary_path28 def __get_binary(self, files, driver_name):29 if len(files) == 1:30 return files[0]31 for f in files:32 if driver_name in f:33 return f34 raise Exception(f"Can't find binary for {driver_name} among {files}")35 def __save_metadata(self, browser_version, driver_name, os_type, driver_version, binary_path,36 date=None):37 if date is None:38 date = datetime.date.today()39 metadata = self.get_metadata()40 key = f"{os_type}_{driver_name}_{driver_version}_for_{browser_version}"41 data = {42 key: {43 "timestamp": date.strftime(self._date_format),44 "binary_path": binary_path45 }46 }47 metadata.update(data)48 with open(self._drivers_json_path, 'w+') as outfile:49 json.dump(metadata, outfile, indent=4)...
frame_list__.py
Source: frame_list__.py
...17 def __get_metadata(self, filepath) -> dict:18 with open(self.__get_json_filepath(filepath)) as file:19 return json.load(file)20 21 def __save_metadata(self, frame:Frame) -> None:22 json_filepath = self.__get_json_filepath(frame.filepath)23 with open(json_filepath,'w') as f:24 json.dump(frame.metadata, f)25 def __remove_metadata(self, filepath) -> None:26 os.remove(self.__get_json_filepath(filepath))27 def __len__(self) -> int:28 return len(self.__filepathlist)29 def __getitem__(self, ii) -> Frame:30 filepath = self.__filepathlist[ii]31 metadata = self.__get_metadata(filepath)32 frame_arr = img_to_array(load_img(filepath), dtype='uint8')33 return Frame(frame_arr=frame_arr, metadata=metadata, filepath=filepath)34 def __delitem__(self, ii) -> None:35 filepath = self.__filepathlist[ii]36 #remove jpg imgage37 os.remove(filepath)38 #remove json imgage data39 self.__remove_metadata(filepath)40 del self.__filepathlist[ii]41 def __setitem__(self, ii, frame:Frame) -> None:42 #use it to update only metadata43 if self.__filepathlist[ii] == frame.filepath:44 self.__save_metadata(frame)45 else:46 raise NameError('Error in FrameList.__setitem__')47 def append(self, frame:Frame) -> None:48 frame.filepath = os.path.join(self.__pathdir, '%s.jpg'%int(time.time()))49 self.__filepathlist.append(frame.filepath)50 self.__save_metadata(frame)51 img = img_to_array(frame.original)52 save_img(frame.filepath, img)53 def insert(self, index: int, frame: Frame) -> None:54 frame.filepath = os.path.join(self.__pathdir, '%s.jpg'%int(time.time()))55 self.__filepathlist.insert(index, frame.filepath)56 self.__save_metadata(frame)57 img = img_to_array(frame.original)58 save_img(frame.filepath, img)59 60 def remove(self, frame: Frame) -> None:61 i = self.index(frame)62 self.__delitem__(i)63 def index(self, frame: Frame) -> int:64 for i in range(len(self.__filepathlist)):65 if self.__filepathlist[i] == frame.filepath:66 return i67 else:...
Check out the latest blogs from LambdaTest on this topic:
The automation backend architecture of Appium has undergone significant development along with the release of numerous new capabilities. With the advent of Appium, test engineers can cover mobile apps, desktop apps, Flutter apps, and more.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.
Hey Folks! Welcome back to the latest edition of LambdaTest’s product updates. Since programmer’s day is just around the corner, our incredible team of developers came up with several new features and enhancements to add some zing to your workflow. We at LambdaTest are continuously upgrading the features on our platform to make lives easy for the QA community. We are releasing new functionality almost every week.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!