انتقل إلى المحتوى الرئيسي

إجراء اللمس

تحذير من الاستنساخ

أمر touchAction مستنسخ وسيتم إزالته في إصدار مستقبلي. نوصي باستخدام أمر action بدلاً من ذلك مع نوع المؤشر touch، على سبيل المثال:

await browser.action('pointer', {
parameters: { pointerType: 'touch' }
})

توفر واجهة برمجة إجراءات اللمس الأساس لجميع الإيماءات التي يمكن أتمتتها في Appium. وهي متاحة حاليًا فقط للتطبيقات الأصلية ولا يمكن استخدامها للتفاعل مع تطبيقات الويب. في جوهرها، هناك القدرة على ربط الإجراءات الفردية المخصصة معًا، والتي سيتم بعد ذلك تطبيقها على عنصر في التطبيق على الجهاز. الإجراءات الأساسية التي يمكن استخدامها هي:

  • press (تمرير العنصر أو (x,y) أو كليهما)
  • longPress (تمرير العنصر أو (x,y) أو كليهما)
  • tap (تمرير العنصر أو (x,y) أو كليهما)
  • moveTo (تمرير إحداثيات x,y المطلقة)
  • wait (تمرير ms (بالمللي ثانية))
  • release (بدون وسيطات)
الاستخدام
$(selector).touchAction(action)
المعلمات
الاسمالنوعالتفاصيل
actionTouchActionsالإجراء المراد تنفيذه
مثال
touchAction.js
it('should do a touch gesture', async () => {
const screen = await $('//UITextbox');

// simple touch action on element
await screen.touchAction('tap');

// simple touch action using selector and x y variables
// tap location is 30px right and 20px down relative from the center of the element
await screen.touchAction({
action: 'tap', x: 30, y:20
})

// multi action on an element (drag&drop)
await screen.touchAction([
'press',
{ action: 'moveTo', x: 200, y: 300 },
'release'
])

// drag&drop to element
const otherElement = await $('//UIAApplication[1]/UIAElement[2]')
await screen.touchAction([
'press',
{ action: 'moveTo', element: otherElement },
'release'
])
});

Welcome! How can I help?

WebdriverIO AI Copilot