Posted in Selenium

SelectorsHUB : A New Reality to build your own XPath & cssSelector quickly

Selector

Recently Sanjay Kumar Conducted a Poll to know the preferable way to create/fetch the Xpath and found 79% of people love to create XPath by own. So in the market, most of tool provide you the XPath directly and sometimes its fails when the website is too dynamic in Nature. So now we have an innovative tool with us, i.e. SelectorsHub a free community browser plugin to create and verify custom XPath with some advanced feature.
Some feature of Selector hub

  1. Attribute Autosuggest
  2. SVG Support
  3. Shadow Dom and iFrame support
  4. Error message with the missing elements
  5. Secure plugin

How to Install Selectors hub in chrome browser

Click on below link to install Selectors hub in your Chrome browser

https://chrome.google.com/webstore/detail/selectorshub/ndgimibanhlabgdgjcpbbndiehljcpfh/

Click on add to chrome >Add Extension

The selectors hub is now ready to use.
Steps to use the tool-

  1. Open Dev Tools.
  2. On right side, the last sidebar tab is Selectors Hub. Click on it. If not visible, expand the sidebar.
  3. Here in the Selectors box start typing your selector XPath/CSS selector.
  4. Selectors Hub will automatically suggest tagName, all attributes and everything to complete Selectors quickly. Now you need not to copy and paste attribute values from DOM anymore. With SelectorsHub you can save a huge amount of time.
  5. After completing Selector just press enter and it will show the total number of matching elements.
  6. It will high light all matching node and list down them in the SelectorsHub tab.
  7. It will scroll the web element to viewable area if it is not in the viewable area.
  8. To copy selectors value, just double click anywhere in the box or click on XPath/CSS selector title box.

 

Now it support all the major browser like Chrome, Firefox, Edge, opera, Brave, Safari, chromium and Tor

For Detailed Workflow and complete tutorial please visit: https://www.selectorshub.com/what-is-selectorshub/

And for video Tutorial please visit: https://www.youtube.com/watch?v=NNTJyVb7P7U

Reference: https://www.selectorshub.com/what-is-selectorshub/

Keep Learning, Keep sharing..

Posted in Automation Testing Tool, chrome, Selenium

Automate and Test your Web page in Chrome emulator and Chrome View point using selenium and Java.

Now a days most of the application/url having compatibility to open in responsive or in emulator,So lot of people worried how to open these url in chrome emulator or view point using Selenium and java.

So here is the solution,Please go through this code and verify your site in chrome emulator or in View point.

Prerequisite:

You should have Java8, Selenium 3.14 + Jar in your system.I already mentioned in previous blog how to set browser path.Link

Example 1.

To open Url in chrome Nexus emulator:

Here i am using Google page to open in chrome Iphone Emulator

package testEmulatorOnChrome;
/*
* prerequisite to run this code you need
* Java 8, Selenium 3.14 +, and chrome driver
* To download all these you can visit
*/

