Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

check_region of entire element fails in versions apper 3.12.0 #32

Open
eirenik0 opened this issue Dec 4, 2018 · 18 comments
Open

check_region of entire element fails in versions apper 3.12.0 #32

eirenik0 opened this issue Dec 4, 2018 · 18 comments
Labels

Comments

@eirenik0
Copy link
Member

eirenik0 commented Dec 4, 2018

Version 3.12.0 is able to take screenshot of the entire element while higher versions can't.

https://trello.com/c/zBqG4fkj/330-python-check-region

@eirenik0 eirenik0 added the bug label Dec 4, 2018
@eirenik0 eirenik0 closed this as completed Dec 4, 2018
@eirenik0 eirenik0 reopened this Dec 4, 2018
@nunessf
Copy link

nunessf commented Mar 7, 2019

Might this be the reason why I can't use Check Region By Element on native apps? And if so, any idea when it might be resolved?

@eirenik0
Copy link
Member Author

Hi @nunessf, actually this functionality wasn't tested yet. Which error did you get?

@nunessf
Copy link

nunessf commented Mar 11, 2019

It throws this exception:
WebDriverException: Message: Method is not implemented

On appium logs:

[debug] [W3C (ec773ebb)] Calling AppiumDriver.execute() with args: ["return arguments[0].style.overflow;",[{"element-6066-11e4-a52e-4f735466cecf":"fb1e555d-56b9-4540-85d5-f3bfd2461c32","ELEMENT":"fb1e555d-56b9-4540-85d5-f3bfd2461c32"}],"ec773ebb-8612-4343-bf50-6412c6b44dc8"]
[debug] [W3C (ec773ebb)] Encountered internal error running command: NotImplementedError: Method is not implemented
[debug] [W3C (ec773ebb)]     at AndroidUiautomator2Driver.extensions.execute (C:\Users\USER-Admin\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\commands\execute.js:12:9)
[debug] [W3C (ec773ebb)]     at curCommandCancellable._bluebird.default.resolve.then (C:\Users\USER-Admin\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\driver.js:291:18)
[debug] [W3C (ec773ebb)]     at tryCatcher (C:\Users\USER-Admin\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\node_modules\bluebird\js\main\util.js:26:23)
[debug] [W3C (ec773ebb)]     at Promise._settlePromiseFromHandler (C:\Users\USER-Admin\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\node_modules\bluebird\js\main\promise.js:510:31)
[debug] [W3C (ec773ebb)]     at Promise._settlePromiseAt (C:\Users\USER-Admin\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\node_modules\bluebird\js\main\promise.js:584:18)
[debug] [W3C (ec773ebb)]     at Promise._settlePromiseAtPostResolution (C:\Users\USER-Admin\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\node_modules\bluebird\js\main\promise.js:248:10)
[debug] [W3C (ec773ebb)]     at Async._drainQueue (C:\Users\USER-Admin\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\node_modules\bluebird\js\main\async.js:128:12)
[debug] [W3C (ec773ebb)]     at Async._drainQueues (C:\Users\USER-Admin\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\node_modules\bluebird\js\main\async.js:133:10)
[debug] [W3C (ec773ebb)]     at Immediate.Async.drainQueues (C:\Users\USER-Admin\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\node_modules\bluebird\js\main\async.js:15:14)
[debug] [W3C (ec773ebb)]     at runCallback (timers.js:705:18)
[debug] [W3C (ec773ebb)]     at tryOnImmediate (timers.js:676:5)
[debug] [W3C (ec773ebb)]     at processImmediate (timers.js:658:5)

@eirenik0
Copy link
Member Author

Ok, thanks. I see there many things should be changed to support this feature. Currently, I'm busy with other tasks, could make this fix in a week...

@nunessf
Copy link

nunessf commented Mar 11, 2019

Alright, thank you!

@ludovicmcosta
Copy link

Hello, Any news about the problem reported by @nunessf ?

@eirenik0
Copy link
Member Author

hi @ludovicmcosta! Have you tried 4.x version of sdk?

@ludovicmcosta
Copy link

Yes, I have the following: eyes-selenium 4.0.8

Should the problem be fixed in this version?

@eirenik0
Copy link
Member Author

Oh, sorry, just checked that this is related to native apps. This behave for native apps isn't supported yet.

@ludovicmcosta
Copy link

Thanks for the quick answer :)

The problem reported by @nunessf was also obtained when we execute the example in https://applitools.com/tutorials/appium-native-python.html#run-your-first-test.

When method eyes.open() is executed the error below is displayed (appium logs). Is this issue related to native apps as well?

