SelectorsHub: The best xpath plugin for all the browsers

SelectorsHub helps to write and verify the XPath and cssSelector.

SelectorsHub is the complete new way to write and verify the XPath and cssSelectors.

SelectorsHub auto suggests all attributes, text and everything along with their occurrences to complete Selectors quickly. Now you need not to copy and paste attribute values from DOM anymore to build XPath and cssSelector. It also supports shadowDOM, iframe and SVG elements. It gives the proper error message like what is wrong in your xpath and cssSelector.

SelectorsHub is invented and created by Sanjay Kumar

How to install & use SelectorsHub?

Find the download link here. Try it now it’s absolutely FREE.

https://www.selectorshub.com/

  1. Click on the download link for whichever browser you want.

2) Click on Add to Chrome.

3) After adding the extension, it will show in the browser toolbar like this. You can pin to the toolbar by clicking on the pin icon.

4) After adding the extension, restart the browser.

5) Now open DevTools by right clicking on any element and clicking on inspect.

6) On the right side of the Elements tab, SelectorsHub will be the last tab as shown in below image. If not visible, expand the sidebar or click on the two arrow icons as shown in below gif.

7) Now here you start typing your xpath or cssSelector. You will get auto suggest for inspected element.

Why to use SelectorsHub while there are so many other good XPath tools & selectors tools?

Biggest reason is, SelectorsHub helps to improve XPath and cssSelector writing skills.

Not one reason, there are many reasons which makes SelectorsHub the unique and best xpath tool.

  1. SelectorsHub is the only tool which made it possible to write own selectors in less than 5sec with its auto suggest feature without compromising learning skills.
  2. SelectorsHub is the only tool which supports #shadowDOM, in fact even Chrome DevTools doesn’t support shadowDOM.
  3. SelectorsHub is the only tool which gives the proper error message for the missing elements in your selectors.
  4. It helps you to improve your xpath and cssSelectors writing skills.
  5. It has iframe support.
  6. It supports svg elements.
  7. It supports dark theme.

ShadowDOM Support

It was never possible to verify and write the cssSelectors for shadowDOM elements but this amazing innovation made it possible.

Proper error message for missing elements in selectors

Earlier there was nothing which can tell us what’s wrong in our selector. We were never able to understand what’s wrong in our selector until we are not expert in it. Devtools suggests 0 matching node for wrong selector pattern. But now we have the Selector’s guide which helps us with the correct error message and what is wrong or missing in our selector.

Iframe support


It supports iframes as well. It will let you know if the inspected element is inside an iframe or not. Now we can easily write and verify selectors for elements inside an iframe without wasting any time.

SVG element support

Many of us are not aware that svg elements don’t support the standard xpath format. SVG elements support different xpath patterns. SelectorsHub has made it easy and let you know the correct format and helps you to learn how to write selectors for svg elements.

Looking forward to see some more interesting features in SelectorsHub.

Core Java (For Automation Testers) – Interview Questions and Answers – Part 1

1. What is OOPS?

Object Oriented Programming System is the programming technique to write programs based on the real world objects. The states and behaviors of an object are represented as the member variables and methods. In OOPS programming programs are organized around objects and data rather than actions and logic.

2. What are the advantages of OOPS concepts?

Major advantages of OOPS programming are;
1. Simplicity: OOPS programming objects model real world objects, so the complexity is reduced and the program structure is clear.
2. Modularity: Each object forms a separate entity whose internal workings are decoupled from other parts of the system.
3. Modifiability: It is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods.
4.  Extensibility: Adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones.
5.  Maintainability: Objects can be maintained separately, making locating and fixing problems easier.
6.  Reusability: Objects can be reused in different programs1

3. What are the core concepts of OOPS?

OOPS core concepts are:
1. Abstraction
2. Encapsulation
3. Polymorphism
4. Inheritance
5. Composition
6. Association
7. Aggregation

4. Explain JDK,JRE and JVM in short.

JVM
JVM is an acronym for Java Virtual Machine, it is an abstract machine which provides the runtime environment in which java bytecode can be executed. It is a specification.
JVMs are available for many hardware and software platforms (so JVM is platform dependent).
JRE
JRE stands for Java Runtime Environment. It is the implementation of JVM.
JDK
JDK is an acronym for Java Development Kit. It physically exists. It contains JRE + development tools.

5. What is constructor?

Constructor is just like a method that is used to initialize the state of an object. It is invoked at the time of object creation.

6. What is the purpose of default constructor?

The default constructor provides the default values to the objects. The java compiler creates a default constructor only if there is no constructor in the class

