Skip to content
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

postponed image saved in workspace (mobile) #2

Closed
tuan91 opened this issue Jul 4, 2019 · 16 comments
Closed

postponed image saved in workspace (mobile) #2

tuan91 opened this issue Jul 4, 2019 · 16 comments
Assignees
Labels
bug Something isn't working

Comments

@tuan91
Copy link

tuan91 commented Jul 4, 2019

WebdriverIO version: 5.7.15
Mode: WDIO Testrunner
If WDIO Testrunner, running sync/async: sync
Node.js version: 10.15.1
NPM version: 6.4.1
Platform name and version: Browserstack

{
"os_version": "9.0",
"device": "Google Pixel 3",
"real_mobile": "true",
"browserstack.appium_version": "1.12.1"
}

Additional wdio packages used (if applicable): "@wdio/browserstack-service": "^5.7.13", "wdio-image-comparison-service": "^1.1.0"
wdio.conf

services: [["image-comparison",
{
baselineFolder: join(process.cwd(), "./visualRegressionReferenceImages/"),
formatImageName: "{logName}-{tag}-{width}x{height}",
screenshotPath: join(process.cwd(), ".tmp/"),
clearRuntimeFolder: true,
savePerInstance: true,
autoSaveBaseline: true,
blockOutStatusBar: true,
blockOutToolBar: true
}], "browserstack"],

Describe the bug

Visual Regression Test:
expectation:
I want to scroll to an element and save the layout of the element as an image.

Problem only on Mobile:
The image is stored incorrectly. Browserstack indicates that the image was properly saved, but a postponed image is saved in the workspace.
Problem only occurs when several ITs running. If only one IT is running then it will work.

Element:".prod-info__box-container.js-prod-info-box"
URL: https://www.mytoys.de/birkmann-kekskunst-zum-selbermachen-4283014.html

Image Workspace
Mobile-info_Box_with_action_banner-393x658

Image Browserstack
image

approach:
-browser.pause(3000), before save Picture
-Instead of searching at the search bar, we went directly to the specific URL.

To Reproduce

element.scrollIntoView();
browser.saveElement(element, imageNameMobile, {});

browser.checkElement(element, imageNameMobile, {});

@wswebcreation
Copy link
Member

Hi @tuan91

thanks for filling an issue, can you please share the complete code?

Secondly,are you using both commands?

browser.saveElement(element, imageNameMobile, {});

browser.checkElement(element, imageNameMobile, {});

Because the is not needed.

@tuan91
Copy link
Author

tuan91 commented Jul 9, 2019

Hi @wswebcreation
thanks for the fast respond.
code:

if (mtFunctions.isDesktop()) {
            ProductDetailPage.open("10171918");
            ProductDetailPage.getAvaibleProduct(ProductDetailPage.availableVarianteSizeSelect).click();
            browser.pause(2000);
            ProductDetailPage.saveSpecifiedElementLayout(ProductDetailPage.infoBoxLayout, "infobox sizelist selected",
                ProductDetailPage.infoBoxLayout, "infobox sizelist selected");
            ProductDetailPage.checksaveSpecifiedElementLayout(0, ProductDetailPage.infoBoxLayout, "infobox sizelist selected",
                ProductDetailPage.infoBoxLayout, "infobox sizelist selected");
        }
getAvaibleProduct(selector) {
        if (selector.length > 0) {
            return selector[0];
        }
        throw new Error("Kein verfügbares Produkt gefunden!");
    }
saveSpecifiedElementLayout(elementMobile, imageNameMobile, element, imageName) {
        if (mtFunctions.isSmartPhone()) {
            elementMobile.scrollIntoView();
            browser.pause(2000);
            browser.saveElement(elementMobile, imageNameMobile, {});
        } else {
            browser.onload = () => {
                element.waitForDisplayed();
                element.scrollIntoView();
                browser.pause(2000);
                browser.saveElement(element, imageName, {});
            };
        }
    }
