Skip to content

Instantly share code, notes, and snippets.

@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()
@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 / 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 / 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 / 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 / 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 / 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 / ios15_native_bundle_ids
Created February 17, 2022 21:05
iOS 15 - Bundle IDs for native iOS and iPadOS apps
App Name | Bundle ID
---------------------------------
Activity | com.apple.Fitness
App Store | com.apple.AppStore
Apple Store | com.apple.store.Jolly
Books | com.apple.iBooks
Calculator | com.apple.calculator
Calendar | com.apple.mobilecal
Camera | com.apple.camera
Clips | com.apple.clips
@erdemkiiliic
erdemkiiliic / XCUIElement+Wait.swift
Last active March 6, 2022 18:19 — forked from ryanpato/XCUIElement+Wait.swift
Clean waiting in XCUITest
//
// XCUIElement+Wait.swift
//
// Created by Ryan Paterson on 12/12/2020.
//
import XCTest
extension XCUIElement {
@erdemkiiliic
erdemkiiliic / MatcherExtensions.kt
Last active March 2, 2023 12:45
Clean waiting in Espresso (Kotlin)
fun Matcher<View>.doOnView(vararg actions: ViewAction) {
doOnView_Method(matcher = this, actions = *actions)
}
fun Matcher<View>.assertOnView(vararg assertions: ViewAssertion) {
assertOnView_Method(matcher = this, assertions = *assertions)
}
fun Matcher<View>.waitForView(millis: Int = 5000, millisPerTry: Long = 200): ViewInteraction {
return waitForView_Method(viewMatcher = this, waitMillis = millis, waitMillisPerTry = millisPerTry)