I've faced with issue using Webdriver.io+Browserstack. When I'm running tests in browser (Automate service) it's ok, I see a correct statuses http://prntscr.com/ijw1rr , but when I'm running for mobile apps tests (App Automate) it shows me always Completed http://prntscr.com/ijw277
Where in wdio.conf.js I should paste this request from REST API documentation REST API?
Also I've found here something similar, but don't know how can I use it.
Browserstack reports successful even when test fails in Nightwatchjs
Here is an example when it works for me
afterTest: function (test) {
var session = browser.sessionId;
var request = require("request");
request({uri: "https:/<user>:<key>#api.browserstack.com/app-automate/sessions/"+session+".json", method:"PUT", form:{"status":"completed","reason":""}});
}
But it is like hard coded (every time will completed or failed, depends on what I specified), I need somehow populate this value depends on if assert or test fails.
You could use the following code block to mark tests as failed on browserstack
afterTest: test => {
if (!test.passed) {
request({
uri: `https://${user}:${key}#api.browserstack.com/app-automate/sessions/${browser.sessionId}.json`,
method:'PUT',
form:{ 'status':'error','reason': errors.join(' | ') },
})
}
This api call will be invoked only upon test failures. So all test that are completed will be green and the ones that failed will be marked red/error/failed.
Related
I'm trying to write a Cypress test that interacts with react-stripe-js's PaymentRequestButtonElement component. Unfortunately I'm hitting a little bit of a stumbling block actually getting my test to render the button (works fine when I manually test).
I've tried mocking the window's PaymentRequest function:
cy.window().then(win => {
if (win.PaymentRequest) {
// If we’re running in headed mode
cy.stub(win, 'PaymentRequest').callsFake(getMockPaymentRequest(validPaymentRequestResponse));
} else {
// else headless
win.PaymentRequest = getMockPaymentRequest(validPaymentRequestResponse)
}
});
but no luck, our button still doesn't appear. I suspect it has something to do with the following error I see in my console:
Unable to download payment manifest "https://google.com/pay"., but had a look through Google and seemingly nobody seems to have mentioned this.
I've also tried stubbing window.Stripe in a similar way (to mock out the stripe.paymentRequest function) but equally no luck there.
Has anyone had any success implementing something similar?
In order to test Stripe's Payment Request button in Cypress you will likely need to mock the Payment Request API:
Now that all the pieces are in place we can attempt to test something a bit trickier, the Payment Request API that Stripe conveniently wraps for us.
This API is used to detect whether a browser supports payment methods like Apple or Google Pay and then handles accepting payments via these APIs.
We have many dozens of build pipelines and we want to pause and resume (re-enable) build pipelines from a simple webapp interface as we are making config changes frequently. Here is the MS doc explaining this API:
https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/update%20build?view=azure-devops-rest-5.0#definitionqueuestatus
From this documentation, it appears I need to hit the REST API and change/toggle the DefinitionQueueStatus -- however, this documentation only shows a sample for a build specific operation, whereas I want to pause then re-enable the entire build pipeline. What is the proper way to make this call?
I'm using fetch - and I've tried many dozen formats in the call - the 'ourorg' and 'ourproject' are correct (we use this call structure for many other calls), but all fails for this call below. I grabbed the 'definitionID' from the URL I can visibly see when in the Azure devops portal on the specific build pipeline page, and I'm using it for the {buildID} as I don't know what else to put there. Any guidance to help here is appreciated - I don't need to use fetch btw - any working sample will help here:
fetch(https://dev.azure.com/our_org/our_projectname/_apis/build/builds/definitionId=1593?retry=true&api-version=5.0 {
method: 'PATCH ',
credentials: 'same-origin',
body: 'DefinitionQueueStatus: "Enabled"'
}).then(function(response) {
console.log(response);
})
It seems that the body is incorrect in your post. Here is sample about how to use POSTMAN to access Azure DevOps Services REST APIs.
Generate the PAT, and then record the token, it is important to use to authorization, please see this document.
Create a new request in POSTMAN, it is recommended to put the request in a collection for Azure DevOps Services REST API;
Select the authorization as Basic Auth, you can input the username as any value, and the password as the token which is generated in step1.
Basic Auth
Set the REST API which you want to use,and select the request method type(GET,POST,FETCH ....), here you use https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=5.0.
In the Body tab, you can set the request body as raw in json format, and input the value as following:
{
"buildNumber":"#20190607.2",
"buildNumberRevision":1,
"definition":
{
"id":1,
"createdDate":null,
"queueStatus":"paused"
}
}
Everthing is ready now, you can send the request, if sccuess, you will get the response from the REST API.
In your post, the body content is incorrect, the Request Body should meet the format in the REST API document. The DefinitionQueueStatus is a type in definitions. In addition, if you send the request with parameter retry, you will get the message The request body must be empty when the retry parameter is specified..
I need help using Google Sign-In when testing my Angular 6 app with Cypress. It can't use the sign-in popup, and so I'm trying to follow Cypress' advice to "always use cy.request() to talk to 3rd party servers via their APIs." That's from https://docs.cypress.io/guides/references/best-practices.html#Visiting-external-sites which then points us to this example: https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/logging-in__single-sign-on/cypress/integration/logging-in-single-sign-on-spec.js - more info on how to do this is seen at minute 23 in a presentation by the Cypress author: https://www.youtube.com/watch?v=5XQOK0v_YRE
I'm taking the video solution and trying to modify it for Firebase Auth according to https://firebase.google.com/docs/auth/web/google-signin#advanced-authenticate-with-firebase-in-nodejs but I'm getting stuck on how to obtain the proper id_token and so far I have this code in my commands.js file:
Cypress.Commands.add('login', () => {
var id_token = ___?____;
cy.request({
method: 'POST',
url: 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyAssertion?key=[API_KEY]',
body: {
"requestUri": "http://localhost:3500",
"postBody": `id_token=${id_token}&providerId=google.com`,
"returnSecureToken": true,
"returnIdpCredential": true
}
})
})
I believe I need to use a different API to initiate the login and request user credentials, which will include the id_token, and so I tried https://firebase.google.com/docs/auth/web/google-signin#advanced-authenticate-with-firebase-in-nodejs but am not yet skilled enough to pull in external js files (https://apis.google.com/js/platform.js) into Node (This is probably not possible in js files the way it is in html). Using this package: https://github.com/google/google-auth-library-nodejs may be my next attempt. Is there anyone who can pick it up from here?
Similar question at Is it possible to use Cypress e2e testing with a firebase auth project? - but they are signing in with user and pass.
I have the following
[HttpPost]
public IActionResult LaunchExternalProcess()
{
Process.Start("C:\\Windows\\System32\\calc.exe");
return Ok();
}
And this works perfectly fine on my local machine, but when deployed onto IIS 10 (windows 2016) I get no errors but it does not launch the calc on the server.
I simply want to call an external .exe from a button on my page.
Here is the javascript that I am using which also works on my local but no errors on server and it displays the success message
$.ajax({
url: "/Admin/LaunchExternalProcess",
type: "POST",
cache: false,
success: function () {
console.log("success");
}
});
First, it is a very bad idea to spin up an external process like this. So please, don't do this in a real application. You will more than likely create far more issues and security holes that it would ever be worth. There are several, far more robust, architectural patterns for dealing with external processes outside your request pipeline.
That said, the problem here is that calc.exe is failing to launch on your server. Your method doesn't know about this however since you're simply telling it to start a Process, you're not checking to see what state that process is in.
var process = Process.Start("C:\\Windows\\System32\\calc.exe");
if (process == null) // failed to start
{
return InternalServerError();
}
else // Started, wait for it to finish
{
process.WaitForExit();
return Ok();
}
AzureWebJob is one of those implementations, not as simple, but it gets the job done
Trying to test some user permissions here, and i'm having trouble logging out after each test...
afterEach: function () {
return this.remote
.clearLocalStorage()
// .clearCookies();
},
nextTest: function () {
return this.remote.get("/")...
This will only work if I clearCookies as well, but I shouldn't need to clear cookies (manually executing localStorage.clear() and reloading works). I would expect return this.remote.clearLocalStorage(); to suffice, but on the following test I get redirected to my dashboard.
clearLocalStorage simply sends a DELETE request to the WebDriver server's local_storage endpoint, so the driver is what actually implements the clearing behavior. It's possible that different WebDrivers handle clearing local storage in different ways, but given that local storage and cookie storage are not the same, clearing one shouldn't necessarily affect the other.