7. Does constructor return any value?

Ans:yes, that is current instance (You cannot use return type yet it returns a value)

8. Is constructor inherited?

No, constructor is not inherited.

9. Can you make a constructor final?

No, constructor can’t be final.

10. What is static variable?
  •  static variable is used to refer the common property of all objects (that is not unique for each object) e.g. company name of employees,college name of students etc.
  •  static variable gets memory only once in class area at the time of class loading.
11. What is static block?
  • Is used to initialize the static data member.
  • It is executed before main method at the time of class loading.
12. Can we execute a program without main() method?

Yes, one of the way is static block.

13. What is final variable?

If you make any variable as final, you cannot change the value of final variable(It will be constant).

14. What is final method?

Final methods can’t be overriden.

15. What is final class?

Final class can’t be inherited.


Continue to: CORE JAVA (FOR AUTOMATION TESTERS) – INTERVIEW QUESTIONS AND ANSWERS – PART 2

Selenium Online Training with live project

About Selenium Online Training Course
With Selenium Training, We help you to learn Selenium. It is one of the top automation testing tool. As part of the training you will learn about Selenium components like Selenium IDE, RC, WebDriver and Grid through hands-on projects and case studies in this Selenium certification training.
What you will learn in this Selenium online Training Course?

Selenium Automated Testing advantages
Advanced study of SIKULI, TestNG Plugin in Eclipse
Learn about Object Repository and Maven
Introduction to Selenium WebDriver
WebDriver programs like Textbox, Checkbox and multiple Windows
Use Selenium Grid for software testing
Jenkins

Who should take this Selenium 3.0 Training Course?
Software Developers, Testers, QA Engineers
System Analysts, Administrators, BI and ETL professionals

What are the prerequisites for taking this Selenium Certification Training Course?
Having a basic knowledge of C or Java is beneficial but not mandatory for taking this Selenium certification training.

Topics to be covered:

Why Selenium script runs slow on IE browser as compared to other browsers like chrome and Firefox?

Why execution speed of Selenium in IE is slow?

If we are talking about execution speed then i would go with headless browser and htmlunit is a headless browser.

So as per my working experience have got that scripts in almost all browser get executed at the same rate except few of the exception in IE. But if we are going to include the browser up time then order is like this,

htmlunit –> Chrome –> Firefox –> at the last its IE

Now, why IE is slow?

Much of the functionality of WebDriver is implemented using so-called “automation atoms”. These are JavaScript functions that are used to ensure consistency and reduce maintenance across the different drivers. Some of these functions are fairly straightforward, and delegate down to the browsers’ native code fairly quickly. Finding an element by ID, for example, pretty clearly translates to document.getElementById().
Other operations, on the other hand, are much more computationally expensive. For example, getting the text of an element is one of the most expensive things you can do, Because of the way the WebDriver API defines getting an elements text.
Because so much of this functionality is built in JavaScript, a browser that has a slow JavaScript engine like IE Will show poor performance when executing WebDriver code. Remember that the JavaScript engine in IE before version 9 was about ten times slower than the JavaScript engines in Firefox and Chrome. IE9 introduced a new JavaScript engine that was a lot closer in performance to that of Firefox and Chrome, but Microsoft only implemented the new JavaScript engine in the 32-bit version of IE. So the first thing you can do is run your tests against the 32-bit version of IE9.
IE also doesn’t have a native XPath engine for finding elements. So to be able to find elements by XPath in IE, we have to use a JavaScript XPath query engine. That’s going to be slower than doing the same thing in other browsers. This is the biggest reason why I recommend using CSS selectors instead of XPath for finding elements.
I would also recommend calling expensive methods as seldom as possible. The two most expensive methods are getText() and isDisplayed(), because they have to walk a substantial portion of the DOM tree before they can return the correct value.

 

Integrate Git / GitHub with Eclipse IDE for Selenium Java Project

Integrate Git GitHub with Eclipse IDE – Git is a revision control system, a tool to manage versions of edits you made to files in a git repository.  In order to checkin & checkout the code from eclipse IDE, the very first thing we need to do is, install Git plugin in to Eclipse IDE.

Below are the steps to guide about installation of Git plugin in eclipse IDE.

Go to Help –> Install New Software

enter image description here

Use URL = http://download.eclipse.org/egit/updates

enter image description here

Click on OK & Select the just now added URL.

Avilable softwares for GIT installation

Select and Click on Next. Follow the next process and complete the installation.

 

Now, Once installation is completed,  you want to add the Git Repositories view:

