Tags » Framework

I'd say oh so busy, but mostly I forgot

Catching up

Ok, so as I was previously saying, I was working on a mobile app using EmberJS with some JS libraries. It went quite well and I managed to get the app to display the game board and get it installed on an Android phone and working to some degree. 767 more words

Coursework

Codeigniter series

Codeigniter is one of the easy to use PHP web development frameworks and in this series, I would be teaching you how to create a simple blog using Codeigniter. I hope you enjoy it.

Codeigniter

Selenium Automation framework related common commands for Desktop/MObile

Below is the code to customize  selenium commands for both desktop and mobile automaiton.

package dataManagement;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

import io.appium.java_client.MobileDriver;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.remote.MobileBrowserType;
import io.appium.java_client.remote.MobileCapabilityType;

import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriver.Timeouts;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.safari.SafariDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;

import cucumber.api.Scenario;
import testRunner.Starter;

public class Command extends Starter{


 private static Map<String, String> map = new HashMap<String, String>();


 public static void init() throws IOException{
 if(properties("Device").equalsIgnoreCase("Desktop")){
 if(properties("Browser").equalsIgnoreCase("chrome")){
 System.setProperty("webDriver.chrome.driver", "./chromedriver.exe");
 driver = new ChromeDriver();
 }else if(properties("Browser").equalsIgnoreCase("safari")){
 driver = new SafariDriver();
 }
 
 }else if(properties("Device").equalsIgnoreCase("mobile")){
 DesiredCapabilities cap = new DesiredCapabilities();
 cap.setCapability("deviceName", properties("MobileDevice"));
 cap.setCapability("platformName", "iOS");
 cap.setCapability("platformVersion", properties("Version"));
 
 if(properties("Isrealdevice").equalsIgnoreCase("Yes")){
 cap.setCapability(MobileCapabilityType.UDID, properties("UDID")); 
 if(properties("IsmobileBrowser").equalsIgnoreCase("Yes")){
 cap.setCapability(MobileCapabilityType.BROWSER_NAME, properties("Browser"));
 } else {
 cap.setCapability(MobileCapabilityType.APP, properties("AppPath"));
 }
 } else if(properties("IsmobileBrowser").equalsIgnoreCase("Yes")){
 cap.setCapability(MobileCapabilityType.BROWSER_NAME, properties("Browser"));
 if(properties("Browser").equalsIgnoreCase("chrome")){
 cap.setCapability(MobileCapabilityType.APP, properties("AppPath"));
 }
 } else {
 cap.setCapability(MobileCapabilityType.APP, properties("AppPath"));
 }
 idriver = new IOSDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"),cap);
 }
 }
 
 public static void get(String url){
 if(properties("Device").equalsIgnoreCase("mobile"))
 idriver.get(url);
 else if(properties("Device").equalsIgnoreCase("desktop")) 
 driver.get(url);
 }
 
 public static void sendkeys(By locator,String value){
 if(properties("Device").equalsIgnoreCase("mobile"))
 idriver.findElement(locator).sendKeys(value);
 else if(properties("Device").equalsIgnoreCase("desktop")) 
 driver.findElement(locator).sendKeys(value);
 }
 
 public static void click(By locator){
 if(properties("Device").equalsIgnoreCase("mobile"))
 idriver.findElement(locator).click();
 else if(properties("Device").equalsIgnoreCase("desktop"))
 driver.findElement(locator).click();
 }
 public static void submit(By locator){
 if(properties("Device").equalsIgnoreCase("mobile"))
 idriver.findElement(locator).submit();
 else if(properties("Device").equalsIgnoreCase("desktop"))
 driver.findElement(locator).submit();
 }
 
 public static void clear(By locator){
 if(properties("Device").equalsIgnoreCase("mobile"))
 idriver.findElement(locator).clear();
 else if(properties("Device").equalsIgnoreCase("desktop")) 
 driver.findElement(locator).clear(); 
 }
 
 public static String getText(By locator){
 String value="";
 if(properties("Device").equalsIgnoreCase("mobile"))
 value = idriver.findElement(locator).getText();
 else if(properties("Device").equalsIgnoreCase("desktop")) 
 value = driver.findElement(locator).getText(); 
 return value;
 }
 
 public static Select select(By locator){
 Select select = null;
 if(properties("Device").equalsIgnoreCase("mobile"))
 select = new Select(idriver.findElement(locator));
 else if(properties("Device").equalsIgnoreCase("desktop")) 
 select = new Select(driver.findElement(locator)); 
 return select;
 }
 
