Showing posts with label webdriver tutorials. Show all posts
Showing posts with label webdriver tutorials. Show all posts

BrowserStack is web cloud platform which provides us an environment to test web and mobile applications on different version combinations of OS and browsers. BrowserStack provides limited access in Free trial version but you can get full access in Paid version's different plans. Many of you already aware about it's different features and usage. But still let me introduce you with browserstack little bit.

Earlier we already learn different selenium webdriver methods to add cookie, get cookies detail by name and all cookies. Sometimes you also need to delete all cookies from your browser in selenium webdriver test. Selenium Webdriver have built in deleteAllCookies() to Delete all cookies from current running browser window in test.

Earlier we learnt how to add cookie and get cookie details using different methods like addCookie(), getCookieNamed() and getCookies(). Sometimes you also need to delete cookie. Selenium webdriver have built in methods to delete cookies by deleteCookieNamed() or passing cookie object in deleteCookie() method.

Any site can have single or multiple cookies. If you know cookie name then you can get it's detail easily using getCookieNamed(). But if there are multiple cookies and you need all of them then you need to use getCookies(). It will retrieve all cookies of site you are navigating in selenium webdriver test. Here we will learn how to get all cookies using getCookies() and extracting all cookie detail using Java Set interface and Iterate through cookie set using Iterator.

Most of all you are already aware about browser cookie. Basically cookie is piece of data that is stored in your browser. It is sent from website you visit and mostly it is used to recognize if user return to website again. In sort, It tracks your website navigation journey. Cookie consist of different parameters like name, value, expiry, path, etc. Here we will see how can we add cookie and get cookie from browser in selenium webdriver using addCookie() and getCookieNamed().

Sometimes you need to set Dimension and Position of your browser window. Webdriver have built in Dimension and Position class with many different methods. We can use both these class and it's methods to set dimensions and positions of browser window. Let's see how we can use Dimension and Position methods to manage size and position

manage() method is very basic and we are using it very frequently in selenium WebDriver tests. You can use it to manage size and positions of browser window during your test. You can use it to add or delete cookie, get cookie, timeouts, waits and there are many other usages as well but here we will discuss about how to maximize browser or set it to full screen mode.

navigate() method is very frequently used method in selenium webdriver. Using this method, driver can navigate back, forward, refresh browser and navigate to specific URL. navigate() is very simple method and we can use it verify quickly in our selenium webdriver tests. Lets see how we can use navigate() method in selenium webdriver.

We can use switchTo() method when you want to switch between multiple browser windows or multiple frames on page. Earlier we had seen how to switch between two windows using getWindowHandles() and switchTo() methods. Here we will see how to switch between iFrames on page using switchTo() method by index of iFrame.

getwindowhandle() and getWindowHandles() are methods to get handle of window. getwindowhandle() is useful to get handle of current selected window or tab while getWindowHandles() will return handles of all open windows or tabs. Both these methods are useful when you are working with multiple windows and you need to switch from one window to another window.

Many new learners are initially confused about when to use close() and when to use quit() method in Selenium WebDriver. close() method will close the current instance of the webdriver object reference. In simple word, It will close current window or tab on which your test is currently running. quit() methods will dispose webdriver object so it is also known as dispose method. In simple word, quit() methods will close all open browser tabs or windows.

Selenium Webdriver's findElement() method is useful to locate WebElement for page. It is one of the mostly used method in selenium webdriver. It uses By object as parameter can can use it with various element locating strategies like ID, Name, Linktext, Partial Linktext, Tag Name, Class Name, DOM Locator, CSS Selector and Xpath. findElement() will return first matching webelement from page.

It Is most Important to learn shortcuts of eclipse IDE If you wants to speed up Selenium WebDriver test creation and execution process because performing each and every actions In eclipse using just mouse Is time consuming. If you knows keyboard shortcut keys to perform regular actions In eclipse then It will be very easy for you to do It within one second.

Earlier have shared many tutorial examples on selenium IDE different commands and Its usage. You can view each of that example on Selenium IDE Tutorial. Still many peoples are using selenium IDE to automate their small web applications and sometimes they needs to perform compatibility testing In Google Chrome and IE browsers like submitting form, registration, login etc. activities.

We can perform these activities very easily In google chrome and IE browsers using Selenium WebDriver and you can view related tutorials link on Selenium Tutorial. Is It possible to run selenium IDE test In Google Chrome? Yes.. Follow steps given bellow to run selenium IDE test In google chrome browser.

Part 10

46 : What is Polymorphism?
Answer : Polymorphism is ability using which we can create reference variables or methods which behaves differently in different programmatic context. Best example of polymorphism is human. We behaves differently with different people in different environment. Our behavior will be different when we meet to boss and meet to friend. Read more on Polymorphism in java.

47 : What is the advantages of Polymorphism?
Answer : Main advantage of polymorphism is code reusabilty. You can dynamically supply different implementations through polymorphism. So it will reduce your work volume in terms of handling and distinguishing various objects.

Part 9

41 : In java, What is return type of main method?
Answer : Main method doesn't have any return type. It is void.

42 : Can We Overload main method in java?
Answer : Yes, Java class can have any number of main methods so it is possible to overload main method. But when you run program, It will not execute overloaded main method. Always It will execute only public static void main(String[] args) method.

Part 8

36 : What is the difference between the Constructor and Method?
Answer : Main difference between the Constructor and Method is as bellow.

Constructor :
  1. Name of the constructor must be same as class name.
  2. Constructor must not have any return type.
  3. It is used to initialize the state of an object.
  4. It is not possible to call constructor directly. Constructors called implicitly when the new keyword creates an object.
Method :
  1. Method name can be any.
  2. Method must have return type.
  3. It is used to expose behavior of an object.
  4. Methods can be called directly.
Read more on Constructor and Method.

Part 7

31 : What is default value of local variable.
Answer : There is not any default value of local variable. You must have to initialize it. View more details on local variables in java.

32 : Java support constructor inheritance?
Answer : No, Constructor inheritance is not supported in java. View more details on constructor in java.

Part 6

26 : What is local variable in java?
Answer : Local variable is declared inside method or constructor and it is limited for that method or constructor only. View more detail on local variable in java.

Local Variable Example :
public class JavaVariable {

 public void Calc() {
  // Local Variables.
  int sum;
  int item1 = 5;
  int item2 = 7;
  sum = item1 + item2;
  System.out.println("Sum is : " + sum);
 }

 public static void main(String args[]) {
  JavaVariable j = new JavaVariable();
  j.Calc();
 }
}

Earlier we have talked about method overriding concept in java during THIS POST to change the implementation of parent class's method in sub class. In inheritance, Super keyword is used to refer object of immediate parent class. Generally we are using super keyword in inheritance for three different purpose. Let's see how and when to use super keyword in java. Interviewer can ask you this question so please understand how it works.