Skip to content

Instantly share code, notes, and snippets.

View cuhavp's full-sized avatar
🪲
Hunting bugs

Ha Do cuhavp

🪲
Hunting bugs
  • Testingvn.com
  • Vietnam
View GitHub Profile
@cuhavp
cuhavp / gatlingClusterRun.sh
Created June 28, 2021 07:23 — forked from Nimrod007/gatlingClusterRun.sh
Gatling - running on multiple machines and aggregating the results
#!/bin/bash
##################################################################################################################
#Gatling scale out/cluster run script:
#Before running this script some assumptions are made:
#1) Public keys were exchange inorder to ssh with no password promot (ssh-copy-id on all remotes)
#2) Check read/write permissions on all folders declared in this script.
#3) Gatling installation (GATLING_HOME variable) is the same on all hosts
#4) Assuming all hosts has the same user name (if not change in script)
##################################################################################################################
package testcases;
import configuration.BaseTest;
import org.openqa.selenium.By;
import org.openqa.selenium.support.How;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public enum Browser {
CHROME("chrome") {
public WebDriver open() {
return new ChromeDriver();
}
},
FIREFOX("firefox") {
public WebDriver open() {
return new FirefoxDriver();
}
driver.findElement(By.id("username")).sendKeys("tomsmith");
driver.findElement(By.id("username")).sendKeys("tomsmith");
driver.findElement(By.tagName("input")).sendKeys("tomsmith");
driver.findElement(By.xpath("//input")).sendKeys("tomsmith");
driver.findElement(By.name("username")).sendKeys("tomsmith");
driver.findElement(By.cssSelector("input")).sendKeys("tomsmith");
driver.findElement(By.xpath("//*[@type='text']")).sendKeys("tomsmith");
driver.findElement(By.xpath("//*[@id='username']")).sendKeys("tomsmith");
driver.findElement(By.cssSelector("input#username")).sendKeys("tomsmith");
driver.findElement(By.xpath("//*[@name='username']")).sendKeys("tomsmith");
package libraries;
import object.TodoPage;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.How;
import java.util.List;
import java.util.stream.Collectors;
@cuhavp
cuhavp / selenium common function
Last active November 5, 2019 03:14
CommonFunction.java
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class Table {
public static void main(String[] args) {
CommonFunctions.openBrowser("chrome");
CommonFunctions.visit("https://the-internet.herokuapp.com/tables");
List<WebElement> rowsTable1 = CommonFunctions.getElements(How.XPATH, "//table[@id='table1']/tbody/tr/td1");
System.out.println("Total rows: " + rowsTable1.size());
[UiAutomator2] Starting uiautomator2 server 1.12.0
[UiAutomator2] Using UIAutomator2 server from '/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-v1.12.0.apk' and test from '/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk'
[UiAutomator2] Running command: 'adb -s 52009bf3ec7b749f shell am instrument -w io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner'
[UiAutomator2] Waiting up to 20000ms for UiAutomator2 to be online...
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [UiAutomator2] [UIAutomator2] java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner} from pid=28208, uid=28208 not allowed because package io.appium.uiautomator2.server.test does not have a signature m
@cuhavp
cuhavp / BaseTest.java
Created June 30, 2018 07:59
Abstract Base Test
public class BaseTest {
@Parameters("browser")
@BeforeTest
public void setUp(String browser) {
launchBrowser(browser);
}
@Parameters("url")
@BeforeMethod
public void init(String url) {
[Appium] Welcome to Appium v1.7.2
[Appium] Non-default server args:
[Appium] port: 4876
[Appium] sessionOverride: true
[Appium] Appium REST http interface listener started on 0.0.0.0:4876
[HTTP] --> GET /wd/hub/status {}
[debug] [MJSONWP] Calling AppiumDriver.getStatus() with args: []
[debug] [MJSONWP] Responding to client with driver.getStatus() result: {"build":{"version":"1.7.2","revision":null}}
[HTTP] <-- GET /wd/hub/status 200 13 ms - 72
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"app":"/Users/misfit/Jenkins/workspace/UI/QA-SMOKE-UI-TEST/apps/FossilQ_3_0-14121.apk","automationName":"UIAutomator2","chromedriverExecutable":"/Users/dtha/Desktop/chromedriver","deviceName":"android","newCommandTimeout":900,"noReset":false,"platformName":"ANDROID"},"capabilities":{"desiredCapabilities":{"app":"/Users/misfit/Jenkins/workspace/UI/QA-SMOKE-UI-TEST/apps/FossilQ_3_0-14121.apk","automationName":"UIAutomator2","chromedriverExecutable":"/Users/dtha/Desktop/chromedriver","deviceName":"android","newCom