 public static WebElement explicityElementToBeClickable(By locator, int seconds){
 WebDriverWait wait = null;
 WebElement element = null;
 if(properties("Device").equalsIgnoreCase("mobile"))
 wait = new WebDriverWait(idriver, seconds);
 else if(properties("Device").equalsIgnoreCase("desktop"))
 wait = new WebDriverWait(driver, seconds);
 element = wait.until(ExpectedConditions.elementToBeClickable(locator)); 
 return element;
 }
 public static Boolean explicityElementToBeSelected(By locator, int seconds){
 WebDriverWait wait = null;
 Boolean element = false;
 System.out.println("Wait started");
 if(properties("Device").equalsIgnoreCase("mobile"))
 wait = new WebDriverWait(idriver, seconds);
 else if(properties("Device").equalsIgnoreCase("desktop"))
 wait = new WebDriverWait(driver, seconds);
 element = wait.until(ExpectedConditions.elementToBeSelected(locator)); 
 return element;
 }
 public static Boolean explicityElementSelectionStateToBe(By locator, int seconds, Boolean selected){
 WebDriverWait wait = null;
 Boolean element = false;
 if(properties("Device").equalsIgnoreCase("mobile"))
 wait = new WebDriverWait(idriver, seconds);
 else if(properties("Device").equalsIgnoreCase("desktop"))
 wait = new WebDriverWait(driver, seconds);
 element = wait.until(ExpectedConditions.elementSelectionStateToBe(locator, selected)); 
 return element;
 }
 
 public static Timeouts implicityWait(int seconds){
 Timeouts time = null;
 if(properties("Device").equalsIgnoreCase("mobile"))
 time = idriver.manage().timeouts().implicitlyWait(seconds, TimeUnit.SECONDS);
 if(properties("Device").equalsIgnoreCase("desktop"))
 time = driver.manage().timeouts().implicitlyWait(seconds, TimeUnit.SECONDS);
 return time;
 }
 public static Boolean isDisabled(By locator){
 Boolean value = false;
 if(properties("Device").equalsIgnoreCase("mobile"))
 value = idriver.findElement(locator).isDisplayed();
 else if(properties("Device").equalsIgnoreCase("desktop")) 
 value = driver.findElement(locator).isDisplayed(); 
 return value;
 }
 
 public static Boolean isEnabled(By locator){
 Boolean value = false;
 if(properties("Device").equalsIgnoreCase("mobile"))
 value = idriver.findElement(locator).isEnabled();
 else if(properties("Device").equalsIgnoreCase("desktop")) 
 value = driver.findElement(locator).isEnabled();
 return value;
 }
 
 public static Boolean isSelected(By locator){
 Boolean value = false;
 if(properties("Device").equalsIgnoreCase("mobile"))
 value = idriver.findElement(locator).isSelected();
 else if(properties("Device").equalsIgnoreCase("desktop")) 
 value = driver.findElement(locator).isSelected();
 return value;
 }
 
 public static String getTitle(){
 String title = "";
 if(properties("Device").equalsIgnoreCase("mobile"))
 title = idriver.getTitle();
 else if(properties("Device").equalsIgnoreCase("desktop"))
 title = driver.getTitle();
 return title;
 }
 
 public static String getAttribute(By locator, String value){
 String attributevalue = "";
 if(properties("Device").equalsIgnoreCase("mobile"))
 attributevalue = idriver.findElement(locator).getAttribute(value);
 else if(properties("Device").equalsIgnoreCase("desktop")) 
 attributevalue = driver.findElement(locator).getAttribute(value);
 return attributevalue;
 }
 public static void quit(){
 if(properties("Device").equalsIgnoreCase("mobile"))
 idriver.quit();
 else if(properties("Device").equalsIgnoreCase("desktop")) 
 driver.quit();
 }
 public static Scenario addScreenshot(Scenario scenario){
 
 byte[] screenshot = null;
 try {
 if(properties("Device").equalsIgnoreCase("mobile"))
 screenshot = ((TakesScreenshot) idriver)
 .getScreenshotAs(OutputType.BYTES);
 else if(properties("Device").equalsIgnoreCase("desktop")) 
 screenshot = ((TakesScreenshot) driver)
 .getScreenshotAs(OutputType.BYTES); 
 
 scenario.embed(screenshot, "image/png");
 } catch (Exception e) {
 e.printStackTrace();
 }
 
 return scenario;
 }
 public static String get(String testcasename,String columnname) throws IOException {
 
 FileInputStream fis;
 int k =0;
 try {
 fis = new FileInputStream(properties("DatasheetPath"));
 HSSFWorkbook wb = new HSSFWorkbook(fis);
 HSSFSheet ws = wb.getSheet(properties("Sheetname"));
 int rows = ws.getPhysicalNumberOfRows();
 for(int i=0;i<rows;i++){
 int cols = ws.getRow(0).getPhysicalNumberOfCells();
 for (int j = 0; j < cols; j++) { 
 if(ws.getRow(i).getCell(j,Row.CREATE_NULL_AS_BLANK).toString().replace(".0", ""). 90 more words
Automation Tools

Appium Start and Stop server using Java

Below is the code to start and stop Appium server by using Java without manual interruption.

import io.appium.java_client.ios.IOSDriver;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecuteResultHandler;
import org.apache.commons.exec.DefaultExecutor;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import com.cucumber.listener.ExtentCucumberFormatter;
import com.relevantcodes.extentreports.DisplayOrder;
import com.relevantcodes.extentreports.NetworkMode;
import cucumber.api.CucumberOptions;
import cucumber.api.Scenario;
import cucumber.api.junit.Cucumber;
import dataManagement.Command;

@RunWith(Cucumber.class)

/*
* Set your execution feature path by giving feature value 
and tags value in below Cucumber options
*/

@CucumberOptions(features = {"features/IN-features"},
                 glue = {"stepDefinition"},
                 tags={"@test"},
                 monochrome = true,plugin = 
{"com.cucumber.listener.ExtentCucumberFormatter:output/report.html"})

public class Starter{

protectedstatic WebDriver driver;
protected Scenario scenario;
protected static IOSDriver idriver;
protected String browser = "browser";

@BeforeClass
public static void startServer() {

CommandLine command = new CommandLine(
"/Applications/Appium.app/Contents/Resources/node/bin/node");
command.addArgument(
"/Applications/Appium.app/Contents/Resources
/node_modules/appium/build/lib/main.js",false);
command.addArgument("--address", false);
command.addArgument("127.0.0.1");
command.addArgument("--port", false);
command.addArgument("4723");
command.addArgument("--backend-retries", false);
command.addArgument("0");
command.addArgument("--log-level", false);
command.addArgument("warn:error");
DefaultExecuteResultHandler resultHandler 
= new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
try {
executor.execute(command, resultHandler);
Thread.sleep(10000);
 System.out.println("Appium server started.");
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}

DisplayOrder NEWEST_FIRST = null;
NetworkMode ONLINE = null;
ExtentCucumberFormatter.initiateExtentCucumberFormatter(
new File("./Reports/Auutomation_report.html"),true,NEWEST_FIRST, ONLINE,
 new Locale("en-US"));
ExtentCucumberFormatter.addSystemInfo("Browser Name", "Chrome");
ExtentCucumberFormatter.addSystemInfo("Browser version", "v55.0");
ExtentCucumberFormatter.addSystemInfo("Selenium version", "v2.52.0");
Map<String, String> systemInfo = new HashMap<String, String>();
systemInfo.put("Cucumber version", "v1.2.3");
systemInfo.put("Extent Cucumber Reporter version", "v1.1.1");
ExtentCucumberFormatter.addSystemInfo(systemInfo);
try {
Command.init();
} catch (IOException e) {
e.printStackTrace();
}
}

@AfterClass
public static void stopServer() {

Command.quit();
 System.out.println("Executing After classssss-------------------");
 String[] command = { "/usr/bin/killall", "-KILL", "node" };
try {
Runtime.getRuntime().exec(command);
 System.out.println("Appium server stopped.");
} catch (IOException e) {
e.printStackTrace();
}
}
}
Mobile Automation

Nvidia Vulkan API High-Level Framework for Linux game developers

So Nvidia recently published a #highlevel #abstractionlayer call #VkHLF (Vulkan High-Level Framework). While this is specifically available for the Vulkan API, the framework is an initiative to simplify game development. 19 more words

Programming

Financial Regulation: HKMA to add cyber security, anti-money laundering knowledge to bankers’ certification

Starting in December 2016, new programmes will be added to the HKMA’s Enhanced Competency Framework (ECF) for local bankers

The Hong Kong Monetary Authority said it will require bankers operating in the city to be trained and certified to deal with cyber security and money laundering, beefing up its regulations to prepare for competition with Singapore to be the Asian hub for financial technology. 374 more words