import java.util.HashMap;
import java.util.Map;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class TestEmulatorChrome {
public static void main(String[] args) {
Map<String, String> mobileEmulation = new HashMap<>();

mobileEmulation.put(“deviceName”, “iPhone 5”); //You can use various device like iPad,iPhone,Nexus etc.
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption(“mobileEmulation”, mobileEmulation);
System.setProperty(“webdriver.chrome.driver”,”D:\\Software\\chromedriver.exe”);
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get(“https://www.google.com&#8221;);
driver.findElement(By.name(“q”)).sendKeys(“globallogic”);
driver.findElement(By.xpath(“//*[@id=\”tsf\”]/div[2]/div[1]/div[1]/button[2]”)).click();

}
}

Example 2:

To open Url in chrome View Point:

package testEmulatorOnChrome;
/*
* prerequisite to run this code you need
* Java 8, Selenium 3.14 +, and chrome driver
* To download all these you can visit
*/

import java.util.HashMap;
import java.util.Map;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class TestMultibrowser2 {
public static void main(String[] args) {

Map<String, Object> deviceMetrics = new HashMap<>();
deviceMetrics.put(“width”, 360);
deviceMetrics.put(“height”, 640);
deviceMetrics.put(“pixelRatio”, 4.0);

Map<String, Object> mobileEmulation = new HashMap<>();
mobileEmulation.put(“deviceMetrics”, deviceMetrics);
ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setExperimentalOption(“mobileEmulation”, mobileEmulation);
System.setProperty(“webdriver.chrome.driver”,”D:\\Software\\chromedriver.exe”);
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get(“https://www.google.com&#8221;);
driver.findElement(By.name(“q”)).sendKeys(“globallogic”);
driver.findElement(By.name(“btnK”)).submit();

}
}

In case you find difficulty please let me know,

 

Here are some list of device you can use in this code..

Thanks, Keep learning New things….

Abhishek

Posted in Automation Testing Tool, Selenium

JUnit 4 vs JUnit 5:An Overview

Junit5

JUnit5, the Next Generation Junit. A Regression Testing Framework used by developers and tester to implement unit and functional testing in Java and Selenium, to accelerate programming speed and increase the quality of code. JUnit Framework can be easily integrated with either of the following –Eclipse, Ant, Maven. Junit5 introduces New Assert and Annotations to test your code more efficiently.

Junit5 requires Java 8 and above Java version and some useful annotations are:

@ParameterizedTest: Denotes that a method is a parameterized test. Such methods are inherited unless they are overridden.

 

@RepeatedTest: Denotes that a method is a test template for a repeated test. Such methods are inherited unless they are overridden.

@DisplayName: Declares a custom display name for the test class or test method. Such annotations are not inherited.

@BeforeEach: Denotes that the annotated method should be execute before each @Test,@RepeatedTest, @ParameteizedTest or @Test Factory method in the current class; analogous to JUnit 4’s @Before. Such methods are inherited unless they are overridden.

@AfterEach: Denotes that the annotated method should be executed after  @Test

@AfterAll:Denotes that the annotated method should be executed after @RepeatedTest@ParameterizedTest, and @TestFactory methods in the current class; analogous to JUnit 4’s @AfterClass. Such methods are inherited (unless they are hidden or overridden) and must be static (unless the “per-class” test instance lifecycle is used).

@Tag: Used to declare tags for filtering tests, either at the class or method level; analogous to test groups in TestNG or Categories in JUnit 4. Such annotations are inherited at the class level but not at the method level.

Screen Shot 2018-08-07 at 4.12.22 PM

Asserts in Junit:

Screen Shot 2018-08-07 at 4.13.42 PM

For More Information you may visit JUnit Official site Click here and For comparison with JUnit 4 you may visit click here

Reference:https://junit.org/junit5/docs/current/user-guide/

Posted in Selenium

ChroPath: An Alternative Add on to FirePath and Xpath finder

As we all know in Firebug and Firepath is deprecatede with New version Firefox ,And its very difficut to verify your customized xpath in current version firefox.

So Finally i found a solution for this i.e “ChroPath

[EDIT:Now the chropath is available for Firefox,chrome,opera and Edge browser and version 6.0 having various feature like record the steps,get all xpath altogether in csv file,get xpath using desired attribute and many more.As lots of tutorial and blogs are available so will share the link of the blogs and tutorials in this post itself https://medium.com/@mailcoolsanjay/what-are-the-unique-innovation-in-autonomiq-chropath-6-0-version-2b1b1984a4c8]

About this extension:

ChroPath is a developer tool, which is used to edit, inspect and generate relative xpath, absolute xpath and CSS selectors. ChroPath makes it easy to write, edit, extract, and evaluate XPath queries on any webpage. ChroPath is the only tool for now which provide the unique Relative xpath and CSS selector for any web element in webpage in Firefox and Chrome. ChroPath is very good alternative for Firebug and Xpath Finder.

Screen Shot 2018-07-16 at 12.10.13 PM

Screen Shot 2018-08-08 at 10.34.30 AM

The link for Chrome browser-
https://chrome.google.com/webstore/detail/chropath/ljngjbnaijcbncmcnjfhigebomdlkcjo?hl=en

The link for Firefox browser-

https://addons.mozilla.org/en-US/firefox/addon/chropath-for-firefox/

How to use ChroPath –

  1. Right-click on the web page, and then click Inspect
  2. In devtools panel click on ChroPath tab.
  3. Click on ChroPath tab and click on selector to Select the Type of Selector.
  4. Click on Select Element button and hover to the element , You can observer the Xpath or CSS As per your selection
  5. Now if you want to see the all node of the page write // node name and enter, Eg://div
  6. Now you can create Xpath as per your requirement
  7. You can verify the xpath by clicking enter.

Note:
1- Click again on inspect to disable the inspect action.
2- Tool will add xpath/css attribute to all the matching node(s) as per their sequential occurrence. For example, a matching node appearing second in the list will have xpath=2. And if verifying CSS then it will add css=2.

Ref: From the post of Sanjay Kumar(Medium.com)

Posted in Automation Testing Tool

Katalon Studio:An open source Automation tool

Katalon Studio is a comprehensive toolset for web and mobile app automation testing. This tool includes powerful features that help overcome common challenges in web UI test automation, for example, window popup, frames, wait, dropdown and many more inbuilt functions. This is user-friendly and help tester in automation to create regression suit better and faster even without prior knowledge of Scripting.

The tool is open source and can be downloaded at https://www.katalon.com.

Feature:

Katalon Studio is open source framework which comes with some advanced inbuild feature, Some of advanced feature are:

  • Support Web and mobile testing
  • Integrated with Restful and soup web services
  • You can pull test cases from JIRA
  • Inbuilt GIT repository support
  • Data management is very easy it support excel, database data,csv data and internal data.
  • Record and play funtionality
  • Even without prior knowledge of script you can create test cases.
  • User friendly
  • Suports groovy
  • Inbuilt functions

 Setup Katalon Studio in mac:

1.Redirected to https://www.katalon.com

2.Sign up for katalon studio

3.Download the .dmg file for mac

4.Install the package in Application folder

5.Open katalon studio enter userid and password and create a new project

6.Create new test case.

7.Record the test steps by clicking web recording button,after clicking the recording button a pop up will open(You can write the test script in groovy too)

8.Provide the test url and select the desired browser and click in browser icon.

9.After performing steps click on ok button

10.you will find test steps in created test case file

11.Execute the test case after selecting browser.

Note:You can insert assert or condition statement by adding Assert statement and decision making statement in test steps

[This is the basic steps of katalon studio,you can perform varios automation related activity using this powerful automation tool.]

Please let me know if you having any query related to this,For more you can visit

https://www.katalon.com/katalon-studio/

Thanks

Abhishek Roy