Multithreading Tabbed Browser

Multi-threading Tabbed Browser import java.util.Random; class BrowserTabHandler extends Thread { String url; int delayTimeInSeconds; int tabId; public BrowserTabHandler(String url, int tabId) { this.url = url; this.tabId = tabId; Random r = new Random(); delayTimeInSeconds = r.nextInt(10); System.out.printf(“[TAB: #%d] – URL: %s: Random Delay In Seconds: %d\n”, tabId, url, delayTimeInSeconds); } public void run() { try{…

Multithreading solution

Multi-threading solution – Runnable interface method class DownloadManager implements Runnable { static final int WAIT_TIME_MILLISECONDS = 500; static final int TOTAL_ITERATIONS = 60; public void run() { downloadFile(); } public void downloadFile() { int i; for(i=0;i<TOTAL_ITERATIONS;i++) { System.out.println(“Download File “+i); try { Thread.sleep(WAIT_TIME_MILLISECONDS); } catch(Exception e) { System.out.println(“Exception in Downloading File”); } } } }…

Multithreading exercise

Multi-threading exercise In our day to day use of our PC/laptops, we do multiple things in parallel like surfing internet ( or sometimes practicing Java coding) while listening to music. In this exercise, we are trying to do two things –    1. download a file and    2. listen to a song. Class DownloadManager is providing…

Java – Multithreading

We can think thread as a component of processes. Every process has at least one thread. Multiple threads can exist within the same process, executing concurrently and sharing the process’s resources, including memory and open files.   Q for thought: why do we need multi-threading ? Can you think of some scenarios where multi-threading helps /is required…

Selenium – Browser Commands

Understanding Browser Commands Most important reason for us to open a Web Browser is that we want to visit some website.  After the website opens up there are two things we can do. Interact with browser (Get Page Title, Get Current Url, Get page source etc.) Interact with components of website (Menu, Textboxes, RadioButtons etc.) In this tutorial…

Selenium – Navigation Commands

What is Selenium & Why should I used it? Selenium Automates Browser.  That means anything that we do in browser manually, can be programmatically done using Selenium. Selenium WebDriver provides us Classes and Functions that helps us perform browser operations by writing code.  In this tutorial we are going to focus on Navigation bar of browser and see…

Java – String Class

String – Class or Primitive Data Type? String is a most frequently used Java class. Ideally to create object of String class we should write code like String s = new String(“Being Zero”); But since it is most frequently used class, Java has made it easy for us to create string objects by directly assigning it…

Java – Class

Class is referred to a User Defined Data Type.  Generally in real world it represents a category of things,  Object is a uniquely identifiable entity of Data Type Class. MobilePhone is a class, as it represents category of devices. My iPhone 6S with IMEI Number XXXXXX and a Wallpaper of Company Logo – is uniquely…

Java – Objects

Objects are similar to variables. With few differences that will become evident in next few lines of the tutorial. Java has Eight Primitive (Basic) Data Types and Huge number of Classes (Complex Data Types). Declaration Syntax There is no difference between way we declare a variable and the way we declare an object. int a; //…