Best Python code snippet using webdriver_manager
driver_mgmt.py
Source: driver_mgmt.py
...47 self._conn = None48 except:49 pass50 51 def find_driver(self,productType,version):52 try:53 tcontent =(productType,version)54 self._cur.execute("select * from drivers_table where productType=? and version=?;", tcontent)55 return self._cur.fetchone()56 except:57 return None58 def find_driverbyid(self,id):59 try:60 tcontent =(id,)61 self._cur.execute("select * from drivers_table where id = ?;", tcontent)62 line = self._cur.fetchone()63 if (line is not None):64 return line[PROCDUCTTYPE],line[VERSION],line[MODULENAME]65 return None,None,None66 except:67 return None,None,None68 def add_driver(self,productType,version,modulename):69 try:70 71 tcontent =(productType,version,modulename)72 sql_state="insert into drivers_table(productType,version,modulename) values (?,?,?);" 73 if self.find_driver(productType,version)!=None:74 tcontent =(productType,version,modulename,productType,version)75 sql_state='update drivers_table set productType=?,version=?,modulename=? where productType=? and version=? ;'76 self._conn.execute(sql_state, tcontent)77 self._conn.commit()78 return True79 except:80 return False81 82 def show_drivers(self):83 try:84 res=self._cur.execute("select * from drivers_table;")85 for line in res:86 print line87 return None88 except:89 return None 90 91 def getAllDriverInfo(self):92 try:93 c=self._cur.execute("select distinct * from drivers_table;")94 res=c.fetchall()95 namelist=[]96 count=097 for line in res:98 count=count+199 namelist.append({'id': line[0], 'productType':line[1],'version':line[2],'driverFile':line[3]})100 return namelist101 except:102 return namelist103 104 def delete_driver_id(self, sid):105 try:106 tcontent =(sid,)107 sql_state='delete from drivers_table where id=?;'108 self._conn.execute(sql_state, tcontent)109 self._conn.commit()110 return True111 except:112 return False113 114 def delete_driver(self, productType,version):115 try:116 line=self.find_driver(productType,version)117 if line== None:118 return False119 tcontent =(line[0],)120 sql_state='delete from drivers_table where id=?;' 121 self._conn.execute(sql_state, tcontent)122 self._conn.commit()123 return True124 except:125 return False126 127def getdriverinfo(db,productType,version):128 try:129 dm=driver_mgmt(db)130 line=dm.find_driver(productType, version)131 if line == None:132 return None133 else:134 return line[MODULENAME]135 except:136 return None137 138if __name__ == '__main__':139 #===========================================================================140 # Unit test samples141 #===========================================================================142 dm = driver_mgmt(None,'D:/OPS2.db')143 dm.add_driver('NE5000E', '1.0', 'xxx_Driver.py')144 dm.delete_driver('NE5000E', '1.0')145 dm.show_drivers()146 print dm.find_driver('NE5000E', '1.0')...
test_driver.py
Source: test_driver.py
...29 def test_find(self):30 """31 Test driver finding32 """33 drv = find_driver(Simulator, 'dummy')34 self.assertTrue(drv is not None)35 def test_not_implemented(self):36 """37 Test exception on not implemented functionality38 """39 class C: pass # dummy does not implement C interface40 drv = find_driver(C, 'dummy')41 self.assertTrue(drv is None)42 def test_unknown_driver(self):43 """44 Test exception on unknown driver45 """46 self.assertRaises(DeviceError, find_driver, Simulator, 'unknown')...
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!!