Posts

Selenium

 Testing

Selenium

 Testing

Typescript basics

  1. What is TypeScript? Think of TypeScript as an improved version of JavaScript. It helps developers write better and more reliable code by adding a feature called "static typing," which means we can specify the types of values in our code. Example: // JavaScript code function add(x, y) { return x + y; } // TypeScript code with type annotations function add(x: number, y: number): number { return x + y; } 2. Setting Up TypeScript To use TypeScript, we need to install it on our computer. We can do this by running a simple command. Once installed, write the code in files with a .ts extension and then use a tool to convert it into regular JavaScript. Example: # Install TypeScript globally npm install -g typescript # Create a TypeScript file (e.g., yourfile.ts) # Compile it into JavaScript using the tsc command tsc yourfile.ts 3. Type Annotations and Inference In TypeScript, we can say what type (like a number or text) a variable should be. For example, if we have a v...

Python program to sum up the Salary when the Name and Age matches with subsequent rows.

I have a .txt file as per below content with 4 fields as Name, Age, Salary and Date of Salary received Vijay,35,6000,29-12-2023 Manoj,32,12000,29-7-2023 Vinoth,31,11000,29-12-2023 Vijay,32,10000,29-10-2023 Vijay,32,7000,29-12-2023 Manoj,30,10000,29-11-2023 Vinoth,32,10000,29-10-2023 Vijay,32,10000,29-4-2023 Mano,32,1000,29-12-2023 Vijay,32,3000,29-8-2023 I wish to write a python program to sum up the Salary when the Name and Age matches with subsequent rows. Will you able to do the code ? Certainly! You can achieve this by reading the contents of the file, parsing each line to extract the relevant information (Name, Age, Salary), and then using a dictionary to store the sum of salaries for each unique combination of Name and Age. Here's a Python program that accomplishes this: def read_file(file_path): data = [] with open(file_path, 'r') as file: for line in file: line = line.strip() if line: name, age, salary, _ = l...

Automation using selenium and python/java interview question to order a product in e commerce website.

Image
 1. Open the browser  2.  Go to the address bar and type  "https://www.flipkart.com/"          3. Select the search bar and enter "poco c65 mobiles" 4. Select the desired mobile by clicking on it. 5. Click on add to cart button. 6. Click  the place order button. 7.Enter mobile number and click continue. 8.Enter the OTP and click sign up. 9. After entering multiple wrong OTP the  system throws an error All the above steps should be automated.

Django practical examples

Image
Using the urls.py to display our content in views.py: urls.py from django.contrib import admin from django.urls import path from myApp import views urlpatterns = [     path('admin/', admin.site.urls),     path ('index/', views.index, name='index') ] views.py from django.shortcuts import render from django.http import HttpResponse # Create your views here. def index(request):     return HttpResponse('<h1>Hello index<h1>') The above code in the django gives the following result   Create Tables using models.py from django.db import models # Create your models here. class sampleTable(models.Model):     Row1 = models.CharField(max_length = 100)     Row2 = models.IntegerField() For creating tables we use make migrations in cmd type the following commands: python manage.py makemigrations python manage.py migrate After the commands entered, empty sqlite3 file is filled with some table contents which was empty previously   o...

Django introduction

Introduction: Django, a high-level Python web framework, has gained immense popularity for its simplicity, versatility, and scalability. Whether you're a novice developer or someone with experience in other languages, Django provides an excellent starting point for building robust web applications. This blog post will guide you through the basics of Django, helping you take your first steps into the world of web development. What is Django? Django is an open-source web framework written in Python. It follows the Model-View-Controller (MVC) architectural pattern, but in Django's terminology, it's referred to as the Model-View-Template (MVT). This framework encourages rapid development, clean and pragmatic design, and the "Don't Repeat Yourself" (DRY) principle. Prerequisites: Before diving into Django, ensure  the following installed on the system: Python: Django is a Python framework, so having Python installed is essential. We can download the latest version ...

Basic Linux Commands

1. ls - List Files and Directories: This command is used to list the files and directories in the current working directory. Example: ls Following are some frequently used options in Linux ls commands: Options Description ls -a list all files including hidden file starting with '.'. ls -d list directories - with ' */'. ls -l list with long format - show permissions. ls -F Append indicator (one of */=>@|) to entries. ls -lh This command will show you the file sizes in human readable format. ls -r list in reverse order. ls -i list file's inode(index) number. ls -ltr View Reverse Output Order by Date. ls -t sort by time & date. ls -n It is used to print group ID and owner ID instead of their names. ls -m A list of entries separated by commas should fill the width. ls -g This allows you to exclude the owner and group information columns. ls -q Force printing of non-graphic characters in file names as the character `?';. ls -Q Place double quotations around t...