Best Python code snippet using selene_python
Race.py
Source:Race.py
1import Driver2import Player3import py_conf4class Race:5 def __init__(self, p_name):6 self.name = p_name7 self.players = []8 self.drivers = []9 point_scale = {'1': 25, '2': 18, '3': 15, '4': 12, '5': 10, '6': 8, '7': 6, '8': 4, '9': 2, '10': 1}10 def __str__(self):11 return self.name12 @staticmethod13 def is_number(s):14 try:15 int(s)16 return True17 except ValueError:18 return False19 def populate_driver_list(self):20 for line in open(py_conf.driver_csv):21 first_name, last_name, team, number = line.split(',')22 self.drivers.append(Driver.Driver(first_name, last_name, team, number.rstrip()))23 def is_driver_num(self, driver_num):24 is_driver = False25 return_driver = Driver26 for driver in self.drivers:27 if driver.number == driver_num:28 return_driver = driver29 is_driver = True30 break31 return is_driver, return_driver32 def cmdln_pick_drivers(self):33 entered_num = False34 while entered_num is False:35 num_drivers = raw_input("How many drivers will each player pick?: ")36 if self.is_number(num_drivers):37 entered_num = True38 num_drivers = int(num_drivers)39 pop_drivers_list = self.drivers40 while num_drivers > 0:41 for player in self.players:42 picked_driver = False43 while picked_driver is False:44 print '\n\n\n'45 for driver in pop_drivers_list:46 print driver.number + ' ' + driver.first_name + ' ' + driver.last_name47 selection = raw_input('\n' + player.name + ' Select a driver by number: ')48 is_driver_ret = Race.is_driver_num(self, selection)49 if is_driver_ret[0] is True:50 player.driver_list.append(is_driver_ret[1])51 picked_driver = True52 for index, pop_driver in enumerate(pop_drivers_list):53 if is_driver_ret[1] == pop_driver:54 pop_drivers_list.pop(index)55 num_drivers -= 156 def cmdln_set_players(self):57 get_number = True58 while get_number:59 num_players = raw_input('Enter number of players: ')60 if Race.is_number(num_players):61 get_number = False62 else:63 print "Please enter a number"64 for num in range(1, int(num_players)+1):65 question_string = 'Enter player ' + str(num) + ' name: '66 self.players.append(Player.Player(raw_input(question_string)))67 def cmdln_show_player_selection(self):68 for player in self.players:69 print "\n" + player.name + ':'70 for driver in player.driver_list:...
android_capability.py
Source:android_capability.py
...5 platformName='Android',6 platformVersion='9',7 automationName='uiautomator2',8 deviceName='Pixel 2 API 28 2')9def return_driver(caps):10 driver = webdriver.Remote('http://localhost:4723/wd/hub', caps)11 return driver12def des_cap_youtube():13 desired_caps = dict(14 # platformName='Android',15 # platformVersion='9',16 # automationName='uiautomator2',17 # deviceName='Pixel 2 API 28 2',18 common_cap_dict,19 appPackage='com.google.android.youtube',20 appActivity='com.google.android.apps.youtube.app.WatchWhileActivity')21 # driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)22 # return driver23 return return_driver(desired_caps)24def des_cap_learn_android_using_source_code():25 desired_caps = dict(26 common_cap_dict,27 # appPackage='com.tutorials.learn.androidexample',28 # appActivity='com.tutorials.learn.androidexample.MainActivity')29 app='/Users/localadmin/Downloads/APK/Learn_Android_With_Source.apk')...
staginglogin.py
Source:staginglogin.py
2"""3 This function opens zipstg.com by entering neccessary password for access4"""5def staging_login():6 #driver = driversetup.return_driver() # if you use 'import driversetup'7 driver = return_driver() # if you use 'from driversetup import return_driver, close_driver8 driver.get("http://www.zipstg.com")9 #pwd = driver.find_element_by_name("devserver")10 #pwd.send_keys("zipballgame")11 cookie = {'name' : 'closed_tos_update', 'value' : '1'}12 driver.add_cookie(cookie)13 #submit = driver.find_element_by_class_name("btn-primary").click()...
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!!