Cypress can't access a website from its automated browser (used to work normally and other browsers access normally) - node.js

I was hoping one of you could help me out here. I ran out of ideas already.
I have a script with Cypress.io that basically access a website and clicks on a link for LOGIN. I have reduced the code to only access the LOGIN page directly, which was working perfectly for the past 1-2 months, but in the past week I ran the script and it's no longer working.
When it tries to access the URL https://sso.tce.sp.gov.br/cas-server/login it gives the error below.
The most weird thing is that I can access this URL manually from the other non-automated (EDGE, Chrome), but when I try to do it with the Cypress automated browser it doesn't work.
cy.visit() failed trying to load:
https://sso.tce.sp.gov.br/cas-server/login
We attempted to make an http request to this URL but the request
failed without a response.
We received this error at the network level:
Error: Parse Error: Duplicate Content-Length
Common situations why this would fail:
you don't have internet access
you forgot to run / boot your web server
your web server isn't accessible
you have weird network configuration settings on your computer
Apparently it's doesn't look like a proxy thing nor a code thing, do you guys have any idea of what it could be?
Code:
describe('Test', () => {
it('Access AUDESP Website', function () {
Cypress.config('chromeWebSecurity',false);
//cy.visit('https://www.tce.sp.gov.br/audesp')
//cy.get('.menu-superior-itens > [href="https://sso.tce.sp.gov.br/cas-server/login"]').click()
cy.visit('https://sso.tce.sp.gov.br/cas-server/login')
})
})
Any ideas would be very helpful!!
Thank you!
UPDATE:
Guys, I'm still with this error, but I have found out that the website is sending a duplicate header, but cypress is not able to process it. The browser, outside of Cypress, ignores it apparently... any ideas on how to fix it on Cypress?

Related

500(Internal Server Error): Forge deployed on Azure

