find_element(AppiumBy.ID, "xxx")の"xxx"にid属性値を指定することで要素を取得することが出来ます。
下記のサンプルでは、まずアプリの上部にあるテキストボックスの要素を取得しています。次にその要素に対し「click」を実行し文字列入力が可能になった後、文字列を入力しています。
※Appiumでのid属性値などの要素調査方法についてはこちらを参考にしてください。
説明
◆メソッド
○id属性から要素を取得する
・driver.find_element(AppiumBy.ID, "xxx")
○要素をクリックする
・element.click()
◆備考
・セッション作成時にアプリ(.apk)を指定せずに、activate_app()でアプリを起動した場合は、
id属性値での要素取得はパッケージ名も指定する必要があります。
例:find_element(AppiumBy.ID,"com.example.appium_test_app:id/etName")
◆その他「Appium API」
・XPathから要素を取得する
・要素にキー入力した値を取得/クリアするサンプル
from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy
#接続したいアプリ情報を変数に格納
desired_caps = {}
desired_caps["appium:app"] = "C:\\appium_test\\app-debug.apk"
desired_caps["platformName"] = "Android"
desired_caps["platformVersion"] = "12.0"
desired_caps["appium:deviceName"] = "PixelXLAPI31"
desired_caps["appium:automationName"] = "UiAutomator2"
#セッションの作成
test_session = webdriver.Remote(
command_executor='http://localhost:4723/wd/hub',
desired_capabilities= desired_caps)
#テキストボックスの要素をID属性値から取得する
element = test_session.find_element(AppiumBy.ID, "etName")
#テキストボックスをクリックする
element.click()
#文字列を入力する
element.send_keys("Appiumでのテスト")
※Appium v2.0.0-beta.55で動作確認をしています