[debug] [W3C (14623234)] Calling AppiumDriver.execute() with args: ["\n var height = undefined;\n var width = undefined;\n if (window.innerHeight) {\n height = window.innerHeight;\n } else if (document.documentElement && document.documentElement.clientHeight) {\n height = document.documentElement.clientHeight;\n } else {\n var b = document.getElementsByTagName('body')[0];\n if (b.clientHeight) {height = b.clientHeight;}\n }\n if (window.innerWidth) {\n width = window.innerWidth;\n } else if (document.documentElement && document.documentElement.clientWidth) {\n width = document.documentElement.clientWidth;\n } else {\n var b = document.getElementsByTagName('body')[0];\n if (b.clientWidth) {\n width = b.clientWidth;}\n }\n return [width, height];",[],"14623234-013b-4d3f-b34b-d05282a0d447"]
[debug] [W3C (14623234)] Encountered internal error running command: NotImplementedError: Method is not implemented
[debug] [W3C (14623234)] at AndroidUiautomator2Driver.execute (C:\Users\ludovic.costa\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\commands\execute.js:14:11)
[debug] [W3C (14623234)] at curCommandCancellable._bluebird.default.resolve.then (C:\Users\ludovic.costa\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\driver.js:305:66)
[debug] [W3C (14623234)] at tryCatcher (C:\Users\ludovic.costa\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\release\util.js:16:23)
[debug] [W3C (14623234)] at Promise._settlePromiseFromHandler (C:\Users\ludovic.costa\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\release\promise.js:517:31)
[debug] [W3C (14623234)] at Promise._settlePromise (C:\Users\ludovic.costa\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\release\promise.js:574:18)
[debug] [W3C (14623234)] at Promise._settlePromiseCtx (C:\Users\ludovic.costa\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\release\promise.js:611:10)
[debug] [W3C (14623234)] at _drainQueueStep (C:\Users\ludovic.costa\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\release\async.js:142:12)
[debug] [W3C (14623234)] at _drainQueue (C:\Users\ludovic.costa\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\release\async.js:131:9)
[debug] [W3C (14623234)] at Async._drainQueues (C:\Users\ludovic.costa\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\release\async.js:147:5)
[debug] [W3C (14623234)] at Immediate.Async.drainQueues (C:\Users\ludovic.costa\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\release\async.js:17:14)
[debug] [W3C (14623234)] at runCallback (timers.js:705:18)
[debug] [W3C (14623234)] at tryOnImmediate (timers.js:676:5)
[debug] [W3C (14623234)] at processImmediate (timers.js:658:5)
[HTTP] <-- POST /wd/hub/session/14623234-013b-4d3f-b34b-d05282a0d447/execute/sync 405 116 ms - 1886

@eirenik0
Copy link
Member Author

eirenik0 commented Sep 11, 2019 via email

@ludovicmcosta
Copy link

ludovicmcosta commented Sep 11, 2019

I am using appium driver and sdk version = 4.0.8.
The issue was observed with selenium and appium driver and with sdk version 4.0.8.

I did the example https://applitools.com/tutorials/appium-native-java.html and the same problem was observed. It looks like that Android native apps are not supported by applitools SDK.

@eirenik0
Copy link
Member Author

@ludovicmcosta I've copied code from tutroial with small modification for version 4.x and I it run as expected. Code:

import os

from selenium import webdriver
from applitools.selenium import Eyes


class HelloWorld:

    # Initialize the eyes SDK and set your private API key.
    eyes = Eyes()

    # Desired capabilities.
    desired_caps = dict(
        platformName="Android",
        deviceName="Android Emulator",
        platformVersion="8.0",
        app="http://saucelabs.com/example_files/ContactManager.apk",
    )

    # Open the app.
    sauce_url = "https://{username}:{password}@ondemand.saucelabs.com:443/wd/hub".format(
        username=os.getenv("SAUCE_USERNAME", None),
        password=os.getenv("SAUCE_ACCESS_KEY", None),
    )
    wd = webdriver.Remote(sauce_url, desired_caps)
    wd.implicitly_wait(60)

    try:

        # Start the test.
        eyes.open(
            driver=wd,
            app_name="Contacts",
            test_name="My first Appium native Python test!",
        )

        # Visual UI testing.
        eyes.check_window("Contact list!")

        # End the test.
        eyes.close()

    finally:

        # Close the app.
        wd.quit()

        # If the test was aborted before eyes.close was called, ends the test as aborted.
        eyes.abort()

Could you provide exactly code that you run?

@ludovicmcosta
Copy link

Below you can see the executed code, logs captured during the execution and the console output.

As you can see the sdk is not able to extract device pixel ratio, returning the error message: Method is not implemented.

The results are sent to applitools but several logs are created in appium and it can be a problem if I do parallel test with multiple devices.

Code:

from appium import webdriver
from applitools.selenium import Eyes
from applitools.common import logger
from applitools.common.logger import FileLogger
class HelloWorld:

    # Initialize the eyes SDK and set your private API key.
    logger.set_logger(FileLogger("log.log"))
    eyes = Eyes()
    eyes.api_key = 'MY API KEY'

    # Desired capabilities.
    desired_caps = dict(
        platformName='Android',
        deviceName='DEVICE NAME',
        platformVersion='8.1.0',
        app='http://saucelabs.com/example_files/ContactManager.apk',
        automationName='UiAutomator2')

    # Open the app.
    wd = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
    wd.implicitly_wait(60)

    try:

        # Start the test.
        eyes.open(driver=wd, app_name='Contacts', test_name='My first Appium native Python test!')

        # Visual UI testing.
        eyes.check_window('Contact list!')
        eyes.check_region_by_element()

        # End the test.
        eyes.close()

    finally:

        # Close the app.
        wd.quit()

Logs:

2019-09-12 10:18:56,115 [INFO] MainThread) eyes: No Batch set
2019-09-12 10:18:56,115 [INFO] MainThread) eyes: No OS set, checking for mobile OS...
2019-09-12 10:18:56,117 [INFO] MainThread) eyes: Android detected
2019-09-12 10:18:56,117 [INFO] MainThread) eyes: Setting OS: Android 8
2019-09-12 10:18:57,910 [INFO] MainThread) eyes: check('Contact list!', check_settings) - begin
2019-09-12 10:18:57,911 [INFO] MainThread) eyes: initializing position provider. stitch_mode: StitchMode.Scroll
2019-09-12 10:18:58,411 [INFO] MainThread) eyes: getting screenshot...
2019-09-12 10:18:58,456 [INFO] MainThread) eyes: Failed to extract device pixel ratio! Using default. Error Message: Method is not implemented
 
2019-09-12 10:18:58,456 [INFO] MainThread) eyes: Device pixel ratio: 1
2019-09-12 10:18:58,505 [INFO] MainThread) eyes: Failed to set ContextBasedScaleProvider.
2019-09-12 10:18:58,505 [INFO] MainThread) eyes: Using FixedScaleProvider instead...
2019-09-12 10:18:58,506 [INFO] MainThread) eyes: Done!
2019-09-12 10:18:58,506 [INFO] MainThread) eyes: Viewport screenshot requested
2019-09-12 10:18:59,506 [INFO] MainThread) eyes: Getting screenshot as base64...
2019-09-12 10:19:00,246 [INFO] MainThread) eyes: Done getting base64! Creating BufferedImage...
2019-09-12 10:19:00,657 [INFO] MainThread) eyes: Done getting screenshot!
2019-09-12 10:19:00,657 [INFO] MainThread) eyes: Done getting title
2019-09-12 10:19:00,700 [INFO] MainThread) eyes: dom_url: None
2019-09-12 10:19:00,700 [INFO] MainThread) eyes: Done
2019-09-12 10:19:02,698 [INFO] MainThread) eyes: getting screenshot...
2019-09-12 10:19:02,700 [INFO] MainThread) eyes: Viewport screenshot requested
2019-09-12 10:19:03,700 [INFO] MainThread) eyes: Getting screenshot as base64...
2019-09-12 10:19:04,500 [INFO] MainThread) eyes: Done getting base64! Creating BufferedImage...
2019-09-12 10:19:04,585 [INFO] MainThread) eyes: Done getting screenshot!
2019-09-12 10:19:04,586 [INFO] MainThread) eyes: Done getting title
2019-09-12 10:19:04,631 [INFO] MainThread) eyes: dom_url: None
2019-09-12 10:19:04,631 [INFO] MainThread) eyes: Done
2019-09-12 10:19:07,101 [INFO] MainThread) eyes: Window mismatch Contact list!
2019-09-12 10:19:07,101 [INFO] MainThread) eyes: close(): Ending server session...
2019-09-12 10:19:07,980 [INFO] MainThread) eyes: close(): Existing test [TestResults(steps=1, matches=0, mismatches=1, missing=0, url=u'https://eyes.applitools.com/app/batches/00000251834024504240/00000251834024504100?accountId=3-hCyOsBHUGcbWHGhhfyIA~~')]
2019-09-12 10:19:07,980 [INFO] MainThread) eyes: --- Failed test ended. 
	See details at https://eyes.applitools.com/app/batches/00000251834024504240/00000251834024504100?accountId=3-hCyOsBHUGcbWHGhhfyIA~~

Console output:

C:\Python27\python.exe C:/Users/WIN10/PycharmProjects/robot/HelloWorld.py
C:\Python27\lib\site-packages\applitools\common\logger.py:259: UserWarning: Failed to get viewport size. Only window size is available
  warnings.warn(msg)
C:\Python27\lib\site-packages\applitools\common\logger.py:259: UserWarning: Exception raising during capturing DOM Json. Passing...
 Got next error: Message: Method is not implemented

@eirenik0
Copy link
Member Author

eirenik0 commented Sep 12, 2019 via email

@ludovicmcosta
Copy link

Yes, I can see the results on eyes dashboard.

However at each eyes.open() the error "Encountered internal error running command: NotImplementedError: Method is not implemented" is logged in the appium file logs.

Since this appium method in not yet implemented it should not be better to use always the default ratio to avoid all these error messages from appium? If multiple devices are used (e.g: 200) this error will be replicated for all devices and the log file will increase.

@eirenik0
Copy link
Member Author

eirenik0 commented Sep 12, 2019

@ludovicmcosta I've got your point. It will be added in next release so won't bother you anymore :)

applitools/eyes.sdk.python@0e11887

@ludovicmcosta
Copy link

Thanks :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants