If this object passing does not works:
await browser.executeScript( "arguments[0].scrollIntoView()", await browser.wait( until.elementLocated( By.xpath( "//div[@jscontroller='MC8mtf']" ) ), 1000 ) );
There is a demonstration for scroll to microphone button, on google page. Found it by javascript xpath, using chromedriver and selenium-webdriver.
start1() start a browser in narrow window, the microphone button does not shows.
start2() start a browser in narrow window, then scroll to microphone button.
require('chromedriver');
const { Builder,
By,
Key,
until
} = require('selenium-webdriver');
async function start1() {
var browser = new Builder()
.forBrowser( 'chrome' )
.build();
await browser
.manage()
.window()
.setRect( { width: 80,
height: 1040,
x:-10,
y:0}
);
await browser.navigate().to( "https://www.google.com/" );
}
async function start2() {
var browser = new Builder()
.forBrowser( 'chrome' )
.build();
await browser
.manage()
.window()
.setRect( { width: 80,
height: 1040,
x:-10,
y:0}
);
await browser.navigate().to( "https://www.google.com/" );
await browser.executeScript( "document.evaluate(\"//div[@jscontroller='MC8mtf']\", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.scrollIntoView(true);");
}
start1();
start2();