enter image description here

enter image description here

enter image description here

Create a new Git Repository. I have already created a repository called Java. I will refer to that repo for the rest of the explanation.

enter image description here

After you create your repository, it should show up in the Git Repositories view. Now to add your project to the repository, right click on your project and select Team->Share Project.

Select the repository you just created. You can also use CTRL+ to select multiple projects and place them in one repository.

Now go back to your Git Repositories view. Go to Remotes . Right click and select Create Remote.

enter image description here

Select Change... and enter the SSH link for your Repository on GitHub. For connection, select SSH. Then press Finish. enter image description here For Rev-mapping, select Advanced.... For Source Ref select refs/heads/master. And then press Add Spec, then select Save specifications in 'origin' configuration. Then press finish.
That's pretty much it. You can commit changes by right clicking your project - >
Team->Commit…`

enter image description here

Push new commits to GitHub:

enter image description here

Hope this helps !!!

How to run testng.xml from POM.xml (maven)

In this article i will talk about how to run testng.xml from maven’s POM.xml file. This is very useful feature of maven when we need to run multiple testng.xml files.

run testng.xml from pom.xml maven

The very first thing is, install maven in your eclipse IDE. Refer below article to know about how to install maven in eclipse ide.

How to download and Install Maven in Eclipse IDE?

Now, create a maven project.  Refer below article to understand how to create new project in eclipse IDE.

How to create Maven Project for Selenium in Eclipse IDE?

Now, write one sample test case in one of the folder created by maven, preferably test folder.  I have created below sample code –

package kdf1;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class Sample {
  
  @Test
  public void test(){
    System.out.println("Test Print");
    System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    
    driver.navigate().to("http://demowebshop.tricentis.com/");
    driver.manage().window().maximize();
    
    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
  }

}

Now, create testng.xml file for executing above test case. My testng.xml files looks like –

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Default suite">
  <test verbose="2" name="Default test">
    <classes>
      <class name="kdf1.Sample"/>
    </classes>
  </test> <!-- Default test -->
</suite> <!-- Default suite -->

Now, create a POM.xml file, add required dependencies. My POM.xml looks like –

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com</groupId>
  <artifactId>kdf1</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  <dependencies>
  <dependency>
  <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.53.0</version>
  </dependency>
  
  <!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.9.9</version>
    <scope>test</scope>
</dependency>
  
  </dependencies>
    
</project>

Now, My job is to execute above given testng.xml file from above created POM.xml file via maven commands.

To achieve this, we need to use Suite XML files. Add below lines of code in POM.xml under <build> tags.

Make sure that you give the full testng.xml path.

<plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.20.1</version>
        <configuration>
          <suiteXmlFiles>
            <suiteXmlFile>testng.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
      </plugin>
</plugins>

After adding above piece of code in to my POM.xml (under <build> tags), my POM.xml looks like –

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com</groupId>
  <artifactId>kdf1</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  <dependencies>
  <dependency>
  <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.53.0</version>
  </dependency>
  
  <!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.9.9</version>
    <scope>test</scope>
</dependency>
  
  </dependencies>
  <build>
  <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.20.1</version>
        <configuration>
          <suiteXmlFiles>
            <suiteXmlFile>C:\Users\Prakash\workspace\kdf1\testng.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
      </plugin>
</plugins>
  </build>
  
</project>

Thats it, you are done.

You are good to execute your testng.xml file from maven’s POM.xml. The main advantage of using this is we can execute multiple testng.xml files.

You can execute the project now by right clicking on project, Run As –> Maven Test  (another way to execute test case is from command prompt).

This was all about how to run testng.xml from pom.xml.

To know more about how to execute maven commands from command prompt, refer below link –

Maven Build Life Cycle – How to execute maven project

 

Hope this helps !!!!! Do provide your valuable comments !!!

Maven Build Life Cycle – Build process in Maven

In this article i will talk about maven build life cycle, that is maven build process.

In my last tutorial. i talked about maven introduction, how to install maven & other things.

Introduction to Maven (A Build Tool) – What is Maven?

How to download and Install Maven in Eclipse IDE?

How to create Maven Project for Selenium in Eclipse IDE?

Okay, so let us talk about maven build life cycle. Maven build process is via command prompt or in eclipse IDE.

Every build follows the life cycle (Write code -> compile -> run test cases -> package -> install).  In the similar way maven has its own build life cycle.

Maven-Build-Life-Cycle consist of below phases –

  1. Validate – (Check if everything is at proper place like POM.xml, if configuration is proper etc)
  2. Compile – (Takes all .java files & create .class files)
  3. Test –  (Where our actual test cases runs)
  4. Package –  (Packages the code, all class files either in jar / war files, depending on what we specify in POM.xml)
  5. Install –  (Install the package in to local maven repository. Note that – Install does not mean installation in to your server like install war in to server. Here it is maven specific. It just put in local maven repository. So, Install is something that helps you to publish your jars in to your local repository so if you have dependency of this jar in another project, it can pull that jar from local repository).
  6. Deploy –  (Deploy does not mean deploying on webserver. This means publish this artifact to remote repository so that other can pull the same. This is more or less same as install phase. We do not use deploy phase mostly until and unless your projects are linked and they have dependency of newly created jar file on another project)

How to run Maven commands?

Maven commands can be run via command prompt or can be via eclipse IDE.

  1. Run Maven Commands from eclipse IDE

Once you have created a maven project & updated you POM.xml with required testng.xml (watch below video to understand how), we can run maven project from eclipse ide. refer below screenshot.

maven build process - Run maven commands from eclipse IDE

You can right click on maven project & then click on “Run As”, You will find multiple options to run your maven projects. Will talks about multiple options in below few para.

2. Another way to run maven commands is from Command prompt.

Once your maven project is ready, Go to command prompt & go to the directory where your maven project is located at.

My maven project is present at – C:\Users\Prakash\workspace\kdf1

So, go to this location & enter the maven command here. Execution should start. Refer below screenshot.

maven build process - Run maven commands from command prompt

So, above is the way how to execute maven commands.

Now what are the maven commands?

  1. mvn clean –> This command is used to clean results from previous build
  2. mvn clean test –> this command is used to clean & then run the test cases (So this include compile as well)
  3. mvn compile –> this will only compile the project (creates .class files only). No Execution.
  4. mvn package –> this will compile, execute & it will creates a package (.jar or war file as specified)
  5. mvn deploy –> this will compile, execute, creates package & will deploy in repository.

.  .  .  .  .  there can be few more commands as well .   .   .   .

This is all about maven build life cycle.

Refer below video for the same –

 

Do post you comments / improvement suggestions. Thanks !!!!!

Introduction to maven – What is maven (Build tool)

Introduction to maven?

Maven is basically a project management tool, where we manage our projects, we can  build projects, deploy projects & many more features like reporting & documentation. It refers concept of Project Object Model (POM). In a short term, it is a build tool.

If you are using build tool like mavn, it simplifies your build process. everything becomes very simple because it follows some life-cycle what it has. we will talk about mavn life-cycle in couple of next para.

Why do we need maven project?

Earlier project who does not have mavn, they need to add jar files manually & if multiple persons are working on the same project, they have to use same jar files. If one has changed, it cause issues. Also earlier to mavn, we used to create project folder structure by our own. Where as after mavn, this is not manually required, because –

1. In case of maven project, you need not add any jar files in to the project. just add all your dependency in POM.xml file
2. Maven project creates a very good project folder structure for coding purpose.

So, in Short, Maven has two main purposes
  1. Project management (Includes creating folder structure, compiling, packaging etc.)
  2. Dependency management (update dependencies in POM.xml file to download jar automatically)

As i said earlier, maven is a build tool, now let us try and understand what us build tool.

Build tool has a set of processes, certain outcomes like compile source code, copying resources, compiling and running tests, packaging project(in jar or zip file based on selected option), deploying project & finally cleanup. So when you compile your source code using maven, it will create a jar or war file for further use.

All settings of maven project are POM.xml file

What is POM.xml?

POM is an xml file that contain an information about project and configuration details used by mavn to build project. Information is about name, version, artifact it, dependencies, plugin information & profiles. We will talk about POM.xml in more details in coming sessions.

What are important maven objectives?

  1. Making the build process easy.
  2. Provides the uniform build system.
  3. Provide quality project information.
  4. Providing guidelines for best practices development.
  5. Allowing transparent migration to new feature.]

Maven Build Lifecycle –

For the person building a project, this means that it is only necessary to learn a small set of commands to build any Maven project, and the POM will ensure they get the results they desired.

There are three built-in build lifecycles: default, clean and site. The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project’s site documentation.

Each of these build lifecycles is defined by a different list of build phases, wherein a build phase represents a stage in the lifecycle.

maven lifecycle

For example, the default lifecycle comprises of the following phases (for a complete list of the lifecycle phases, refer to the Lifecycle Reference):

  • validate – validate the project is correct and all necessary information is available
  • compile – compile the source code of the project
  • test – test the compiled source code using a suitable unit testing framework. These tests should not require the code be package or deploy.
  • package – take the compiled code and package it in its distributable format, such as a JAR.
  • verify – run any checks on results of integration tests to ensure quality criteria are met
  • install – install the package into the local repository, for use as a dependency in other projects locally
  • deploy – done in the build environment, copies the final package to the remote repository for sharing with other developers and projects.

These lifecycle phases (plus the other lifecycle phases not shown here) are executed sequentially to complete the default lifecycle. Given the lifecycle phases above, this means that when the default lifecycle is used, Maven will first validate the project, then will try to compile the sources, run those against the tests, package the binaries (e.g. jar), run integration tests against that package, verify the integration tests, install the verified package to the local repository, then deploy the installed package to a remote repository.

I will talk about maven in more detail in next articles. Refer below links –

How to download and Install Maven in Eclipse IDE?

How to create Maven Project for Selenium in Eclipse IDE?

 

How to Install Maven in Eclipse IDE ? – Build Tool for java

In this article i will talk about how to install maven in eclipse IDE. Maven is basically a build tool for java based projects.

There are two ways to install maven in eclipse IDE. First one is to install directly in Eclipse IDE via Eclipse MarketPlace / Install new software from help menu of Eclipse IDE & second one is, Install it on your machine manually & then configure the installation details in Eclipse IDE.

Let us talk about both methods.

1.  Install maven directly in eclipse IDE via eclipse marketplace or install new software from help menu

Follow below steps one by one

Open Eclipse, Go to Help Menu on Top right hand side & click on install new software.

Install maven 1

Add depository for downloading M2e as shown in below image.

Install maven 1

Then select work with as the current URL that you have added. It will show you the list of Maven Integration tools for Eclipse IDE. Select the desired one & click on next. Shown in below image

Install maven 1

Click on the next, below screen will show you the current installation items that you have selected.

Install maven 1

Now accept the Terms and conditions of license agreement & click on finish button so as to start with installation of maven plugin inside eclipse IDE. Shown in below image.

Install maven 1

Finally, You can see that software installation has begin. Shown in below image

Install maven 1

Once installation is finished, do restart your machine.

This is how we can install maven inside Eclipse IDE.

 

2. Another way to install maven is Install it in your machine & then configure it in Eclipse IDE.

Follow below steps to get the installation done using above method.

Download Maven files from : https://maven.apache.org/download.cgi

or click here apache-maven-3.5.2-bin.zip

Then Extract it to some folder. Let us say i am extracting it in my C:/ drive. So path of maven files is : C:\apache-maven-3.5.2

Now, Setup Environment Variables.

Go to start program, type “env“, in search result you can find option to edit environment variables. Click on it. Refer below image –

install maven

Once you click on it, System properties will open. Click on Environment variables. As shown in below image.

install maven

Now add below variables by clicking on new button for system variables.

JAVA_HOME=C:\Program Files\Java\jdk1.8.0_111
M2_HOME=C:\apache-maven-3.5.2
M2=%M2_HOME%\bin

Once above variable setup is done, Edit the “Path” variable. Enter below path at the end of current path (Do not modify anything other than this unless you are sure about it)

Path=;%M2%;%JAVA_HOME%\bin

install maven

Once this is done, click on OK. Now you are done with environment variable setup. Now you can verify if maven is installed correctly on your machine or not.

To check this, open command prompt & type below command.

mvn -version

Result of above command should show the currently installed maven version (This means maven is installed correctly) Refer below image.

install maven

Next part is now, to configure this installed maven in to your eclipse IDE.

Before we update anything in Eclipse IDE, first we need to modify setting.xml file from maven installation directory. Here we need to add the path of current maven repository at correct position. refer below image.

Location of settings.xml file: C:\apache-maven-3.5.2\conf\settings.xml

install maven

In the above image, the highlighted line need to be inserted at correct position, as shown above. Save the file.

Now let us update Eclipse IDE. To do this, Click on Window & go to preferences of your Eclipse IDE.

Go to maven –> Installations. Window will looks like below.

install maven

Now click on Add, and add the path of your current maven directory here & Click on OK. refer below image.

install maven

Now go to user Settings in the same menu & add path of your settings.xml file (Located in conf folder of your maven installation directory)

install maven

Click on OK.

That’s it, now done.

Clean your project & start with new maven project. You should be good to start with creation of maven project.

Refer below video for the same –

Refer below article to know about how to create new maven project.

How to create maven project in Eclipse IDE

 

Put your comments if you have any issues !!!! Thanks !!