checksaveSpecifiedElementLayout(comparisonNumber, elementMobile, imageNameMobile, element, imageName) {
        if (mtFunctions.isSmartPhone()) {
            browser.pause(3000);
            const perCheckMobile = browser.checkElement(elementMobile, imageNameMobile, {});
            if (perCheckMobile > comparisonNumber) {
                throw new Error("expect to be less than " + comparisonNumber + "%! Recent differences:" + perCheckMobile +"%");
            }
        } else {
            browser.onload = () =>{
                browser.pause(3000);
                const perCheck = browser.checkElement(element, imageName, {});
                if (perCheck > comparisonNumber) {
                    throw new Error("expect to be less than " + comparisonNumber + "%! Recent differences:" + perCheck + "%");
                }
            };
        }
    }

I use both methods.
When do I use "saveElement" and when do I use "checkElement"?

Updated with proper markdown

@wswebcreation
Copy link
Member

Hi @tuan91

Thanks for the feedback, I need to dive into the issue, but I'm kinda packed today and tomorrow. I hope to have time for it this week.

When do I use "saveElement" and when do I use "checkElement"?

You only use saveElement when you ONLY want to save an element, not comparing stuff.

The checkElement is used to compare screenshots, this already holds the saveElement because it will automatically make a screenshot of the element, so you don't need to use both

@tuan91
Copy link
Author

tuan91 commented Jul 9, 2019

Hi @wswebcreation
Thanks for the Information.
Unfortunately, it still does not work, with only "checkElement".

I'll wait for your feedback!

@wswebcreation
Copy link
Member

Hi @tuan91

I've been checking this on the Sauce Labs real device cloud (I don't have an account for Browserstack), but all seems to work how it should work.

This is the script I'm using

describe('wdio-test', () => {
    it('issue 2', () => {

        browser.url('https://www.mytoys.de/birkmann-kekskunst-zum-selbermachen-4283014.html');

        const box = $('.prod-info__box-container.js-prod-info-box');

        box.scrollIntoView();
        browser.checkElement(box, 'box-example');
    })
})

And it gives this output

box-example-chrome-393x786

Which is what I expect it to be.

I think the problem in this case is that the element-id is already determined before the scroll really has been executed. This means that when it needs to determine the position (x,y,width, height) of the element, it is not in it's endposition.
I think that if you would use the script above it would work.

Going to close it for now because it looks like it works as designed. It's still open for discussion .

@tuan91
Copy link
Author

tuan91 commented Jul 10, 2019

Hi @wswebcreation
thanks for your Feedback.
It works, when I run one IT. When I run two ITs, it still does not work. The first IT works fine but the second IT still has the same issue.

Can you insert the code in front of your code and run it again?
code:
it('issue 1', () => {

    browser.url('https://www.mytoys.de/anki-anki-cozmo-6853448.html');

    const box = $('.prod-info__box-container.js-prod-info-box');

    box.scrollIntoView();
    browser.checkElement(box, 'box-example1');
})

@wswebcreation
Copy link
Member

Hi @tuan91

Again, it works for me

describe('wdio-test', () => {
    it('issue 1', () => {

        browser.url('https://www.mytoys.de/birkmann-kekskunst-zum-selbermachen-4283014.html');

        const box = $('.prod-info__box-container.js-prod-info-box');

        box.scrollIntoView();
        browser.checkElement(box, 'box-example-1');
    })

    it('issue 2', () => {

        browser.url('https://www.mytoys.de/birkmann-kekskunst-zum-selbermachen-4283014.html');

        const box = $('.prod-info__box-container.js-prod-info-box');

        box.scrollIntoView();
        browser.checkElement(box, 'box-example-2');
    })
})

box-example-1-chrome-393x786

box-example-2-chrome-393x786

@tuan91
Copy link
Author

tuan91 commented Jul 16, 2019

hi @wswebcreation
thanks for your Feedback!
It still does not work, can you lock on my repository?

