Posts

Protractor - Full Course at one place

Image
  PROTRACTOR API

Cypress

 Cypress  Its   is a free and open source automation tool, MIT-licensed and written in  JavaScript .  -------------------------------------------------------------------------------------------------------------------- Implicit assertion ( it appears on LOGs every time ) ---------------------------------------------------------------------------- cy.url().should('include','theExpectedText')   // to check the particular test inside the respective URL should-contain     .should('contain),'any text') should-have        .should('have.class','abc')     have.text     have.html should-be    .should('be.visible')     be.enabled     be.selected     be.disabled     be.focused = have.focus // We can use two condition to check cy.get('input[name=userName]').should('be.visible').should('be.enabled').type('Hello ...

Useful Command Promt in Automation

dir    / / to check directory dir /b //to get list of files inside that folder  

JavaScriptExecutor

JavaSciptExecutor is an interface which provides mechanism to execute Javascript through selenium driver. JavaScriptExecutor is used when Selenium Webdriver fails to click on any element due to some issue.   JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript(Script,Arguments);   // to enter text  js.executeScript ("document.getElementsByName('uploadfile_0')[0].value='C://Users/ankumalv/Desktop/testNotes.txt'");   // to click   js.executeScript("arguments[0].click();", spaceIsAWebelement);  js.executeScript("alert('Hello world - this is ankur');");     // to get docs  String url = js.executeScript("return document.URL;").toString(); js.executeScript("return document.title;").toString();   //toscroll js.executeScript("window.scrollBy(0,600)"); And below simple prog to upload a file: import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebE...

Karate Framework : Dedicated for API Testing

Image
Here you can find how to use KARATE framework in API Testing, in simple way. Here I have used maven framework: 1. Create a Maven Framework : and respective directories - files & folders;  2. Add dependencies into POM.XML: get it from Maven Repository   1.  karate-core 2. karate-apache 3. karate-junit4    < 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 https://maven.apache.org/xsd/maven-4.0.0.xsd" > < modelVersion > 4.0.0 </ modelVersion > < groupId > KarateTesting </ groupId > < artifactId > KarateTesting </ artifactId > < version > 0.0.1-SNAPSHOT </ version > < dependencies > <!-- https://mvnrepository.com/artifact/com.intuit.karate/karate-core --> < dependency > < groupId > com.intuit.karate ...

Java File Handling

 1. This program helps to create a new file , with their inner content:  package com.test.file ; import java.io.FileOutputStream ; import java.io.IOException ; import java.nio.charset.StandardCharsets ; import java.util.Scanner ; public class CreateNewFIleWithContent { public static void getFileCreated (){ Scanner sc = new Scanner ( System . in ); System . out . print ( " Enter the file name path : " ); String filePath = sc . nextLine (); filePath = filePath . replace ( "/" , " \\ " ); try { FileOutputStream fos = new FileOutputStream ( filePath , true ); System . out . print ( " Enter the content inside the file: " ); String content = sc . nextLine (); fos . write ( content . getBytes ()); fos . close (); } catch ( IOException e ){ e . printStackTrace (); } } public static void main ( String [] args ) {...

Java Selenium Programs & Concepts:

 Refer to this page to have good diving into basics and advanced logical programs used in automating various web pages.  The index are: 1. Using ChromeOptions: To make in use chrome to config download desired folder. 1. Using ChromeOptions: To make in use chrome to config download desired folder.  (This will also not show the Deprecated message as we know that DesiredCapabilities now not in use) String fileNewPath = " C:/User/Documents/Test ";  String filePath = fileNewPath.replace('/', '\\'); Map<String, Object> chromePrefs = new HashMap<String, Object>(); chromePrefs .put(" profile.default_content_settings.popups", 0 ); chromePrefs .put("download.default_directory", filePath ); chromePrefs .put(" download.prompt_for_download ", false ); chromePrefs .put("plugins.plugins_disabled", "Chrome PDF Viewer"); ChromeDriverService service =               new ChromeDriverService.Builder().usingDriverExec...