I am new to this topic. I have deployed my app to Azure (following the tutorial from Autodesk). When I try to press to the login to BIM360 is return an error 500 (internal Server Error). I have changed the FORGE_CALLBACK_URL = "htttp://forgeSample1234.azurewebsite.net/api/forge/callback/oauth"
The code has no problem when in localhost.
Does anyone has the same problem?
Please note that when updating the callback URL, you actually have to change it in two places:
in your code (that's typically the FORGE_CALLBACK_URL)
in your Forge app page in https://forge.autodesk.com/myapps
And of course, the URL has to match exactly in both places.
Also, it looks like there might be a typo in your URL: you say htttp instead of http, and I'm also wondering if you shouldn't be using https?

MS Teams | Microsoft bot framework - Returns 502 error on task/fetch

I have an MS Teams adapter written using the botframeworks sdk v4 for node js which works perfectly for normal conversations. But when I try to do a task/fetch, it returns an error message "Unable to reach app. Please try again." on the task module popup
I can see from the inspector that it returns 502 response for the request to invoke the task module
The task module returns a simple adaptive card and I can see that I get a callback on my handleTeamsTaskModuleFetch function from the logs
The adapter runs on a docker container with an nginx proxy and the nginx logs shows that, it returns a 200 response whenever I click on the task module launch button
I have a similar setup in my dev and taskmodule works perfect there
Any help is highly appreciated
Update
I have tried hardcoding the adaptive card. That doesnt help either
Eventually it was found that there was a problem with one of the csp headers and microsoft was not happy about it.
I removed the CSP headers and the taskmodule started working
Thanks to #gousia-msft for your help in debugging the issue

How to fill login prompt with Webdriver IO?

I'm working on a CLI with OCLIF. In one of the commands, I need to simulate a couple of clicks on a web page (using the WebdriverIO framework for that). Before you're able to reach the desired page, there is a redirect to a page with a login prompt. When I use WebdriverIO methods related to alerts such as browser.getAlertText(), browser.sendAlertText() or browser.acceptAlert, I always get the error no such alert.
As an alternative, I tried to get the URL when I am on the page that shows the login prompt. With the URL, I wanted to do something like browser.url(https://<username>:<password>#<url>) to circumvent the prompt. However, browser.url() returns chrome-error://chromewebdata/ as URL when I'm on that page. I guess because the focus is on the prompt and that doesn't have an URL. I also don't know the URL before I land on that page. When being redirected, a query string parameter containing a token is added to the URL that I need.
A screenshot of the prompt:
Is it possible to handle this scenario with WebdriverIO? And if so, how?
You are on the right track, probably there are some fine-tunings that you need to address to get it working.
First off, regarding the chrome-error://chromewebdata errors, quoting Chrome DOCs:
If you see errors with a location like chrome-error://chromewebdata/
in the error stack, these errors are not from the extension or from
your app - they are usually a sign that Chrome was not able to load
your app.
When you see these errors, first check whether Chrome was able to load
your app. Does Chrome say "This site can't be reached" or something
similar? You must start your own server to run your app. Double-check
that your server is running, and that the url and port are configured
correctly.
A lot of words that sum up to: Chrome couldn't load the URL you used inside the browser.url() command.
I tried myself on The Internet - Basic Auth page. It worked like a charm.
URL without basic auth credentials:
URL WITH basic auth credentials:
Code used:
it('Bypass HTTP basic auth', () => {
browser.url('https://admin:admin#the-internet.herokuapp.com/basic_auth');
browser.waitForReadyState('complete');
const banner = $('div.example p').getText().trim();
expect(banner).to.equal('Congratulations! You must have the proper credentials.');
});
What I'd do is manually go through each step, trying to emulate the same flow in the script you're using. From history I can tell you, I dealt with some HTTP web-apps that required a refresh after issuing the basic auth browser.url() call.
Another way to tackle this is to make use of some custom browser profiles (Firefox | Chrome) . I know I wrote a tutorial on it somewhere on SO, but I'm too lazy to find it. I reference a similar post here.
Short story, manually complete the basic auth flow (logging in with credentials) in an incognito window (as to isolate the configurations). Open chrome://version/ in another tab of that session and store the contents of the Profile Path. That folder in going to keep all your sessions & preserve cookies and other browser data.
Lastly, in your currentCapabilities, update the browser-specific options to start the sessions with a custom profile, via the '--user-data-dir=/path/to/your/custom/profile. It should look something like this:
'goog:chromeOptions': {
args: [
'--user-data-dir=/Users/iamdanchiv/Desktop/scoped_dir18256_17319',
],
}
Good luck!

nodejs api returning nothing

I am trying to implement MEAN app for which I made node server
app.get("/posts",(req,res)=>{
posts=[{"title":"a","context":"b"},{"title":"c","context":"d"}]
res.send(posts); // tried even with res.status(200).json(posts)
});
when it checked with api tester it works well output snapshot
output snapshot with apitester
when i try to access with angular services
getposts()
{
var url='http://localhost:3000/posts';
this.http.get<post[]>(url).subscribe(data=>this.posts=data);
console.log(this.posts);
return this.posts;
}
when i do console.log(posts) it returning []
can someone please help i am struggling from last 2 days?
As you have not added the screenshot from the Browser's Inspector => Network Tab, I am guessing this answer will help you in case my guess is right.
Try setting the below in your front-end project (Angular in your case):
Try setting the below in your back-end project (Node in your case):
Also, verify your updates as in the below screengrab in the Browser's Inspector (Chrome in my case):
Please Note: - The mentioned response headers have special meaning, so kindly look for more info with a simple Google search. Use these settings during your development phase on localhost.

Stripe webhook test error 302

I am trying to test a stripe webhook for subscription trial ending. When I go to send the test even to my webhook receiving route I get error 302. I am using a middleware called stripe-webhook-middleware. My route looks like this:
app.post('/stripe/events',
stripeWebhook.middleware,
stripeEvents
);
I know that route goes against what they docs say but I did get it directly from the package creator. So it should work, then I have the stripe-events.js from the package. I am just adding in a console.log to the route to find the correct data I need.
I tried different webhooks and all give the same error, it has to be in how I have it set up. I hope anyways.
Edit **
I have also done a new route that is just a basic post route with a console.log and still getting the 302 error. What could possible causes be? I can't post a github because of a credential I accidentally leaked.
I am/was using cloud9.io as my development environment and had my test site as private. That was causing stripe to need to login in order to do anything. I made it public and now it works. I had completely forgotten I had to login to see the site because I always was logged in to cloud 9 when I accessed the site. If you are getting a 302 error, make sure you don't need to log in to get to that route.
Just in case anyone sees this 302 error with Codeigniter 3, my webhook route was pointing to a Subscription controller that always exits the constructor if a user isn't logged in and authorised - so I moved the method to my Home controller (used for registration, login etc) thus:
$route['webhook']['post'] = 'home/webhook';
and the 302 error went away. I hope this helps a tired CI dev down the road.
Just in case someone receives this error with dJango, my webhook route was pointing to a language redirection. You can investigate it with curl -IvL http://localhost:8000/webhooks/stripe as #duck suggested above.
Here was my output:
HTTP/1.1 302 Found
...
* Issue another request to this URL: 'http://localhost:8000/en/webhooks/stripe/'
...
You can see the redirected URL in the output.
So, when I let Stripe CLI listen to that URL, it works:
stripe listen --forward-to localhost:8000/en/webhooks/stripe/

Resources