मुख्य सामग्री पर जाएं

scrollIntoView

डेस्कटॉप/मोबाइल वेब और मोबाइल नेटिव ऐप्स के लिए तत्व को व्यूपोर्ट में स्क्रॉल करें।

जानकारी

मोबाइल नेटिव ऐप्स के लिए स्क्रॉलिंग मोबाइल swipe कमांड के आधार पर की जाती है।

उपयोग
$(selector).scrollIntoView({ behavior, block, inline, direction, maxScrolls, duration, scrollableElement, percent })
पैरामीटर्स
नामप्रकारविवरण
options
वैकल्पिक
object, booleanElement.scrollIntoView() के लिए विकल्प। डेस्कटॉप/मोबाइल वेब के लिए डिफ़ॉल्ट:
{ block: 'start', inline: 'nearest' }
मोबाइल नेटिव ऐप के लिए डिफ़ॉल्ट
{ maxScrolls: 10, scrollDirection: 'down' }
केवल डेस्कटॉप/मोबाइल वेब
options.behavior
वैकल्पिक
stringदेखें MDN संदर्भ
केवल-वेब (डेस्कटॉप/मोबाइल)
options.block
वैकल्पिक
stringदेखें MDN संदर्भ
केवल-वेब (डेस्कटॉप/मोबाइल)
options.inline
वैकल्पिक
stringदेखें MDN संदर्भ
केवल-वेब (डेस्कटॉप/मोबाइल)
केवल मोबाइल नेटिव ऐप
options.direction
वैकल्पिक
stringdown, up, left या right में से एक हो सकता है, डिफ़ॉल्ट up है।
केवल-मोबाइल-नेटिव-ऐप
options.maxScrolls
वैकल्पिक
numberस्क्रॉल्स की अधिकतम संख्या जब तक यह तत्व की खोज बंद कर देगा, डिफ़ॉल्ट 10 है।
केवल-मोबाइल-नेटिव-ऐप
options.duration
वैकल्पिक
numberस्वाइप के लिए मिलीसेकंड में अवधि। डिफ़ॉल्ट 1500 ms है। मान जितना कम होगा, स्वाइप उतना ही तेज़ होगा।
केवल-मोबाइल-नेटिव-ऐप
options.scrollableElement
वैकल्पिक
Elementवह तत्व जिसके भीतर स्क्रॉल करने के लिए उपयोग किया जाता है। यदि कोई तत्व प्रदान नहीं किया गया है तो यह iOS के लिए निम्न सेलेक्टर का उपयोग करेगा -ios predicate string:type == "XCUIElementTypeApplication" और Android के लिए निम्न //android.widget.ScrollView'। यदि डिफ़ॉल्ट सेलेक्टर से अधिक तत्व मेल खाते हैं, तो डिफ़ॉल्ट रूप से यह पहले मेल खाने वाले तत्व को चुनेगा।
केवल-मोबाइल-नेटिव-ऐप
options.percent
वैकल्पिक
numberस्वाइप करने के लिए (डिफ़ॉल्ट) स्क्रॉल योग्य तत्व का प्रतिशत। यह 0 और 1 के बीच का मान है। डिफ़ॉल्ट 0.95 है।
कभी भी स्क्रीन के बिल्कुल ऊपर|नीचे|बाएँ|दाएँ से स्वाइप न करें, आप उदाहरण के लिए नोटिफिकेशन बार या अन्य OS/ऐप सुविधाओं को ट्रिगर कर सकते हैं जिससे अप्रत्याशित परिणाम हो सकते हैं।
केवल-मोबाइल-नेटिव-ऐप
उदाहरण
desktop.mobile.web.scrollIntoView.js
it('should demonstrate the desktop/mobile web scrollIntoView command', async () => {
const elem = await $('#myElement');
// scroll to specific element
await elem.scrollIntoView();
// center element within the viewport
await elem.scrollIntoView({ block: 'center', inline: 'center' });
});

mobile.native.app.scrollIntoView.js
it('should demonstrate the mobile native app scrollIntoView command', async () => {
const elem = await $('#myElement');
// scroll to a specific element in the default scrollable element for Android or iOS for a maximum of 10 scrolls
await elem.scrollIntoView();
// Scroll to the left in the scrollable element called '#scrollable' for a maximum of 5 scrolls
await elem.scrollIntoView({
direction: 'left',
maxScrolls: 5,
scrollableElement: $('#scrollable')
});
});

Welcome! How can I help?

WebdriverIO AI Copilot