我正在尝试一些非常简单的事情:
如此简单,但我无法让它发挥作用。这是代码:
const playwright = require('playwright');
(async () => {
for (const browserType of ['chromium', 'firefox', 'webkit']) {
const browser = await playwright[browserType].launch();
try {
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://google.com');
await page.fill('input[name=q]', 'cheese');
await page.press('input[name=q]', 'Enter');
await page.waitForNavigation();
page.waitForSelector('div#rso h3')
.then(firstResult => console.log(`${browserType}: ${firstResult.textContent()}`))
.catch(error => console.error(`Waiting for result: ${error}`));
} catch(error) {
console.error(`Trying to run test on ${browserType}: ${error}`);
} finally {
await browser.close();
}
}
})(); …Run Code Online (Sandbox Code Playgroud) 我有一个可以本地化为多种语言的应用程序。但是我有一个大麻烦。我有默认文件 values/strings.xml ,默认情况下我用英语存储字符串,我有文件夹 values-uk/strings.xml (用于乌克兰本地化)。我正在 SharedPreferences 中保存选定的本地化。问题是当应用程序启动时没有任何选定的语言首选项(但设备的系统语言是乌克兰语,我检查过)我的应用程序必须从 values-uk/strings.xml 加载乌克兰语字符串,但它从值/字符串加载英语值。 xml。谁能解释一下为什么会发生这种情况以及如何解决这个问题。非常感谢!