Hop*_*rka 4 automated-tests base-url playwright
为项目配置和使用 url 的最佳方法是什么
...作为示例,我们有这样的情况
水果应用程序
色彩应用程序
...和这样的测试
test('Navigate to fruits/banana', async () => {
await page.goto('https://https://dev.fruits.com/banana/');
...
});
test('Navigate to colors/red', async () => {
await page.goto('https://https://dev.colors.com/red/');
...
});
Run Code Online (Sandbox Code Playgroud)
...我想去的地方
您可以针对不同的配置使用单独的项目:
// @ts-check
const { devices } = require('@playwright/test');
/**
* @see https://playwright.dev/docs/test-configuration
* @type{import('@playwright/test').PlaywrightTestConfig}
*/
const config = {
projects: [
{
name: 'Fruit Dev',
testMatch: 'fruits/**/*',
use: {
baseURL: 'https://dev.fruits.com'
}
},
{
name: 'Fruit Test',
testMatch: 'fruits/**/*',
use: {
baseURL: 'https://test.fruits.com'
}
},
{
name: 'Fruit Prod',
testMatch: 'fruits/**/*',
use: {
baseURL: 'https://test.fruits.com'
}
},
{
name: 'Color Dev',
testMatch: 'colors/**/*',
use: {
baseURL: 'https://dev.colors.com'
}
},
{
name: 'Color Test',
testMatch: 'colors/**/*',
use: {
baseURL: 'https://test.colors.com'
}
},
{
name: 'Color Prod',
testMatch: 'colors/**/*',
use: {
baseURL: 'https://test.colors.com'
}
},
]
};
module.exports = config;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7774 次 |
| 最近记录: |