How to use selecteer_bestand method in SeleniumBase

Best Python code snippet using SeleniumBase

dutch.py

Source: dutch.py Github

copy

Full Screen

...96 return self.inspect_html(*args, **kwargs)97 def bewaar_screenshot(self, *args, **kwargs):98 # save_screenshot(name)99 return self.save_screenshot(*args, **kwargs)100 def selecteer_bestand(self, *args, **kwargs):101 # choose_file(selector, file_path)102 return self.choose_file(*args, **kwargs)103 def voer_het_script_uit(self, *args, **kwargs):104 # execute_script(script)105 return self.execute_script(*args, **kwargs)106 def blokkeer_advertenties(self, *args, **kwargs):107 # ad_block()108 return self.ad_block(*args, **kwargs)109 def overslaan(self, *args, **kwargs):110 # skip(reason="")111 return self.skip(*args, **kwargs)112 def controleren_op_gebroken_links(self, *args, **kwargs):113 # assert_no_404_errors()114 return self.assert_no_404_errors(*args, **kwargs)...

Full Screen

Full Screen

admin.py

Source: admin.py Github

copy

Full Screen

1from django import forms2from django.contrib import admin, messages3from django.contrib.admin.models import ADDITION, CHANGE, LogEntry4from django.contrib.admin.views.decorators import staff_member_required5from django.contrib.contenttypes.models import ContentType6from django.shortcuts import redirect, render7from django.urls import path, reverse8from django.utils.safestring import mark_safe9from iot.import_utils import import_xlsx10from leaflet.admin import LeafletGeoAdmin, LeafletGeoAdminMixin11from openpyxl import load_workbook12from iot import models13admin.site.register(models.Type2)14admin.site.register(models.Theme)15admin.site.register(models.LegalGround)16admin.site.register(models.ObservationGoal)17admin.site.register(models.Project)18LEAFLET_SETTINGS_OVERRIDES = {19 'DEFAULT_CENTER': (52.3676, 4.9041),20 'DEFAULT_ZOOM': 11,21}22class FileForm(forms.Form):23 selecteer_bestand = forms.FileField()24@staff_member_required25def import_xlsx_view(request, message_user, redirect_to):26 if request.method == "POST":27 file = request.FILES["selecteer_bestand"]28 num_created = 029 num_updated = 030 imported_sensors = []31 try:32 workbook = load_workbook(file)33 def action_logger(result):34 instance, created = result35 action = 'Aangemaakt' if created else 'Bijgewerkt'36 LogEntry.objects.log_action(37 user_id=request.user.pk,38 object_id=instance.pk,39 object_repr=str(instance),40 content_type_id=ContentType.objects.get_for_model(type(instance)).pk,41 action_flag=ADDITION if created else CHANGE,42 change_message=f'{action} door het importeren van "{file.name}"',43 )44 return result45 (46 errors,47 imported_sensors,48 num_created,49 num_updated,50 ) = import_xlsx(workbook, action_logger)51 except Exception as e:52 errors = [e]53 send_messages_to_user(request, message_user, num_created, num_updated, errors)54 # warn about any sensors that do not have a lat/​long, these sensors55 # will be imported in the registry, however it won't be possible to56 # show them on the map57 def change_url(s):58 return reverse(f'admin:{s._meta.app_label}_{s._meta.model_name}_change', args=(s.pk,))59 sensors_with_no_location = [60 f'<a target="_blank" href="{change_url(s)}">{s.reference}</​a>'61 for s in imported_sensors62 if s.location is None63 ]64 if sensors_with_no_location:65 message = "De volgende sensoren hebben geen lat/​long, en " \66 "kunnen dus niet op de kaart getoond worden: <br>"67 message += '<br>'.join(sensors_with_no_location)68 message_user(request, mark_safe(message), messages.WARNING)69 return redirect(redirect_to)70 else:71 return render(request, "import_xlsx.html", {"form": FileForm()})72def send_messages_to_user(request, message_user, num_created, num_updated, errors):73 """74 Give the user feedback about what was imported, and any errors that75 occurred.76 """77 message = f"{num_created} sensoren aangemaakt<br>{num_updated} sensoren bijgewerkt"78 if errors:79 level = messages.WARNING if num_created and not num_updated else messages.ERROR80 plural = 'en' if len(errors) > 1 else ''81 message += f"<br>{len(errors)} fout{plural} gevonden:"82 else:83 level = messages.INFO84 message_user(request, mark_safe(message), level)85 if errors:86 max_num_errors_to_show = 1087 show, hide = errors[:max_num_errors_to_show], errors[max_num_errors_to_show:]88 for e in show:89 message_user(request, mark_safe(str(e)), level=messages.ERROR)90 if hide:91 plural = 'en' if len(hide) > 1 else ''92 message_user(request, f'+ nog {len(hide)} fout{plural}', level=messages.ERROR)93@admin.register(models.Device2)94class DeviceAdmin(LeafletGeoAdmin):95 change_list_template = "devices_change_list.html"96 list_display = 'reference', 'owner', 'type', 'location',97 filter_horizontal = 'themes',98 settings_overrides = LEAFLET_SETTINGS_OVERRIDES99 search_fields = 'reference', 'owner__organisation', 'owner__email', 'owner__name'100 list_filter = (101 ('location', admin.EmptyFieldListFilter),102 )103 def get_urls(self):104 _meta = self.model._meta105 context = dict(106 message_user=self.message_user,107 redirect_to=f"admin:{_meta.app_label}_{_meta.model_name}_changelist",108 )109 import_xlsx_path = path('import_xlsx/​', import_xlsx_view, context)110 return [import_xlsx_path] + super().get_urls()111class DeviceInline(LeafletGeoAdminMixin, admin.StackedInline):112 model = models.Device2113 extra = 1114 settings_overrides = LEAFLET_SETTINGS_OVERRIDES115@admin.register(models.Person2)116class PersonAdmin(LeafletGeoAdmin):117 search_fields = 'organisation', 'email', 'name'118 inlines = [DeviceInline]119class ObservationGoalAdmin(LeafletGeoAdmin):120 list_display = 'observation_goal', 'privacy_declaration', 'legal_ground'121 search_fields = 'observation_goal', 'privacy_declaration', 'legal_ground'122 model = models.ObservationGoal123class ProjectAdmin(LeafletGeoAdmin):124 list_display = 'path'125 search_fields = 'path'...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Feeding your QA Career – Developing Instinctive &#038; Practical Skills

The QA testing profession requires both educational and long-term or experience-based learning. One can learn the basics from certification courses and exams, boot camp courses, and college-level courses where available. However, developing instinctive and practical skills works best when built with work experience.

A Complete Guide To CSS Grid

Ever since the Internet was invented, web developers have searched for the most efficient ways to display content on web browsers.

Keeping Quality Transparency Throughout the organization

In general, software testers have a challenging job. Software testing is frequently the final significant activity undertaken prior to actually delivering a product. Since the terms “software” and “late” are nearly synonymous, it is the testers that frequently catch the ire of the whole business as they try to test the software at the end. It is the testers who are under pressure to finish faster and deem the product “release candidate” before they have had enough opportunity to be comfortable. To make matters worse, if bugs are discovered in the product after it has been released, everyone looks to the testers and says, “Why didn’t you spot those bugs?” The testers did not cause the bugs, but they must bear some of the guilt for the bugs that were disclosed.

A Detailed Guide To Xamarin Testing

Xamarin is an open-source framework that offers cross-platform application development using the C# programming language. It helps to simplify your overall development and management of cross-platform software applications.

How To Run Cypress Tests In Azure DevOps Pipeline

When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful