Udemy Playwright: Web Automation Testing From Zero to Hero: Difference between revisions

Jump to navigation Jump to search
m
Line 643: Line 643:


=== Sliders ===
=== Sliders ===
<nowiki>
test("Sliders", async ({ page }) => {
  // Update attribute
  // const tempGaugeDraggerHandle = page.locator('[tabtitle="Temperature"] ngx-temperature-dragger circle')
  // await tempGaugeDraggerHandle.evaluate(node => {
  //    node.setAttribute('cx',"232.103")
  //    node.setAttribute('cy',"232.103")
  // })
  // await tempGaugeDraggerHandle.click()
  // mouse movement
  const tempGauge = page.locator(
    '[tabtitle="Temperature"] ngx-temperature-dragger'
  )
  tempGauge.scrollIntoViewIfNeeded()
  // probably also need to make sure that the bowser window is big enough to show the whole UI control
  const box = await tempGauge.boundingBox()
  const c = {
    x: box.x + box.width / 2,
    y: box.y + box.height / 2,
  }
  await page.mouse.move(c.x, c.y)
  await page.mouse.down()
  await page.mouse.move(c.x + 100, c.y)
  await page.mouse.move(c.x + 100, c.y + 100)
  await page.mouse.up()
  await page.mouse.click(c.x + 100, c.y + 100)
  // this was needed to get the scenario to run in Playwright UI mode viewer
  await expect(tempGauge).toContainText("30")
})</nowiki>
Notes:
* Had some issues with browser window being too small and interfering with scrolling and mouse actions
* also the UI Mode view doesn't show the temperature UI component correctly, and didn't seem to update the value shown. I added a <code>page.mouse.click(...location...)</code> at the end to fix this.
=== Drag & Drop with iFrames ===
=== Drag & Drop with iFrames ===

Navigation menu