https://github.com/tuan91/wdio_postponed_layout

@wswebcreation
Copy link
Member

Looks like the link doesn't work

@tuan91
Copy link
Author

tuan91 commented Jul 16, 2019

Oh sorry it was "private".
Now it should work!

@tuan91
Copy link
Author

tuan91 commented Jul 23, 2019

Hi @wswebcreation
is there already a solution?

@wswebcreation
Copy link
Member

Hi @tuan91

I found the problem. It's partially a problem of this module and partially a problem in you capabilities.

This module checks the platform (iOS/Android) based on the platformName. This is mandatory for Appium, but apparently not for BrowserStack. Because you don't provide the capability platformName: 'Android' this module thinks that the screenshot is taken on a desktop (that's why you also got the desktop_ folder name.
If you provide the capability it will work, I'll make a PR to determine the platformName not only based on the capabilities.

@wswebcreation
Copy link
Member

I've release version 1.5.0 that should solve this bug, can you please dowload the lastest version and verify?

https://github.com/wswebcreation/wdio-image-comparison-service/releases/tag/v1.5.0

@tuan91
Copy link
Author

tuan91 commented Jul 31, 2019

Hi @wswebcreation
thanks for your Feedback!

i can't update the latest version. Generally I can't install the module anymore.

Error Massage:

