spdx-online-tools icon indicating copy to clipboard operation
spdx-online-tools copied to clipboard

Unit test failure - test_archive_license_requests_feature

Open goneall opened this issue 4 years ago • 4 comments

The test_archive_license_requests_feature unit test is failing on the current master branch:

======================================================================
ERROR: test_archive_license_requests_feature (app.tests.ArchiveLicenseRequestsViewsTestCase)
Check if the license is shifted to archive requests when archive button is pressed
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/spdx-online-tools/spdx-online-tools/src/app/tests.py", line 1123, in test_archive_license_requests_feature
    if driver.find_element_by_id('archive_button' + str(license_obj.id)):
  File "/opt/hostedtoolcache/Python/2.7.18/x64/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 360, in find_element_by_id
    return self.find_element(by=By.ID, value=id_)
  File "/opt/hostedtoolcache/Python/2.7.18/x64/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element
    'value': value})['value']
  File "/opt/hostedtoolcache/Python/2.7.18/x64/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/opt/hostedtoolcache/Python/2.7.18/x64/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
NoSuchElementException: Message: Unable to locate element: [id="archive_button1"]

goneall avatar Jul 15 '20 21:07 goneall

This was introduced after https://github.com/spdx/spdx-online-tools/pull/154 got merged and has already been raised at https://github.com/spdx/spdx-online-tools/issues/177 @anshuldutt21 Would you please fix this? Looks like if..else won't work. You would have to use try..catch. Also, please ensure that this test runs for admin user.

rtgdk avatar Jul 16 '20 09:07 rtgdk

@rtgdk Could you please help me out, I was trying to work on this but can't seem to work it through. I tried logging in first using socialauth, but the webdriver still can't locate the archive button. It should work once logged in right?

nishantc7 avatar Mar 24 '21 20:03 nishantc7

@nishantc7 Can you check the output html from selenium? If selenium is not able to find, most likely either the page is not detecting signed in and showing the default page. From code looks like we need to be github logged and auuthorised. You can mock both of these. Also, the archive button will only be present if the license gets added, confirm that the html shows the license added by the test. You don't need to run the test, open up the django shell/python shell and start webdriver testing their. From shell you can do a lot more debugging.

{% if github_login and authorized %}
<button id='archive_button{{elem.id}}' class='btn btn-success' width='25px' value='Archive'>Archive</button>
{% endif %}

rtgdk avatar Mar 25 '21 17:03 rtgdk

@rtgdk - did this get fixed and we can close?

jlovejoy avatar Jun 21 '23 23:06 jlovejoy