Skip to main content

Posts

Showing posts from April, 2020

Django Predefine View Classes, CreateView, ListView, FormView, DetailsView and UpdateView

  These all are predefined class view that is used to perform database operation. 1)  CreateView Example:- 1 ) Create Model Class:- class Job(models.Model):     jobtitle = models.CharField(max_length=100)     jobdescription = models.CharField(max_length=500) 2)  Create Classview under views.py from django.views.generic.edit import CreateView from django.urls import reverse class JobCreate(CreateView):   model = Job   fields = ['jobtitle', 'jobdescription']   success_url='path' 3)  create path urls.py:- from .views import JobCreate path('jobcreate',JobCreate.as_view()) 4)  create HTML file under template and name will job_form.html <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta http-equiv="X-UA-Compatible" content="IE=edge">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>Document...

Collection in C#, What is Collection in C#?

 Collection in C#, What is Collection in C#? It is the collection of elements of similar and dissimilar type both, it is used to solve the limitation of the array, we can store elements dynamically without providing any size.   Type of Collection Objects in C#:-   1) Generic Collection:-     List    Dictionary    SortedList    HashSet   Stack    Queue   2)  Non Generic Collection:-  ArrayList Hashtable  SortedList Stack Queue

How to take screenshots using selenium web driver or Robot class

Web drivers provide two different ways to take a screenshot Example 1st:- Note:-  Download the Jar file of org.apache.commons.io and add to the project. Link Download here package scs; i mport java.io.File; import java.io.IOException; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.apache.commons.io.FileUtils; public class Screenshotexample { public static void main(String[] args) throws IOException {     System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");     WebDriver driver = new ChromeDriver();         driver.get("https://eroomrent.in/");         File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);         FileUtils.copyFile(scrFile, new File("d://screenshot.png"));         driver.close();; }...