Handle Dynamic Data
When conducting visual tests, you may encounter scenarios where certain elements within your application change between test runs. These changes might introduce inconsistencies in your test results.You can ignore / select specific element(s) to be removed from the comparison by parsing the options in the smartuiSnapshot
function in the following way
- Ignore ID
- Ignore Class
- Ignore XPath
- Ignore CSS Selector
This is a sample for your configuration for Javascript to ignore by ID
let options = {
ignoreDOM: {
id: ["ID-1", "ID-2"],
}
}
await driver.get('Required URL');
await smartuiSnapshot(driver, 'Screenshot Name', options);
This is a sample for your configuration for Javascript to ignore by Class
let options = {
ignoreDOM: {
class: ["Class-1", "Class-2"],
}
}
await driver.get('Required URL');
await smartuiSnapshot(driver, 'Screenshot Name', options);
This is a sample for your configuration for Javascript to ignore by XPath
let options = {
ignoreDOM: {
xpath: ["Xpath-1", "Xpath-2"],
}
}
await driver.get('Required URL');
await smartuiSnapshot(driver, 'Screenshot Name', options);
This is a sample for your configuration for Javascript to ignore by CSS Selector
let options = {
ignoreDOM: {
cssSelector: ["CSS-Selector-1", "CSS-Selector-2"],
}
}
await driver.get('Required URL');
await smartuiSnapshot(driver, 'Screenshot Name', options);
- Select ID
- Select Class
- Select XPath
- Select CSS Selector
This is a sample for your configuration for Javascript to select by ID
let options = {
selectDOM: {
id: ["ID-1", "ID-2"],
}
}
await driver.get('Required URL');
await smartuiSnapshot(driver, 'Screenshot Name', options);
This is a sample for your configuration for Javascript to select by Class
let options = {
selectDOM: {
class: ["Class-1", "Class-2"],
}
}
await driver.get('Required URL');
await smartuiSnapshot(driver, 'Screenshot Name', options);
This is a sample for your configuration for Javascript to select by XPath
let options = {
selectDOM: {
xpath: ["Xpath-1", "Xpath-2"],
}
}
await driver.get('Required URL');
await smartuiSnapshot(driver, 'Screenshot Name', options);
This is a sample for your webhook configuration for Javascript to select by CSS Selector
let options = {
selectDOM: {
cssSelector: ["CSS-Selector-1", "CSS-Selector-2"],
}
}
await driver.get('Required URL');
await smartuiSnapshot(driver, 'Screenshot Name', options);