Best Python code snippet using toolium_python
test_driver_wrapper_properties.py
...44 environment_properties = []45def test_configure_properties_deprecated(driver_wrapper):46 environment_properties.append('Config_prop_filenames')47 os.environ['Config_prop_filenames'] = 'properties.cfg'48 driver_wrapper.configure_properties()49 assert driver_wrapper.config.get('Driver', 'type') == 'firefox' # get last value50 assert driver_wrapper.config.get_optional('Driver', 'implicitly_wait') == '5' # only in properties51 assert driver_wrapper.config.get_optional('AppiumCapabilities', 'app') is None # only in android52def test_configure_properties(driver_wrapper):53 environment_properties.append('TOOLIUM_CONFIG_PROPERTIES_FILENAMES')54 os.environ['TOOLIUM_CONFIG_PROPERTIES_FILENAMES'] = 'properties.cfg'55 driver_wrapper.configure_properties()56 assert driver_wrapper.config.get('Driver', 'type') == 'firefox' # get last value57 assert driver_wrapper.config.get_optional('Driver', 'implicitly_wait') == '5' # only in properties58 assert driver_wrapper.config.get_optional('AppiumCapabilities', 'app') is None # only in android59def test_configure_properties_android(driver_wrapper):60 environment_properties.append('TOOLIUM_CONFIG_PROPERTIES_FILENAMES')61 os.environ['TOOLIUM_CONFIG_PROPERTIES_FILENAMES'] = 'android-properties.cfg'62 driver_wrapper.configure_properties()63 assert driver_wrapper.config.get('Driver', 'type') == 'android' # get last value64 assert driver_wrapper.config.get_optional('Driver', 'implicitly_wait') is None # only in properties65 assert driver_wrapper.config.get_optional('AppiumCapabilities',66 'app') == 'http://invented_url/Demo.apk' # only in android67def test_configure_properties_two_files(driver_wrapper):68 environment_properties.append('TOOLIUM_CONFIG_PROPERTIES_FILENAMES')69 os.environ['TOOLIUM_CONFIG_PROPERTIES_FILENAMES'] = 'properties.cfg;android-properties.cfg'70 driver_wrapper.configure_properties()71 assert driver_wrapper.config.get('Driver', 'type') == 'android' # get last value72 assert driver_wrapper.config.get_optional('Driver', 'implicitly_wait') == '5' # only in properties73 assert driver_wrapper.config.get_optional('AppiumCapabilities',74 'app') == 'http://invented_url/Demo.apk' # only in android75def test_configure_properties_two_files_android_first(driver_wrapper):76 environment_properties.append('TOOLIUM_CONFIG_PROPERTIES_FILENAMES')77 os.environ['TOOLIUM_CONFIG_PROPERTIES_FILENAMES'] = 'android-properties.cfg;properties.cfg'78 driver_wrapper.configure_properties()79 assert driver_wrapper.config.get('Driver', 'type') == 'firefox' # get last value80 assert driver_wrapper.config.get_optional('Driver', 'implicitly_wait') == '5' # only in properties81 assert driver_wrapper.config.get_optional('AppiumCapabilities',82 'app') == 'http://invented_url/Demo.apk' # only in android83def test_configure_properties_system_property(driver_wrapper):84 environment_properties.append('TOOLIUM_CONFIG_PROPERTIES_FILENAMES')85 environment_properties.append('TOOLIUM_DRIVER_TYPE')86 os.environ['TOOLIUM_CONFIG_PROPERTIES_FILENAMES'] = 'properties.cfg'87 os.environ['TOOLIUM_DRIVER_TYPE'] = 'Driver_type=opera'88 driver_wrapper.configure_properties()89 assert driver_wrapper.config.get('Driver', 'type') == 'opera'90def test_configure_properties_file_default_file(driver_wrapper):91 driver_wrapper.configure_properties()92 assert driver_wrapper.config.get('Driver', 'type') == 'firefox'93def test_configure_properties_file_not_found(driver_wrapper):94 environment_properties.append('TOOLIUM_CONFIG_PROPERTIES_FILENAMES')95 os.environ['TOOLIUM_CONFIG_PROPERTIES_FILENAMES'] = 'notfound-properties.cfg'96 with pytest.raises(Exception) as excinfo:97 driver_wrapper.configure_properties()98 assert 'Properties config file not found' in str(excinfo.value)99def test_configure_properties_no_changes(driver_wrapper):100 # Configure properties101 environment_properties.append('TOOLIUM_CONFIG_PROPERTIES_FILENAMES')102 os.environ['TOOLIUM_CONFIG_PROPERTIES_FILENAMES'] = 'properties.cfg'103 driver_wrapper.configure_properties()104 assert driver_wrapper.config.get('Driver', 'type') == 'firefox'105 # Modify property106 new_driver_type = 'opera'107 driver_wrapper.config.set('Driver', 'type', new_driver_type)108 assert driver_wrapper.config.get('Driver', 'type') == new_driver_type109 # Trying to configure again110 driver_wrapper.configure_properties()111 # Configuration has not been initialized112 assert driver_wrapper.config.get('Driver', 'type') == new_driver_type113def test_configure_properties_change_configuration_file(driver_wrapper):114 # Configure properties115 environment_properties.append('TOOLIUM_CONFIG_PROPERTIES_FILENAMES')116 os.environ['TOOLIUM_CONFIG_PROPERTIES_FILENAMES'] = 'properties.cfg'117 driver_wrapper.configure_properties()118 assert driver_wrapper.config.get('Driver', 'type') == 'firefox'119 # Modify property120 new_driver_type = 'opera'121 driver_wrapper.config.set('Driver', 'type', new_driver_type)122 assert driver_wrapper.config.get('Driver', 'type') == new_driver_type123 # Change file and try to configure again124 environment_properties.append('TOOLIUM_CONFIG_PROPERTIES_FILENAMES')125 os.environ['TOOLIUM_CONFIG_PROPERTIES_FILENAMES'] = 'android-properties.cfg'126 driver_wrapper.configure_properties()127 # Check that configuration has been initialized128 assert driver_wrapper.config.get('Driver', 'type') == 'android'129def test_configure_properties_finalize_properties(driver_wrapper):130 environment_properties.append('TOOLIUM_CONFIG_PROPERTIES_FILENAMES')131 environment_properties.append('TOOLIUM_DRIVER_TYPE')132 os.environ['TOOLIUM_CONFIG_PROPERTIES_FILENAMES'] = 'properties.cfg'133 os.environ['TOOLIUM_DRIVER_TYPE'] = 'Driver_type=opera'134 # Modify properties after reading properties file and system properties135 def finalize_properties_configuration(self):136 self.config.set('Driver', 'type', 'chrome')137 original_method = DriverWrapper.finalize_properties_configuration138 DriverWrapper.finalize_properties_configuration = finalize_properties_configuration139 driver_wrapper.configure_properties()140 # properties file: firefox141 # system property: opera142 # finalize properties method: chrome143 assert driver_wrapper.config.get('Driver', 'type') == 'chrome'144 # Restore monkey patching after test...
Lab3.py
Source: Lab3.py
...36 else:37 property_list['Location'] = location38 property_list['Model'] = model39 property_list['Serial'] = serial40 device_obj.configure_properties(ip_addr, **property_list)41 ip_list.append(ip_addr)42 while True:43 ip_addr_key = input("Please enter your IP address to retrieve device's properties:")44 if (device_obj.check_ip_in_database(ip_addr_key) == "True"):45 device_properties = input("Do you want to update device's properties? (y/yes or n/no)")46 if device_properties.lower() == 'n' or device_properties.lower() == 'no':47 continue48 elif device_properties.lower() == 'y' or device_properties.lower() == 'yes':49 print ('\tIP Address: '.format(ip_addr_key))50 device_obj.show_properties(ip_addr_key)51 selection = input(52 "Which device's property you'd like to update? (Type 'Location' for location, 'Model'"53 " for model, 'Serial' for serial, or 'All' for all):")54 if selection.lower() == 'all':55 try:56 modified_location = input("Please enter your modified location:")57 modified_model = input("Please enter your modified model:")58 modified_serial = input("Please enter your modified serial:")59 if modified_location == '' or modified_model == '' or modified_serial == '':60 raise ValueError ('One of modified properties is empty!')61 except ValueError as err:62 print ('Input error: {}'.format(err))63 continue64 else:65 property_list['Location'] = modified_location66 property_list['Model'] = modified_model67 property_list['Serial'] = modified_serial68 device_obj.configure_properties(ip_addr_key, **property_list)69 elif selection.lower() == 'location':70 try:71 modified_location = input("Please enter your modified location:")72 if modified_location == '':73 raise ValueError('Modified location can\'t be empty')74 except ValueError as err:75 print ('Input error: {}'.format(err))76 continue77 else:78 property_list['Location'] = modified_location79 device_obj.configure_properties(ip_addr_key, **property_list)80 elif selection.lower() == 'model':81 try:82 modified_model = input("Please enter your modified model:")83 if modified_model == '':84 raise ValueError('Modified model can\'t be emppty')85 except ValueError as err:86 print ('Input error: {}'.format(err))87 continue88 else:89 property_list['Model'] = modified_model90 device_obj.configure_properties(ip_addr_key, **property_list)91 elif selection.lower() == 'serial':92 try:93 modified_serial = input("Please enter your modfied serial:")94 if modified_serial == '':95 raise ValueError('Modified serial can\'t be empty')96 except ValueError as err:97 print ('Input error: {}'.format(err))98 continue99 else:100 property_list['Serial'] = modified_serial101 device_obj.configure_properties(ip_addr_key, **property_list)102 else:103 print('You\'ve not made any choice for modifying device\'s properties. Device\'s properties are unchanged.')104 continue105 print ('\tIP Address: {}'.format(ip_addr_key))106 device_obj.show_properties(ip_addr_key)107 else:108 print("Invalid response!")109 continue110 confirmation = input("Do you still want to retrieve device's properties? (y/n)")111 if confirmation.lower() == 'n' or confirmation.lower() == 'no':112 break113 elif confirmation.lower() == 'y' or confirmation.lower() == 'yes':114 continue115 else:...
app.py
Source: app.py
1from object_detection import ObjectDetection2od = ObjectDetection()3od.configure_pipeline()4od.configure_properties()5od.configure_link()...
Check out the latest blogs from LambdaTest on this topic:
Traditional software testers must step up if they want to remain relevant in the Agile environment. Agile will most probably continue to be the leading form of the software development process in the coming years.
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.
Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.
Estimates are critical if you want to be successful with projects. If you begin with a bad estimating approach, the project will almost certainly fail. To produce a much more promising estimate, direct each estimation-process issue toward a repeatable standard process. A smart approach reduces the degree of uncertainty. When dealing with presales phases, having the most precise estimation findings can assist you to deal with the project plan. This also helps the process to function more successfully, especially when faced with tight schedules and the danger of deviation.
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!!