Warning: Missing input files: C:\GTK\bin\libpangoft2-1.0-0.dll C:\GTK\bin\zlib1.dll C:\GTK\bin\libintl-8.dll C:\GTK\bin\libgmodule-2.0-0.dll C:\GTK\bin\libglib-2.0-0.dll C:\GTK\bin\libexpat-1.dll C:\GTK\bin\libpng14-14.dll C:\GTK\bin\libcairo-2.dll C:\GTK\bin\libfontconfig-1.dll C:\GTK\bin\libgobject-2.0-0.dll C:\GTK\bin\libgthread-2.0-0.dll C:\GTK\bin\libpangocairo-1.0-0.dll C:\GTK\bin\libfreetype-6.dll C:\GTK\bin\libpango-1.0-0.dll C:\GTK\bin\libpangowin32-1.0-0.dll Die Projekte in dieser Projektmappe werden nacheinander erstellt. Um eine parallele Erstellung zu ermöglichen, müssen Sie den Schalter "/m" hinzufügen. Backend.cc ImageBackend.cc PdfBackend.cc SvgBackend.cc c:\users\tnguyenduc\documents\github\wdio_postponed_layout\node_modules\canvas\src\backend\Backend.h(3): fatal error C1083: Cannot open include file: 'cairo.h': No such file or directory (compiling sourc e file ..\src\backend\Backend.cc) [C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\canvas.vcxproj] BMPParser.cc c:\users\tnguyenduc\documents\github\wdio_postponed_layout\node_modules\canvas\src\backend\Backend.h(3): fatal error C1083: Cannot open include file: 'cairo.h': No such file or directory (compiling sourc e file ..\src\backend\PdfBackend.cc) [C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\canvas.vcxproj] c:\users\tnguyenduc\documents\github\wdio_postponed_layout\node_modules\canvas\src\backend\Backend.h(3): fatal error C1083: Cannot open include file: 'cairo.h': No such file or directory (compiling sourc e file ..\src\backend\ImageBackend.cc) [C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\canvas.vcxproj] Backends.cc Canvas.cc c:\users\tnguyenduc\documents\github\wdio_postponed_layout\node_modules\canvas\src\backend\Backend.h(3): fatal error C1083: Cannot open include file: 'cairo.h': No such file or directory (compiling sourc e file ..\src\backend\SvgBackend.cc) [C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\canvas.vcxproj] c:\users\tnguyenduc\documents\github\wdio_postponed_layout\node_modules\canvas\src\backend/Backend.h(3): fatal error C1083: Cannot open include file: 'cairo.h': No such file or directory (compiling sourc e file ..\src\Backends.cc) [C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\canvas.vcxproj] CanvasGradient.cc c:\users\tnguyenduc\documents\github\wdio_postponed_layout\node_modules\canvas\src\backend/Backend.h(3): fatal error C1083: Cannot open include file: 'cairo.h': No such file or directory (compiling sourc e file ..\src\Canvas.cc) [C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\canvas.vcxproj] CanvasPattern.cc CanvasRenderingContext2d.cc c:\users\tnguyenduc\documents\github\wdio_postponed_layout\node_modules\canvas\src\CanvasRenderingContext2d.h(5): fatal error C1083: Cannot open include file: 'cairo.h': No such file or directory (compil ing source file ..\src\CanvasRenderingContext2d.cc) [C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\canvas.vcxproj] closure.cc c:\users\tnguyenduc\documents\github\wdio_postponed_layout\node_modules\canvas\src\CanvasPattern.h(5): fatal error C1083: Cannot open include file: 'cairo.h': No such file or directory (compiling source file ..\src\CanvasPattern.cc) [C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\canvas.vcxproj] c:\users\tnguyenduc\documents\github\wdio_postponed_layout\node_modules\canvas\src\backend/Backend.h(3): fatal error C1083: Cannot open include file: 'cairo.h': No such file or directory (compiling sourc e file ..\src\closure.cc) [C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\canvas.vcxproj] color.cc Image.cc c:\users\tnguyenduc\documents\github\wdio_postponed_layout\node_modules\canvas\src\Image.h(5): fatal error C1083: Cannot open include file: 'cairo.h': No such file or directory (compiling source file ..\ src\Image.cc) [C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\canvas.vcxproj] ImageData.cc init.cc ..\src\init.cc(4): fatal error C1083: Cannot open include file: 'pango/pango.h': No such file or directory [C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\canvas.vcx proj] register_font.cc c:\users\tnguyenduc\documents\github\wdio_postponed_layout\node_modules\canvas\src\register_font.h(3): fatal error C1083: Cannot open include file: 'pango/pango.h': No such file or directory (compiling s ource file ..\src\register_font.cc) [C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\canvas.vcxproj] win_delay_load_hook.cc c:\users\tnguyenduc\documents\github\wdio_postponed_layout\node_modules\canvas\src\CanvasGradient.h(7): fatal error C1083: Cannot open include file: 'cairo.h': No such file or directory (compiling source file ..\src\CanvasGradient.cc) [C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\canvas.vcxproj] gyp ERR! build error gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:189:13)
gyp ERR! stack at Process.ChildProcess.handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "build" "--fallback-to-build" "--module=C:\Users\tnguyendu
c\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\Release\canvas.node" "--module_name=canvas" "--module_path=C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node

modules\canvas\build\Release" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64"
gyp ERR! cwd C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas
gyp ERR! node -v v10.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\User
s\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\Release\canvas.node --module_name=canvas --module_path=C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules
\canvas\build\Release --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
node-pre-gyp ERR! stack at ChildProcess. (C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:189:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:970:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Windows_NT 6.1.7601
node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-bu
ild"
node-pre-gyp ERR! cwd C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas
node-pre-gyp ERR! node -v v10.15.1
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\tnguyenduc\Documents\GitHub\w
dio_postponed_layout\node_modules\canvas\build\Release\canvas.node --module_name=canvas --module_path=C:\Users\tnguyenduc\Documents\GitHub\wdio_postponed_layout\node_modules\canvas\build\Release --napi_ve
rsion=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\tnguyenduc\AppData\Roaming\npm-cache_logs\2019-07-31T09_28_13_754Z-debug.log
`
Note: The module works only on linux system, but dosent't work on windows system

Should I create a bug ticket or is this info enough for you?

@wswebcreation
Copy link
Member

Hi @tuan91

Can you recheck again, a new version of node-canvas-prebuilt is released. node-gfx/node-canvas-prebuilt#78

@wswebcreation
Copy link
Member

Closing this one due to inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants