首页 > 其他分享 >[Playwright] Playwright Selectors

[Playwright] Playwright Selectors

时间:2023-01-18 16:24:45浏览次数:49  
标签:Playwright button await page locator test Selectors click

 

import { test } from '@playwright/test';

test.beforeEach(async ({ page }) => {
  await page.goto('http://localhost:3000');
});

test('selectors', async ({ page }) => {
  /** CSS Selector */
  await page.locator('button.primary').click();

  /** Explicit CSS Selector */
  await page.locator('css=button.primary').click();

  /** Text Selector */
  await page.locator('text=submit').click();

  /** Chain Selectors */
    // button: is using css selector
    // text=Submit is using text selector
  await page.locator('button >> text=Submit').click();

  /** nth */
  await page.locator('button >> nth=0').click();

  /** data-test */
  await page.locator('data-test=submit').click();
});

 

标签:Playwright,button,await,page,locator,test,Selectors,click
From: https://www.cnblogs.com/Answer1215/p/17060099.html

相关文章