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

Need some sample example project /repo #1

Closed
Avinash-Kannan opened this issue Jul 27, 2022 · 12 comments
Closed

Need some sample example project /repo #1

Avinash-Kannan opened this issue Jul 27, 2022 · 12 comments
Labels
help wanted Extra attention is needed

Comments

@Avinash-Kannan
Copy link

Tried this service as per documents : https://webdriver.io/docs/gmangiapelo-wdio-azure-devops-service
But couldn’t find anything reflected in my Azure Test plans.

@gianlucamangiapelo gianlucamangiapelo added the help wanted Extra attention is needed label Jul 27, 2022
@gianlucamangiapelo
Copy link
Owner

Hi @Avinash-Kannan Can you provide your wdio configuration file and useful information for troubleshooting?
Thanks

@Avinash-Kannan
Copy link
Author

Avinash-Kannan commented Jul 27, 2022

@gianlucamangiapelo I have added below lines of code in wdio config file and added package using npm install.

import AzureDevopsService from "@gmangiapelo/wdio-azure-devops-service";
// wdio.conf.js
exports.config = {
    // ...
    // =====
    // Setup
    // =====
    services: [  ['appium', {
            command : 'appium'
        }],
        [  AzureDevopsService,
              {
                  pat: 'token',
                  organizationUrl: 'https://dev.azure.com/org',
                  projectId: 'id',
                  planId: id,
                  suiteId: id,
                  runName: 'FE regression tests for TestPlan',
              },
          ],
    ],
    // ...
};

It didn’t throw me any error / logs related to added service. My Appium mobile tests got passed and couldn’t find anything useful in logs related to azure-devops service added.
Kindly share an example repo if any for reference.

@gianlucamangiapelo
Copy link
Owner

@Avinash-Kannan
What scope you set when you have generated the PAT?

The scope for the token should be Test Management with Read&Write permission.
image

@Avinash-Kannan
Copy link
Author

Avinash-Kannan commented Jul 27, 2022

Yes exactly , I have did the same. Custom defined to read & write access for test management.
Will there be any logs printed in console related to this service - example, any success message kind of?
@gianlucamangiapelo

@Avinash-Kannan
Copy link
Author

Avinash-Kannan commented Jul 28, 2022

Steps that i followed : @gianlucamangiapelo

  1. Installed @gmangiapelo/wdio-azure-devops-service
  2. Generated PAT token from Azure ( with read & write access for test management), Org URL,Project ID, Suite and Plan ID.
  3. Added the service in wdio.config.js ( refer above mentioned lines of code)
  4. Added the test case ID in mocha test it("12345 Validate Login")
  5. Run the wdio test

Test got passed, nothing got updated in Azure test plan. I saw the report example screenshot in your repo readme. But couldn’t find anything as such.
Am i missing something ?

@gianlucamangiapelo
Copy link
Owner

@Avinash-Kannan
All the steps that are you doing are correct, except for the 4. point.
In the title of the test cases, you have to add the testCaseID that you collect from AzureTestPlan preceded by the letter "c":
it("c12345 Validate Login")

To help in troubleshooting you can enable in your wdio.conf.js one of the loggers adding these lines:

logLevel: "trace",
outputDir: path.join(__dirname, "/logs"),

This will produce in the /logs folder a wdio.log file and inside it, you can search for the keyword: @gmangiapelo and see if any errors are produced.

Let me know your findings.

Right now any boilerplate/example repositories are available, I'll try to work on it.

@bhumireddy100
Copy link

Hi @gianlucamangiapelo, I have tried this service with below code and getting errors.

wdio.conf.js file:
import AzureDevopsService from "@gmangiapelo/wdio-azure-devops-service";
services: ['chromedriver', [AzureDevopsService,
{
pat: 'token',
organizationUrl: 'https://dev.azure.com/org',
projectId: 'id',
planId: id,
suiteId: id,
runName: 'FE regression tests for TestPlan',
},
],
],

Spec file:
it('c1234 Verify that the user can train the document type -> regression', async () => { ..... });

Errors:
ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook
undefined
ERROR @wdio/cli:utils: A service failed in the 'onComplete' hook
Error: {"count":1,"value":{"Message":"The requested resource does not support http method 'PATCH'."}}

Do we need to encode the token in base64 format?

Am I missing anything?

Thanks in advance

@gianlucamangiapelo
Copy link
Owner

Hi @bhumireddy100, can you copy the entire log file?
Thanks

PS: the plugin itself is doing the right encoding

@bhumireddy100
Copy link

bhumireddy100 commented Aug 1, 2022

Hi @gianlucamangiapelo, here is the two logs.
wdio.log:
2022-08-01T10:12:21.896Z DEBUG @wdio/utils:initialiseServices: initialise service "chromedriver" as NPM package
2022-08-01T10:12:21.991Z DEBUG @wdio/utils:initialiseServices: initialise custom service "AzureDevopsService"
2022-08-01T10:12:22.009Z INFO @wdio/cli:launcher: Run onPrepare hook
2022-08-01T10:12:22.013Z INFO chromedriver: Start Chromedriver (C:\Users\Venkata.Bhumireddy\Project\workspace\TestAutomationFramework\node_modules\chromedriver\lib\chromedriver\chromedriver.exe) with args --port=9515 --url-base=/
2022-08-01T10:12:23.939Z ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook
undefined

Continue...
2022-08-01T10:12:23.939Z DEBUG @wdio/cli:utils: Finished to run "onPrepare" hook in 1930ms
2022-08-01T10:12:23.941Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2022-08-01T10:12:23.941Z DEBUG @wdio/cli:utils: Finished to run "onWorkerStart" hook in 0ms
2022-08-01T10:12:23.942Z INFO @wdio/local-runner: Start worker 0-0 with arg: run,wdio.conf.js
2022-08-01T10:13:03.148Z DEBUG @wdio/local-runner: Runner 0-0 finished with exit code 0
2022-08-01T10:13:03.149Z INFO @wdio/cli:launcher: Run onWorkerEnd hook
2022-08-01T10:13:03.149Z DEBUG @wdio/cli:utils: Finished to run "onWorkerEnd" hook in 0ms
2022-08-01T10:13:03.150Z INFO @wdio/cli:launcher: Run onComplete hook
2022-08-01T10:13:04.144Z ERROR @wdio/cli:utils: A service failed in the 'onComplete' hook
Error: {"count":1,"value":{"Message":"The requested resource does not support http method 'PATCH'."}}
at RestClient. (C:\Users\Venkata.Bhumireddy\Project\workspace\TestAutomationFramework\node_modules\typed-rest-client\RestClient.js:202:31)
at Generator.next ()
at fulfilled (C:\Users\Venkata.Bhumireddy\Project\workspace\TestAutomationFramework\node_modules\typed-rest-client\RestClient.js:6:58)
at processTicksAndRejections (node:internal/process/task_queues:95:5)

Continue...
2022-08-01T10:13:04.145Z DEBUG @wdio/cli:utils: Finished to run "onComplete" hook in 995ms
2022-08-01T10:13:04.176Z INFO @wdio/local-runner: Shutting down spawned worker
2022-08-01T10:13:04.434Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully

wdio-0-0.log::
2022-08-01T10:12:25.372Z INFO @wdio/local-runner: Run worker command: run
2022-08-01T10:12:25.676Z DEBUG @wdio/config:utils: Found '@babel/register' package, auto-compiling files with Babel
2022-08-01T10:12:27.073Z DEBUG @wdio/local-runner:utils: init remote session
2022-08-01T10:12:27.078Z DEBUG @wdio/utils:initialiseServices: initialise service "chromedriver" as NPM package
2022-08-01T10:12:27.177Z DEBUG @wdio/utils:initialiseServices: initialise custom service "AzureDevopsService"
2022-08-01T10:12:27.552Z DEBUG @wdio/local-runner:utils: init remote session
2022-08-01T10:12:27.553Z INFO webdriver: Initiate new session using the WebDriver protocol
2022-08-01T10:12:27.658Z INFO webdriver: [POST] http://localhost:9515/session
2022-08-01T10:12:27.658Z INFO webdriver: DATA {
capabilities: {
alwaysMatch: { browserName: 'chrome', acceptInsecureCerts: true },
firstMatch: [ {} ]
},
desiredCapabilities: { browserName: 'chrome', acceptInsecureCerts: true }
}
2022-08-01T10:12:28.788Z DEBUG @wdio/utils:shim: Finished to run "before" hook in 0ms
2022-08-01T10:12:28.795Z DEBUG @wdio/utils:shim: Finished to run "beforeSuite" hook in 0ms
2022-08-01T10:12:28.801Z DEBUG @wdio/utils:shim: Finished to run "beforeTest" hook in 0ms
2022-08-01T10:12:28.803Z INFO webdriver: COMMAND maximizeWindow()
2022-08-01T10:12:28.804Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/window/maximize
2022-08-01T10:12:28.928Z INFO webdriver: RESULT { height: 840, width: 1552, x: -8, y: -8 }
2022-08-01T10:12:28.942Z INFO webdriver: COMMAND setTimeouts(5000, 60000, 300000)
2022-08-01T10:12:28.942Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/timeouts
2022-08-01T10:12:28.942Z INFO webdriver: DATA { implicit: 5000, pageLoad: 60000, script: 300000 }
2022-08-01T10:12:28.953Z INFO webdriver: COMMAND navigateTo("url")
2022-08-01T10:12:28.953Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/url
2022-08-01T10:12:28.953Z INFO webdriver: DATA { url: 'url' }
2022-08-01T10:12:58.623Z INFO webdriver: COMMAND findElement("xpath", ".//button[normalize-space() = "Upload"]")
2022-08-01T10:12:58.623Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/element
2022-08-01T10:12:58.623Z INFO webdriver: DATA { using: 'xpath', value: './/button[normalize-space() = "Upload"]' }
2022-08-01T10:12:59.634Z INFO webdriver: RESULT {
'element-6066-11e4-a52e-4f735466cecf': '5be40385-7d63-4199-9dd0-4a0b25a01501'
}
2022-08-01T10:12:59.657Z INFO webdriver: COMMAND executeScript(, )
2022-08-01T10:12:59.658Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/execute/sync
2022-08-01T10:12:59.658Z INFO webdriver: DATA {
script: 'isElementDisplayed(...) [7962 bytes]',
args: [
{
'element-6066-11e4-a52e-4f735466cecf': '5be40385-7d63-4199-9dd0-4a0b25a01501',
ELEMENT: '5be40385-7d63-4199-9dd0-4a0b25a01501'
}
]
}
2022-08-01T10:12:59.671Z INFO webdriver: RESULT true
2022-08-01T10:12:59.678Z INFO webdriver: COMMAND findElements("xpath", ".//button[normalize-space() = "Upload"]")
2022-08-01T10:12:59.678Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/elements
2022-08-01T10:12:59.678Z INFO webdriver: DATA { using: 'xpath', value: './/button[normalize-space() = "Upload"]' }
2022-08-01T10:12:59.690Z INFO webdriver: RESULT [
{
'element-6066-11e4-a52e-4f735466cecf': '5be40385-7d63-4199-9dd0-4a0b25a01501'
},
{
'element-6066-11e4-a52e-4f735466cecf': '4481d659-790d-485d-8246-0d614ebaeb35'
}
]
2022-08-01T10:12:59.706Z INFO webdriver: COMMAND findElement("xpath", "//div[@Class="dropdown"]/a/[local-name()="svg"]")
2022-08-01T10:12:59.706Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/element
2022-08-01T10:12:59.706Z INFO webdriver: DATA {
using: 'xpath',
value: '//div[@Class="dropdown"]/a/
[local-name()="svg"]'
}
2022-08-01T10:12:59.719Z INFO webdriver: RESULT {
'element-6066-11e4-a52e-4f735466cecf': '9d3dd5d0-3102-4c67-b069-6ff3dc37d917'
}
2022-08-01T10:12:59.731Z INFO webdriver: COMMAND executeScript(, )
2022-08-01T10:12:59.731Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/execute/sync
2022-08-01T10:12:59.731Z INFO webdriver: DATA {
script: 'isElementDisplayed(...) [7962 bytes]',
args: [
{
'element-6066-11e4-a52e-4f735466cecf': '9d3dd5d0-3102-4c67-b069-6ff3dc37d917',
ELEMENT: '9d3dd5d0-3102-4c67-b069-6ff3dc37d917'
}
]
}
2022-08-01T10:12:59.743Z INFO webdriver: RESULT true
2022-08-01T10:12:59.748Z INFO webdriver: COMMAND elementClick("9d3dd5d0-3102-4c67-b069-6ff3dc37d917")
2022-08-01T10:12:59.748Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/element/9d3dd5d0-3102-4c67-b069-6ff3dc37d917/click
2022-08-01T10:12:59.801Z INFO webdriver: COMMAND findElement("xpath", ".//[contains(@Class, "dropdown-item") and normalize-space() = "Model Training"]")
2022-08-01T10:12:59.804Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/element
2022-08-01T10:12:59.804Z INFO webdriver: DATA {
using: 'xpath',
value: './/
[contains(@Class, "dropdown-item") and normalize-space() = "Model Training"]'
}
2022-08-01T10:12:59.817Z INFO webdriver: RESULT {
'element-6066-11e4-a52e-4f735466cecf': '3a87c448-79b8-4692-b4a6-ad82778c01ab'
}
2022-08-01T10:12:59.834Z INFO webdriver: COMMAND executeScript(, )
2022-08-01T10:12:59.835Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/execute/sync
2022-08-01T10:12:59.835Z INFO webdriver: DATA {
script: 'isElementDisplayed(...) [7962 bytes]',
args: [
{
'element-6066-11e4-a52e-4f735466cecf': '3a87c448-79b8-4692-b4a6-ad82778c01ab',
ELEMENT: '3a87c448-79b8-4692-b4a6-ad82778c01ab'
}
]
}
2022-08-01T10:12:59.847Z INFO webdriver: RESULT true
2022-08-01T10:12:59.850Z INFO webdriver: COMMAND elementClick("3a87c448-79b8-4692-b4a6-ad82778c01ab")
2022-08-01T10:12:59.850Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/element/3a87c448-79b8-4692-b4a6-ad82778c01ab/click
2022-08-01T10:12:59.925Z INFO webdriver: COMMAND findElement("xpath", ".//b[normalize-space() = "Add a New Document Type"]")
2022-08-01T10:12:59.926Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/element
2022-08-01T10:12:59.926Z INFO webdriver: DATA {
using: 'xpath',
value: './/b[normalize-space() = "Add a New Document Type"]'
}
2022-08-01T10:12:59.961Z INFO webdriver: RESULT {
'element-6066-11e4-a52e-4f735466cecf': '30a18343-73e2-4901-96fd-c28680182b60'
}
2022-08-01T10:12:59.975Z INFO webdriver: COMMAND executeScript(, )
2022-08-01T10:12:59.976Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/execute/sync
2022-08-01T10:12:59.976Z INFO webdriver: DATA {
script: 'isElementDisplayed(...) [7962 bytes]',
args: [
{
'element-6066-11e4-a52e-4f735466cecf': '30a18343-73e2-4901-96fd-c28680182b60',
ELEMENT: '30a18343-73e2-4901-96fd-c28680182b60'
}
]
}
2022-08-01T10:12:59.990Z INFO webdriver: RESULT true
2022-08-01T10:13:00.004Z INFO webdriver: COMMAND findElements("xpath", ".//b[normalize-space() = "Add a New Document Type"]")
2022-08-01T10:13:00.005Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/elements
2022-08-01T10:13:00.005Z INFO webdriver: DATA {
using: 'xpath',
value: './/b[normalize-space() = "Add a New Document Type"]'
}
2022-08-01T10:13:00.035Z INFO webdriver: RESULT [
{
'element-6066-11e4-a52e-4f735466cecf': '30a18343-73e2-4901-96fd-c28680182b60'
}
]
2022-08-01T10:13:00.064Z INFO webdriver: COMMAND takeScreenshot()
2022-08-01T10:13:00.065Z INFO webdriver: [GET] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/screenshot
2022-08-01T10:13:00.396Z INFO webdriver: RESULT iVBORw0KGgoAAAANSUhEUgAAB4AAAAN1CAYAAACesuZ/AAAAAXNSR0IArs4c6...
2022-08-01T10:13:02.858Z ERROR @wdio/utils:shim: Error:
at C:\Users\Venkata.Bhumireddy\Project\workspace\TestAutomationFramework\node_modules@gmangiapelo\azuredevops-test-reporter\dist\cjs\services\azure\testRun.js:49:19
at Generator.next ()
at fulfilled (C:\Users\Venkata.Bhumireddy\Project\workspace\TestAutomationFramework\node_modules@gmangiapelo\azuredevops-test-reporter\dist\cjs\services\azure\testRun.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
2022-08-01T10:13:02.858Z DEBUG @wdio/utils:shim: Finished to run "afterTest" hook in 2796ms
2022-08-01T10:13:02.890Z INFO webdriver: COMMAND getLogTypes()
2022-08-01T10:13:02.890Z INFO webdriver: [GET] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/se/log/types
2022-08-01T10:13:02.893Z INFO webdriver: RESULT [ 'browser', 'driver' ]
2022-08-01T10:13:02.894Z DEBUG @wdio/runner: Fetching logs for browser, driver
2022-08-01T10:13:02.894Z INFO webdriver: COMMAND getLogs("driver")
2022-08-01T10:13:02.894Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/se/log
2022-08-01T10:13:02.894Z INFO webdriver: DATA { type: 'driver' }
2022-08-01T10:13:02.895Z INFO webdriver: COMMAND getLogs("browser")
2022-08-01T10:13:02.895Z INFO webdriver: [POST] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40/se/log
2022-08-01T10:13:02.895Z INFO webdriver: DATA { type: 'browser' }
2022-08-01T10:13:02.902Z INFO webdriver: RESULT []
2022-08-01T10:13:02.905Z INFO webdriver: RESULT [
{
level: 'WARNING',
message: url/vendors~app.001e3c04b3.js 29:59777 "[mobx] you are running a minified build, but 'process.env.NODE_ENV' was not set to 'production' in your bundler. This results in an unnecessarily large and slow bundle",
source: 'console-api',
timestamp: 1659348778387
},
{
level: 'WARNING',
message: 'url/vendorsapp.001e3c04b3.js 29:42262 "[mobx] observableArray.sort() will not update the array in place. Use observableArray.slice().sort() to suppress this warning and perform the operation on a copy, or observableArray.replace(observableArray.slice().sort()) to sort & update in place"',
source: 'console-api',
timestamp: 1659348779895
},
{
level: 'WARNING',
message: 'url/vendors
app.001e3c04b3.js 29:42262 "[mobx] observableArray.sort() will not update the array in place. Use observableArray.slice().sort() to suppress this warning and perform the operation on a copy, or observableArray.replace(observableArray.slice().sort()) to sort & update in place"',
source: 'console-api',
timestamp: 1659348780164
},
{
level: 'WARNING',
message: 'url/vendors~app.001e3c04b3.js 29:42262 "[mobx] observableArray.sort() will not update the array in place. Use observableArray.slice().sort() to suppress this warning and perform the operation on a copy, or observableArray.replace(observableArray.slice().sort()) to sort & update in place"',
source: 'console-api',
timestamp: 1659348780703
}
]
2022-08-01T10:13:02.913Z INFO webdriver: COMMAND deleteSession()
2022-08-01T10:13:02.913Z INFO webdriver: [DELETE] http://localhost:9515/session/88eced843703537f5e163102f1ca6c40

Thanks in advance

@gianlucamangiapelo
Copy link
Owner

@bhumireddy100 One possible issue could be that you're passing in the configuration wrongs

projectId: '',
planId: ,
suiteId: ,

Can you double check and share how you're retrieving this data (attach screenshot if feasible)
Thanks

@bhumireddy100
Copy link

bhumireddy100 commented Aug 2, 2022

Hi @gianlucamangiapelo, thank for your quick help.
Now I am able to update test results in test plan. Actually plan id 'XXXX'(e.g. 1234) is displaying in ADO and it is not working.
I got plan id (e.g. 1233) through the api end point and it is working fine.
API End Point: https://dev.azure.com/orgname/projectname/_apis/test/plans?api-version=5.0

I have 6 test cases in ADO suite and running only 2 test cases from automation code(not developed automation test scripts for 4 test cases). Service created Run with all 6 test cases under Test results tab(2 tc's are passed and another 4 tc's are unspecified).
Also 4 test cases(don't have automation scripts) are displaying with outcome 'In Progress' under Execute tab.
Is it actual behavior?

@gianlucamangiapelo
Copy link
Owner

Ciao @bhumireddy100, happy to read good news.

Also 4 test cases(don't have automation scripts) are displaying with outcome 'In Progress' under Execute tab. Is it actual behavior?
Yes right now it's the expected behavior, need to figure out if I can set another status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants