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

QACOE-242: add Dockerfile and instructions how to use cypress with docker #11

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

GoranP
Copy link

@GoranP GoranP commented Jan 25, 2022

No description provided.

@GoranP
Copy link
Author

GoranP commented Jan 25, 2022

@chan-chandra take a peek at this PR. I added Dockerfile and a few instructions for cypress. Please comment on what needs to be changed for this to be merged in the main repo.

@pedrohyvo
Copy link
Contributor

@GoranP could you add your ticket number in the title and description of this PR, please.

e.g. QACOE-111: add Dockerfile...

@GoranP GoranP changed the title add Dockerfile and instructions how to use cypress with docker QACOE-242: add Dockerfile and instructions how to use cypress with docker Jan 26, 2022
@GoranP
Copy link
Author

GoranP commented Jan 27, 2022

@chan-chandra @pedrohyvo
Could one of you guys please check if Nightwatch tests are OK on your system?

I could not successfully run them all - only partially. After .click(...) action, it seems there are no results or better there is no element called <.main-results> on the Ecosia website after. I tried various existing elements like #main but nothing helps.

I even injected logging and hitting ENTER like this but everything seems ok and I cannot find result element from website:
.setValue('input[type=search]', ['nightwatch testing framework',browser.Keys.ENTER], function(err){console.log(err)})

Following are errors I get:

============================================
ℹ Connected to localhost on port 9515 (126ms).
  Using: chrome (97.0.4692.99) on Linux platform.

✔ Running search for a keyword:

✔ Element <body> was visible after 23 milliseconds.
✔ Testing if the page title contains 'Ecosia' (7ms)
✔ Testing if element <input[type=search]> is visible (25ms)
✔ Testing if element <button[type=submit]> is visible (29ms)
   NoSuchElementError: An error occurred while running .getText() command on <.mainline-results>: 
   {"sessionId":"2deacfb1ac8afeb2db0d1871f07d5091","status":0,"value":[]}
       at processTicksAndRejections (node:internal/process/task_queues:96:5)
✖ Testing if element <.mainline-results> contains text 'Nightwatch.js' in 5000ms - expected "contains text 'Nightwatch.js'" but got: "element could not be located" (5424ms)
    at DescribeInstance.<anonymous> (/app/tests/DemoBDD.js:13:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) 


FAILED: 1 assertions failed, 1 errors and  4 passed (6.931s)

However - since I am trying that in Docker and using headless chrome that might be an issue.

Could you please execute that on your machine with all dependencies installed and with a headless option? Just to eliminate that this is a chrome headless problem and that issue is just my lack of knowledge of how Nightwatch access DOM objects on HTML result. :)

This is the config I am using for nigtwatch.js:

module.exports = {
  "src_folders" : ["tests/"],

  "webdriver" : {
    "start_process": true,
    "server_path": "node_modules/.bin/chromedriver",
    "port": 9515
  },

  "test_settings" : {
    "default" : {
      "desiredCapabilities": {
        "browserName": "chrome",
        "chromeOptions" : {
            "args" : ["headless", "no-sandbox", "disable-gpu"]
        }
      }
    },

    "chrome" : {
      "desiredCapabilities": {
        "browserName": "chrome",
        "chromeOptions" : {
            "args" : ["headless", "no-sandbox", "disable-gpu"]
        },
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    } 
  },
}```

@chan-chandra
Copy link
Contributor

chan-chandra commented Jan 27, 2022

@chan-chandra @pedrohyvo Could one of you guys please check if Nightwatch tests are OK on your system?

I could not successfully run them all - only partially. After .click(...) action, it seems there are no results or better there is no element called <.main-results> on the Ecosia website after. I tried various existing elements like #main but nothing helps.

I even injected logging and hitting ENTER like this but everything seems ok and I cannot find result element from website: .setValue('input[type=search]', ['nightwatch testing framework',browser.Keys.ENTER], function(err){console.log(err)})

Following are errors I get:

============================================
ℹ Connected to localhost on port 9515 (126ms).
  Using: chrome (97.0.4692.99) on Linux platform.

✔ Running search for a keyword:

✔ Element <body> was visible after 23 milliseconds.
✔ Testing if the page title contains 'Ecosia' (7ms)
✔ Testing if element <input[type=search]> is visible (25ms)
✔ Testing if element <button[type=submit]> is visible (29ms)
   NoSuchElementError: An error occurred while running .getText() command on <.mainline-results>: 
   {"sessionId":"2deacfb1ac8afeb2db0d1871f07d5091","status":0,"value":[]}
       at processTicksAndRejections (node:internal/process/task_queues:96:5)
✖ Testing if element <.mainline-results> contains text 'Nightwatch.js' in 5000ms - expected "contains text 'Nightwatch.js'" but got: "element could not be located" (5424ms)
    at DescribeInstance.<anonymous> (/app/tests/DemoBDD.js:13:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) 


FAILED: 1 assertions failed, 1 errors and  4 passed (6.931s)

However - since I am trying that in Docker and using headless chrome that might be an issue.

Could you please execute that on your machine with all dependencies installed and with a headless option? Just to eliminate that this is a chrome headless problem and that issue is just my lack of knowledge of how Nightwatch access DOM objects on HTML result. :)

This is the config I am using for nigtwatch.js:

module.exports = {
  "src_folders" : ["tests/"],

  "webdriver" : {
    "start_process": true,
    "server_path": "node_modules/.bin/chromedriver",
    "port": 9515
  },

  "test_settings" : {
    "default" : {
      "desiredCapabilities": {
        "browserName": "chrome",
        "chromeOptions" : {
            "args" : ["headless", "no-sandbox", "disable-gpu"]
        }
      }
    },

    "chrome" : {
      "desiredCapabilities": {
        "browserName": "chrome",
        "chromeOptions" : {
            "args" : ["headless", "no-sandbox", "disable-gpu"]
        },
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    } 
  },
}```

@GoranP Its failing for headless mode, will update the code

@GoranP
Copy link
Author

GoranP commented Jan 31, 2022

@chan-chandra OK thnx. To it is headless mode then. I tried a few variants but non worked - please notify me when you update the code for headless (if it is possible at all).

@GoranP
Copy link
Author

GoranP commented Feb 1, 2022

I pushed NightwatchJS Dockerfile and slightly adjusted nightwatch.js config file with headless support.
Also, brief documentation of building docker image pushing and deploying on Kubernetes is added in the readme file.
I hope that we can adjust the test code to support headless testing because right now half of the tests will fail with this configuration.
@chan-chandra @pedrohyvo

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

Successfully merging this pull request may close these issues.

3 participants