Best Python code snippet using webdriver_manager
get_browser_driver.py
Source:get_browser_driver.py
...46 elif str(type).lower()=="edge":47 get_edge_driver(type)48def get_chrome_driver(type):49 check_folder()50 version_num=get_browser_version(type)51 # chrome_driveré£çµ52 print("chrome_driveré£çµ...")53 driver_url = str(config.get('driver','chrome_driver_url'))54 r = requests.get(driver_url)55 objSoup = BeautifulSoup(r.text, 'lxml')56 objTag = objSoup.find('td', 'sites-layout-tile sites-tile-name-content-1').find('div').find('div').find_all('li')57 print("æ¬æ©ä½æ¥ç³»çµ±:", sys.platform)58 for i in objTag:59 try:60 target_url = None61 if version_num.split('.')[0].split('=')[1] in i.find('span').text:62 driver_download_url = i.find('a').get('href')63 print(driver_download_url)64 if sys.platform == 'win32':65 # windows66 target_url = str(driver_download_url).split('index.html?')[0] + str(driver_download_url).split('path=')[1] + 'chromedriver_win32.zip'67 print("chrome_driveré£çµ...å®æ")68 download_driver(target_url, 'chromedriver_win32.zip', type)69 print("driverä¸è¼...å®æ")70 except:71 pass72def get_firefox_driver(type):73 check_folder()74 version_num = get_browser_version(type)75 print("firefoxé£çµ...")76 print("æ¬æ©ä½æ¥ç³»çµ±:", sys.platform)77 driver_url=str(config.get('driver','firefox_driver_url'))78 print(driver_url)79 r = requests.get(driver_url)80 objSoup = BeautifulSoup(r.text, 'lxml')81 objTag = objSoup.find('div', 'f1 flex-auto min-width-0 text-normal').text.strip()82 target_url = None83 if sys.platform == 'win32':84 target_url = driver_url+'/download/v' + objTag + '/geckodriver-v' + objTag + '-win64.zip'85 print("firefox_driveré£çµ...å®æ")86 download_driver(target_url, 'firefox_win64.zip', type)87 print("driverä¸è¼...å®æ")88def get_edge_driver(type):89 check_folder()90 version_num = get_browser_version(type).split('=')[1]91 # edge_driveré£çµ92 print("edege_driveré£çµ...")93 print("æ¬æ©ä½æ¥ç³»çµ±:", sys.platform)94 driver_url = str(config.get('driver', 'edge_driver_url'))95 print(driver_url)96 target_url = driver_url + version_num + '/'97 if sys.platform == 'win32':98 target_url += 'edgedriver_win64.zip'99 print("edge_driveré£çµ...å®æ")100 download_driver(target_url, 'edgedriver_win64.zip', type)101 print("driverä¸è¼...å®æ")102if __name__ == '__main__':103 get_chrome_driver()104 print('-'*10)...
ie.py
Source:ie.py
...23 self._ie_release_tag = ie_release_tag24 # todo: for 'browser_version' implement installed IE version detection25 # like chrome or firefox26 def get_latest_release_version(self) -> str:27 log(f"Get LATEST driver version for {self.get_browser_version()}")28 resp = self._http_client.get(29 url=self.latest_release_url,30 headers=self.auth_header31 )32 releases = resp.json()33 release = next(34 release35 for release in releases36 for asset in release["assets"]37 if asset["name"].startswith(self.get_name())38 )39 self._version = release["tag_name"].replace("selenium-", "")40 return self._version41 def get_url(self):42 """Like https://github.com/seleniumhq/selenium/releases/download/3.141.59/IEDriverServer_Win32_3.141.59.zip"""43 log(f"Getting latest ie release info for {self.get_version()}")44 resp = self._http_client.get(45 url=self.tagged_release_url(self.get_version()),46 headers=self.auth_header47 )48 assets = resp.json()["assets"]49 name = f"{self.get_name()}_{self.os_type}_{self.get_version()}" + "."50 output_dict = [51 asset for asset in assets if asset["name"].startswith(name)]52 return output_dict[0]["browser_download_url"]53 @property54 def latest_release_url(self):55 return self._latest_release_url56 def tagged_release_url(self, version):57 version = self.__get_divided_version(version)58 return self._ie_release_tag.format(version)59 def __get_divided_version(self, version):60 divided_version = version.split(".")61 if len(divided_version) == 2:62 return f"{version}.0"63 elif len(divided_version) == 3:64 return version65 else:66 raise ValueError(67 "Version must consist of major, minor and/or patch, "68 "but given was: '{version}'".format(version=version)69 )70 def get_browser_type(self):71 return "msie"72 def get_browser_version(self):73 try:74 return super().get_browser_version()75 except:...
opera.py
Source:opera.py
...40 def tagged_release_url(self, version):41 return self.opera_release_tag.format(version)42 def get_browser_type(self):43 return "opera"44 def get_browser_version(self):45 try:46 return super().get_browser_version()47 except:...
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!!