Skip to content

Instantly share code, notes, and snippets.

@miminari
Last active January 6, 2022 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miminari/cca6307a9811c919824d3592038b28fb to your computer and use it in GitHub Desktop.
Save miminari/cca6307a9811c919824d3592038b28fb to your computer and use it in GitHub Desktop.
/**
* WordPress dependencies
*/
import { visitAdminPage, switchUserToAdmin, switchUserToTest } from '@wordpress/e2e-test-utils';
/**
* Visits general settings page and changes the language to the given vaule.
*
* @param {string} lang Value of the language to set.
*
* @return {string} Value of the previous language.
*/
export async function changeSiteLang(lang) {
await switchUserToAdmin();
await visitAdminPage('options-general.php');
const oldLang = await page.$eval(
'#WPLANG',
(element) => element.options[element.selectedIndex].text
);
await page.select('#WPLANG', lang);
await Promise.all([
page.click('#submit')
]);
await switchUserToTest();
return oldLang;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment