Closed wswebcreation closed 1 month ago
Hi @berekmerilorand,
I found the reason why it's not working. As mentioned during our call I didn't migrate the option elementBlockOuts
. I now found out I did migrate it, but I renamed it. The reason why you couldn't find it was because I didn't document it 🤦♂️ .
I will document this in the coming days, but here's a way to use the new option. The new option is called ignore
and allows 3 different ways to ignore elements.
it('should compare a screen successful with different ignore options', async () => {
await $('~Login').click()
const result = await driver.checkScreen('app-forms', {
ignore: [
// By ChainablePromiseElement<WebdriverIO.Element>
$('~button-LOGIN'),
// By WebdriverIO.Element
await $('~input-password'),
// By coordinates
{
x: 150,
y: 250,
width: 100,
height: 100,
}
]
}) as number
(await $('~Login')).elementId
expect(result).toEqual(0)
})
this will result in the following
I did not add the margion
property, because if you need to make it bigger then you can first find the coordinates of the element, but using the following
it('should compare a screen successful with a custom resized ignored element', async () => {
await $('~Login').click()
const elementId = (await $('~Login')).elementId
const rectangles = await driver.getElementRect(elementId)
const result = await driver.checkScreen('app-forms', {
ignore: [
// By coordinates
{
x: rectangles.x, // Add or abstract a number
y: rectangles.y, // Add or abstract a number
width: rectangles.width, // Add or abstract a number
height: rectangles.height, // Add or abstract a number
}
]
}) as number
(await $('~Login')).elementId
expect(result).toEqual(0)
})
I will fix the hideElements
for native apps to use the ignore Logic
[!NOTE] If you want to store all diffs you can run the test and add
--store-diffs
as a command line argument
Created this new issue
Have you read the Contributing Guidelines on issues?
WebdriverIO Version
8.39.1
Node.js Version
16.17.1
Mode
Standalone Mode
Which capabilities are you using?
What happened?
I've tried to upgrade our current infrastructure which is using
wdio-native-app-compare-service
tovisual-service
, but unfortunately the elements are not hidden from the images/screenshots diffs.Tried with both below flows:
Infrastructure:
wdio.base.visual.config.ts file contents:
tsconfig.json file contents:
What is your expected behavior?
Elements blocks to be hidden from diff images/screenshots.
How to reproduce the bug.
visual-service
version and make sure baselines (images/ss are saved).elements to be hidden mentioned in blockOuts list
(you've to make sure thatthere is indeed a difference for that element
, in order for that part of the screen to be marked withgreen colour in diffs folder
).Relevant log output
Code of Conduct
Is there an existing issue for this?