Best Python code snippet using tempest_python
CatalogPage.py
Source:CatalogPage.py
...13 def click_sort_catalog(self):14 sort_catalog = self._element(self.SORT_CATALOG)15 sort_catalog.click()16 return sort_catalog17 def click_show_catalog(self):18 show_catalog = self._element(self.SHOW_CATALOG)19 show_catalog.click()20 return show_catalog21 def click_add_wishlist(self):22 add_wishlist = self._element(self.ADD_WISHLIST)23 add_wishlist.click()24 return add_wishlist25 def click_add_in_cart(self):26 add_in_cart = self._element(self.ADD_IN_CART)27 add_in_cart.click()28 return add_in_cart29 def click_grid_catalog(self):30 grid_catalog = self._element(self.GRID_CATALOG)31 grid_catalog.click()...
search_engine.py
Source:search_engine.py
1from model.product import Product2from mongoengine import Q3class SearchEngine:4 def search(self, query, show_catalog, trending):5 show_catalog_param = self.get_show_catalog(show_catalog)6 trending_param = self.get_trending(trending)7 filter = Q()8 if trending_param is not None:9 filter = filter & Q(trending=trending_param)10 if show_catalog_param is not None:11 filter = filter & Q(show_catalog=show_catalog_param)12 if query is not None:13 filter = filter & (Q(name__icontains=query) | Q(short_description__icontains=query) | Q(long_description__icontains=query))14 return Product.objects(filter)15 def get_show_catalog(self, show_catalog):16 if show_catalog == 'false':17 return False18 if show_catalog == 'true':19 return True20 return None21 def get_trending(self, trending):22 if trending == 'false':23 return False24 if trending == 'true':25 return True...
urls.py
Source:urls.py
1"""main URL Configuration2The `urlpatterns` list routes URLs to views. For more information please see:3 https://docs.djangoproject.com/en/2.1/topics/http/urls/4Examples:5Function views6 1. Add an import: from my_app import views7 2. Add a URL to urlpatterns: path('', views.home, name='home')8Class-based views9 1. Add an import: from other_app.views import Home10 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')11Including another URLconf12 1. Import the include() function: from django.urls import include, path13 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))14"""15from django.conf.urls import url16from django.contrib import admin17from django.urls import path18import phones.views19urlpatterns = [20 path('admin/', admin.site.urls),21 path('', phones.views.show_catalog, name='show_catalog'),22 path('catalog/', phones.views.show_catalog, name='show_catalog'),23 url(r'^catalog/(?P<slug>[\w-]+)/$', phones.views.show_product, name='show_product'),...
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!!