Skip to content

Instantly share code, notes, and snippets.

import wd from 'wd';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
const PORT = 4723;
const config = {
platformName: 'Android',
deviceName: 'Android Emulator',
app: './android/app/build/outputs/apk/app-debug.apk' // relative to root of project
};
const driver = wd.promiseChainRemote('localhost', PORT);
render() {
return (
<View style={styles.container} accessibilityLabel="testview">
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
...
)
}
test('appium button click', async () => {
expect(await driver.hasElementByAccessibilityId('button')).toBe(true);
await driver.elementByAccessibilityId('button')
.click()
.click();
const counter = await driver.elementByAccessibilityId('counter').text();
expect(counter).toBe('2');
});
test('appium text input', async () => {
const TEXT = 'hello this is appium';
await driver.elementByAccessibilityId('textinput')
.type(TEXT);
const resultText = await driver.elementByAccessibilityId('text').text();
expect(resultText).toBe(TEXT)
});
export default class appiumTutorial extends Component {
state = {
counter: 0
}
onPress = () => this.setState({ counter: this.state.counter + 1 })
render() {
return (
<View style={styles.container} accessibilityLabel="testview">
export default class appiumTutorial extends Component {
state = {
counter: 0,
text: '',
}
onPress = () => this.setState({ counter: this.state.counter + 1 })
onChangeText = text => this.setState({ text })
render() {
import pytest
import os
from appium import webdriver
@pytest.fixture(scope="function")
def driver():
driver = webdriver.Remote(
command_executor='http://127.0.0.1:4723/wd/hub',
desired_capabilities={
def test_basic(driver):
WAIT_SEC = 10
driver.implicitly_wait(WAIT_SEC)
elem = driver.find_element_by_accessibility_id('testview')
assert elem is not None
def test_button(driver):
WAIT_SEC = 10
driver.implicitly_wait(WAIT_SEC)
btn = driver.find_element_by_accessibility_id('button')
btn.click()
btn.click()
counter = driver.find_element_by_accessibility_id('counter')
assert counter.text == '2'
import pytest
import os
from appium import webdriver
AWS = 'aws'
LOCAL = 'local'
def get_desired_capabilities(location=AWS):
if location == LOCAL: