allure-framework / allure-pytest

Deprecated, please use https://github.com/allure-framework/allure-python instead
Other
171 stars 83 forks source link

Allure doesn't make a screenshot on a mobile device during the autotests with pyTest uiAutomator on Android #108

Closed nataly22 closed 7 years ago

nataly22 commented 7 years ago

When I run autotests with pytest+Selenium WebDriver+allure - allure makes screenshots,
but I run autotests with pyTest_uiAutomator+allure on mobile device Android - I get error when want to look png.file with screenshots.

My testcode:

@allure.feature('Autorization to  ...')
@allure.story('Autorization to ...')
    def test_autorization(self):
        ...
        time.sleep(4)
        d.press.home()
        ...
        #Make photo of start page
        allure.attach('my attach','Screen_start_page', allure.attach_type.PNG)

after that a have during open png file:: "Fatal error reading PNG image file: Not a PNG file"

pupssman commented 7 years ago

@nataly22 could you please provide MVE and/or actual report (with source files and built reports)?

nataly22 commented 7 years ago

Test run: ~/101discounts/tests/tmp_for_github$ py.test test_registration_a.py --alluredir /home/ngora/reports/ui/

Text during run:

================================================= test session starts ================================================== platform linux2 -- Python 2.7.12, pytest-2.9.0, py-1.4.31, pluggy-0.3.1 rootdir: /home/ngora, inifile: plugins: allure-adaptor-1.7.5 collected 1 items

test_registration_a.py .

Generate report: ~/reports/ui/allure_cli/bin$ ./allure report generate /home/ngora/reports/ui/

Open report:

~/reports/ui/allure_cli/bin$ ./allure report open

allure dashboard

test_registration_a sttings_a po_start_page_a po_android_dev_page_a functions_a func_func report_picture_open 6c4722c5 a378 4bf6 822a c4deb88c6310 testsuite xml screen_with_report

nataly22 commented 7 years ago

I wrote a reply with source files and built reports on gitHub site in my issue.

Thank you in advance for your help in solving the problem

28 ноября 2016, 19:05:06, от Ivan Kalinin < notifications@github.com >: @nataly22 could you please provide MVE and/or actual report (with source files and built reports)? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub , or mute the thread .

pupssman commented 7 years ago

@nataly22 however useful screenshots could be they fail to provide the most crucial information. Please attach a .tar.gz / .zip archive with the source code and reports to the github issue.

nataly22 commented 7 years ago

sending archive tmp_for_github.tar.gz reports.tar.gz

pupssman commented 7 years ago

Apparently, you are doing screenshots wrong.

Contents of the attachment files are as follows:

pupssman@airship:~/Downloads $ cat ~/Downloads/3d95375c-d765-404a-9bf4-6c985832f0f2-attachment.png 
Screen_start_pagepupssman@airship:~/Downloads $ 

I.e. there is plain text string Screen_start_page instead of image data.

This may be caused by you explicitly commanding allure to attach that very plain text string in your code:

allure.attach('my attach','Screen_start_page', allure.attach_type.PNG)

As per allure's documentation, second argument to the allure.attach method call is the file content to be attached, which one would expect to be the PNG raw data in your case, instead of the plain text string found in the code.

This appears to be a simple typo in the test code and is therefore not a problem with the allure or allure plugin at all.

Please, be more careful with your code and good luck)

nataly22 commented 7 years ago

Thanks for the advice. The problem was solved as follows:

#We take screenshots by comand of uiautomator
d.screenshot('/home/ngora//reports/ui/myattach.png')
#open file as in python
f = open('/home/ngora//reports/ui/myattach.png')
#read files content to second parameter of attach method
allure.attach('Start2_page',f.read(), type=AttachmentType.PNG)

good_end

pupssman commented 7 years ago

Glad to know problem is solved