-
Notifications
You must be signed in to change notification settings - Fork 54
feat(testcafe): add the support for testcafe #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,7 +125,14 @@ class ResembleHelper extends Helper { | |
const el = els[0]; | ||
|
||
await el.saveScreenshot(this.screenshotFolder + name + '.png'); | ||
} else throw new Error("Method only works with Puppeteer and WebDriver helpers."); | ||
} else if (this.helpers['TestCafe']) { | ||
await helper.waitForVisible(selector); | ||
const els = await helper._locate(selector); | ||
if (!await els.count) throw new Error(`Element ${selector} couldn't be located`); | ||
const { t } = this.helpers['TestCafe']; | ||
|
||
await t.takeElementScreenshot(els, name); | ||
} else throw new Error("Method only works with Puppeteer, WebDriver or TestCafe helpers."); | ||
} | ||
|
||
/** | ||
|
@@ -297,25 +304,18 @@ class ResembleHelper extends Helper { | |
} | ||
|
||
const awsC = this.config.aws; | ||
|
||
if (awsC !== undefined && options.prepareBaseImage === false) { | ||
await this._download(awsC.accessKeyId, awsC.secretAccessKey, awsC.region, awsC.bucketName, baseImage); | ||
} | ||
|
||
if (options.prepareBaseImage !== undefined && options.prepareBaseImage) { | ||
await this._prepareBaseImage(baseImage); | ||
} | ||
|
||
if (selector) { | ||
options.boundingBox = await this._getBoundingBox(selector); | ||
} | ||
|
||
const misMatch = await this._fetchMisMatchPercentage(baseImage, options); | ||
|
||
this._addAttachment(baseImage, misMatch, options.tolerance); | ||
|
||
this._addMochaContext(baseImage, misMatch, options.tolerance); | ||
|
||
if (awsC !== undefined) { | ||
await this._upload(awsC.accessKeyId, awsC.secretAccessKey, awsC.region, awsC.bucketName, baseImage, options.prepareBaseImage) | ||
} | ||
|
@@ -369,17 +369,24 @@ class ResembleHelper extends Helper { | |
const helper = this._getHelper(); | ||
await helper.waitForVisible(selector); | ||
const els = await helper._locate(selector); | ||
if (!els.length) throw new Error(`Element ${selector} couldn't be located`); | ||
const el = els[0]; | ||
|
||
if (this.helpers['TestCafe']) { | ||
if (await els.count != 1) throw new Error(`Element ${selector} couldn't be located or isn't unique on the page`); | ||
} | ||
else { | ||
if (!els.length) throw new Error(`Element ${selector} couldn't be located`); | ||
} | ||
|
||
let location, size; | ||
|
||
if (this.helpers['Puppeteer']) { | ||
const el = els[0]; | ||
const box = await el.boundingBox(); | ||
size = location = box; | ||
} | ||
|
||
if (this.helpers['WebDriver'] || this.helpers['Appium']) { | ||
const el = els[0]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes for the same reason. I didn't like this duplicate of code. But If you have a better solution, I'm ready to implement it. |
||
location = await el.getLocation(); | ||
size = await el.getSize(); | ||
} | ||
|
@@ -388,6 +395,9 @@ class ResembleHelper extends Helper { | |
location = await helper.browser.getLocation(selector); | ||
size = await helper.browser.getElementSize(selector); | ||
} | ||
if (this.helpers['TestCafe']) { | ||
return await els.boundingClientRect; | ||
} | ||
|
||
if (!size) { | ||
throw new Error("Cannot get element size!"); | ||
|
@@ -421,8 +431,11 @@ class ResembleHelper extends Helper { | |
if (this.helpers['WebDriverIO']) { | ||
return this.helpers['WebDriverIO']; | ||
} | ||
if (this.helpers['TestCafe']) { | ||
return this.helpers['TestCafe']; | ||
} | ||
|
||
throw new Error('No matching helper found. Supported helpers: WebDriver/Appium/Puppeteer'); | ||
throw new Error('No matching helper found. Supported helpers: WebDriver/Appium/Puppeteer/TestCafe'); | ||
} | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the need for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this assignment from line 373 here. Because that doesn't work like this for TestCafe.