Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

185
Visualizações
playwright javascript wait for link to be bold

Im currently facing a problem using playwright where I need to click a link, and then wait for it to turn bold. I can find the element itself and click it using:

await page.click("a[id$='clickablelink_0']")

and I am currently waiting for to change when I see a class (which adds bold) added to the element:

await page.waitForSelector("a[id$='clickablelink_0'][class~=xmp]")

However this class name is changing every so often. Is there a way instead of using the class, look directly for the value of "font-weight"? ideally as a ">=" to a value?

Just some notes:

  • I cant change any code generating this page
  • I have looked for other ways to determine this was clicked, but the other ways are less deterministic
  • its a private page and unfortantly can not sure it out

Thanks!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In case of asserting a css property you can use the expect toHaveCSS() assertion for this. You can play around with the timeout as well, by default expect assertions have a 5 second timeout. Now you can increase the timeout for specific assertions as shown below or globally as well.

await expect(page.locator("a[id$='clickablelink_0'][class~=xmp]")).toHaveCSS(
  'font-weight',
  '30px',
  {timeout: 7000}
)

Or, if you want to extract the value of font-weight and then apply an assertion for greater than, you can do like this:

const element = await page.waitForSelector(
  "a[id$='clickablelink_0'][class~=xmp]"
)
const fontWeight = await element.evaluate((el) => {
  return window.getComputedStyle(el).getPropertyValue('font-weight')
})
//extracting and converting number
expect(+fontWeight.replace(/\D/g, '')).toBeGreaterThan(30)
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda