Author Archive

Remove vietnammese mark in string

By |

Example: public class CharacterUtils {     private static char[] SOURCE_CHARACTERS = { ‘À’, ‘Á’, ‘Â’, ‘Ã’, ‘È’, ‘É’,             ‘Ê’, ‘Ì’, ‘Í’, ‘Ò’, ‘Ó’, ‘Ô’, ‘Õ’, ‘Ù’, ‘Ú’, ‘Ý’, ‘à’, ‘á’, ‘â’,             ‘ã’, ‘è’, ‘é’, ‘ê’, ‘ì’, ‘í’, ‘ò’, ‘ó’, ‘ô’, ‘õ’, ‘ù’, ‘ú’, ‘ý’,             ‘Ă’, ‘ă’,…

Read more »

Performance test for javascript code

By |

Code: console.time(‘timerName’); //your javascript code console.timeEnd(‘timerName’); Example: console.time(‘timerName’); console.log(“heelo”); console.timeEnd(‘timerName’);

Read more »

Convert string to date in java

By |

try { Date date = new Date(); Calendar cal = Calendar.getInstance(); cal.set(2017, 04, 08); int startYear = cal.get(Calendar.YEAR); int startMonth = cal.get(Calendar.MONTH); int startDay = cal.get(Calendar.DAY_OF_MONTH); System.out.println(“date year ” + startYear); System.out.println(“date month ” + startMonth); System.out.println(“date day ” + startDay); cal.setTime(date); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DAY_OF_MONTH); System.out.println(“date…

Read more »

Date format Java

By |

Letter Date or Time Component Presentation Examples G Era designator Text AD y Year Year 1996; 96 Y Week year Year 2009; 09 M Month in year Month July; Jul; 07 w Week in year Number 27 W Week in month Number 2 D Day in year Number 189 d Day in month Number 10…

Read more »

Run cmd command line on windows by java

By |

ProcessBuilder builder = new ProcessBuilder(“cmd.exe”, “/c”, “adb kill-server && adb start-server && adb devices”); builder.redirectErrorStream(true); Process p = builder.start();

Read more »

Save image in webdriver by java

By |

import java.awt.image.BufferedImage; import java.io.File; import java.net.URL;   WebElement imageEl = driver.findElement(By.xpath(“//img[@alt=’image’]”)); String imageElURL= imageEl .getAttribute(“src”); URL imageURL = new URL(imageElURL); BufferedImage saveImage = ImageIO.read(imageURL); ImageIO.write(saveImage, “png”, new File(“D:” + File.separator + “image.png”));

Read more »

Fix error appium server not start when restart appium

By |

Fix error appium server not start when restart appium

Steps: 1. Open task manager 2. Find node process 3. Kill node and appium process in task manager

Read more »

Run TestNG class in main method

By |

public static void main(String[] args) { TestListenerAdapter testListenerAdapter = new TestListenerAdapter(); TestNG testng = new TestNG(); testng.setTestClasses(new Class[] { test.class }); testng.addListener(testListenerAdapter); testng.run(); }

Read more »

Using dataprovider in TestNG

By |

package com.automation; import …;   @Listeners({com.automation.listenner.Local.class}) public class testClass{ AppiumDriver driver = null; @BeforeMethod public void beforeMethod() { } @DataProvider public Object[][] inputDatas() { Object[][] inputDatas = null; String csvFile = “C:” + File.separator + “file.csv”; try { List<String> lines = Files.readAllLines(new File(csvFile).toPath()); inputDatas = new Object[lines.size()][10]; String[] datas = new String[10]; String line =…

Read more »

Using listener in TestNG class

By |

import com.automation.Example; @Listeners({com.automation.listenner.LocalSuiteListener.class, com.automation.listenner.LocalReportListener.class}) public class testClass{

Read more »