scrollIntoView
Scrollt das Element ins Sichtfeld für Desktop/Mobile Web UND Mobile Native Apps.
Info
Das Scrollen für Mobile Native Apps basiert auf dem mobilen swipe
-Befehl.
Dieser Befehl funktioniert nur mit den folgenden aktuellen Komponenten:
- Appium Server (Version 2.0.0 oder höher)
appium-uiautomator2-driver
(für Android)appium-xcuitest-driver
(für iOS)
Stellen Sie sicher, dass Ihre lokale oder Cloud-basierte Appium-Umgebung regelmäßig aktualisiert wird, um Kompatibilitätsprobleme zu vermeiden.
Parameter
Name | Type | Details |
---|---|---|
options optional | object, boolean | Optionen für Element.scrollIntoView() . Standard für Desktop/Mobile Web: { block: 'start', inline: 'nearest' } Standard für Mobile Native App { maxScrolls: 10, scrollDirection: 'down' } |
Nur Desktop/Mobile Web | ||
options.behavior optional | string | Siehe MDN Reference. NUR WEB (Desktop/Mobile) |
options.block optional | string | Siehe MDN Reference. NUR WEB (Desktop/Mobile) |
options.inline optional | string | Siehe MDN Reference. NUR WEB (Desktop/Mobile) |
Nur Mobile Native App | ||
options.direction optional | string | Kann entweder down , up , left oder right sein, Standard ist up . NUR MOBILE-NATIVE-APP |
options.maxScrolls optional | number | Die maximale Anzahl an Scrolls, bis die Suche nach dem Element beendet wird, Standard ist 10 . NUR MOBILE-NATIVE-APP |
options.duration optional | number | Die Dauer in Millisekunden für den Wisch. Standard ist 1500 ms. Je niedriger der Wert, desto schneller der Wisch.NUR MOBILE-NATIVE-APP |
options.scrollableElement optional | Element | Element, in dem gescrollt wird. Wenn kein Element angegeben wird, wird für iOS der folgende Selektor verwendet: -ios predicate string:type == "XCUIElementTypeApplication" und für Android: //android.widget.ScrollView' . Wenn mehrere Elemente dem Standardselektor entsprechen, wird standardmäßig das erste passende Element ausgewählt. NUR MOBILE-NATIVE-APP |
options.percent optional | number | Der Prozentsatz des (Standard-)scrollbaren Elements, der gewischt werden soll. Dies ist ein Wert zwischen 0 und 1. Standard ist 0,95 .NIEMALS vom exakten oberen|unteren|linken|rechten Rand des Bildschirms wischen, da Sie beispielsweise die Benachrichtigungsleiste oder andere Betriebssystem-/App-Funktionen auslösen könnten, was zu unerwarteten Ergebnissen führen kann. NUR MOBILE-NATIVE-APP |
Beispiele
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')
});
});