Skip to content

Instantly share code, notes, and snippets.

@erdemkiiliic
erdemkiiliic / commonSteps.py
Last active March 21, 2022 18:16
custom success response in locust
def custom_success_response(response, error_code_to_success):
error_name = "err"
if error_name in response.text:
err_code = response.json()[error_name]
if err_code == error_code_to_success:
response.success()
#In this example, when the web service returns 500,
# we considered it successful and did not reflect into the locust statistics.
@erdemkiiliic
erdemkiiliic / BasePage.java
Last active February 14, 2022 14:32
base for selenium project (how to start a selenium project)
public class BasePage {
WebDriver driver;
WebDriverWait webDriverWait;
public BasePage(WebDriver driver){
this.driver=driver;
this.webDriverWait = new WebDriverWait(driver,150);
}
public WebElement findElement(By by){
@erdemkiiliic
erdemkiiliic / BasePage.kt
Last active February 14, 2022 13:02
how to use (variadic) vararg functions in kotlin (espresso waitForView example)
fun waitForElements(vararg elements: Matcher<View>) {
elements.forEach {
Matchers.allOf(it, isDisplayed()).waitForView()
}
}
@erdemkiiliic
erdemkiiliic / locust commands
Last active February 14, 2022 06:20
locust useful commands list
//run with the web UI
locust -f locust_files/my_locust_file.py
//run without the web UI ( u = user, r = spawn rate )
locust -f my_locust_file.py --headless -u 1000 -r 100
/setting a time limit for the test. --run-time or -t
locust -f --headless -u 1000 -r 100 --run-time 1h30m
@erdemkiiliic
erdemkiiliic / Cargo.swift
Created February 13, 2022 22:40
Async get request with URLSession in Swift - mvvm
struct Cargo : Decodable{
let title : String?
let desc : String?
let latitude: Double
let longitude: Double
}
@erdemkiiliic
erdemkiiliic / commonSteps.py
Last active February 13, 2022 22:47
custom error message (failure) in locust
def custom_error_message(response, error_message_name):
error_name = "err"
if error_name in response.text:
err_code = response.json()[error_name]
if err_code != "0":
err_msg = response.json()[error_message_name]
response.failure(error_name + ':' + err_code + ',' + error_message_name + ':' + err_msg)
@erdemkiiliic
erdemkiiliic / BasePage.kt
Last active February 26, 2022 13:19
get text of any element in espresso
fun getText(element: Matcher<View>): String {
return try {
privateGetText(element)
} catch (e: NoMatchingViewException) {
e.toString()
}
}
private fun privateGetText(matcher: Matcher<View>): String {
var text = String()