Codeception : Test Ajax/javascript requests - codeception

I'm new to codeception, and I need to write a functional test, which verifies if a certain page sends an ajax/javascript request, and also test if the request is executed as expected
Thank you
Raja

Related

Jmeter/Selenium - How do I access specific endpoint

I have a simple performance test flow in an application.
Login
Process1
Process2
Process3
Logout
I am using Jmeter/Selenium to do a performance testing. I am currently debugging an endpoint in Process3("/example/path"). The problem is that I have to run the entire automation for me to get to that endpoint in Process3. Is there a way to skip the processes and navigate to that specific endpoint(not headless)? For example:
WDS.sampleResult.sampleStart();
WDS.browser.get("https://domain/path/path/endpoint");
//Authentication
implicitFind(pkg.By.id("username")).sendKeys("user");
implicitFind(pkg.By.id("password")).sendKeys("password");
implicitFind(pkg.By.id("login")).click();
//below code would be for debugging endpoint in UI
When I run WebDriver Sampler, it presents the login page, which I do not mind asking to login. But after I login, webapp does not go to endpoint and throws a NullPointerException. Would I need to add a Cookie Manager? If so, how would I go with doing this using a WebDriver Sampler. If no, is there another way to successfully achieve this? Thanks in advance.
If the application doesn't properly redirect you to the "endpoint" after logging in - it's your application problem only, there is nothing you can do about it on JMeter or Selenium level.
It you want to run Process 3 only and skip Process 1 and Process 2 just temporarily disable them using "Disable" or "Toggle" context menu actions
As you can see the "greyed out" samplers are not executed.
HTTP Cookie Manager relates only to HTTP Request samplers, https://www.selenium.dev/ is a browser automation framework and browsers handle cookies automatically

How to carry out API testing testing using JMeter on API url

I have an API url and body data in xml format.
How to do load testing of available API url using JMeter?.
I need to check the API performance for multiple user login.
Add a Thread Group to your Test Plan and specify the desired number of threads (virtual users), iterations and test duration
Below setup will run the request with 10 users for 1 minute:
Add a HTTP Request sampler as a child of the Thread Group and specify the URL and the body there:
You may also need to add HTTP Header Manager to send the relevant Content-Type header
Run your test in command-line non-GUI mode
Generate HTML Reporting Dashboard and analyze the results
More information:
Testing SOAP/REST Web Services Using JMeter
Building a WebService Test Plan

How to work with apache Jmeter for login applications?

Hi I would like to test using Jmeter for my application which has login page. I am able to write Sample http request for login page which is working ( passing username and password as POST parameters).
But the another Sample HttpRequest (home.do) is not working which is again redirecting to login page. I also added HttpCookieManager at Thread level. Not sure why the authentication is not carry forward to other pages, Can anyone please help me on this.
Most probably your test doesn't work due to missing or incorrect correlation. The absolute majority of modern web applications use dynamic parameters for different reasons (client state tracking, security, etc.) so you need to setup your test plan like:
Open Login Page (usually GET request)
Extract dynamic parameters
Perform Login (usually POST request), provide credentials and dynamic parameters extracted from the previous request
Extract dynamic parameters
Open Home Page (usually GET request)
etc.
You can extract dynamic parameters using JMeter Post-Processors
Also make sure you add HTTP Cookie Manager to your Test Plan to represent browser cookies and deal with cookie based authentication.
BTW, you can quickly build test plan "skeleton" by simply recording your test scenario using HTTP(S) Test Script Recorder

How to stub an API when testing with Selenium Server

I'm using Nightwatch.js to test a MERN stack application—it makes calls to the Twilio API when it receives a POST request at /sms/outgoing/.
I would rather not send SMS messages every time I run my e2e tests—instead I'd like to stub out the behaviour and, ideally, return the request data, so that I can check my app is submitting the correct info.
I have looked at libraries such as nock and fetch-mock, but neither of these will work with tests that rely on selenium.
Is there a library that can intercept requests made by Selenium Server and provide the stubbing behaviour I'm after?
As you have mentioned nock and fetch-mock, I assume you're using a node server?
If that is the case, you could modify the server to detect an environment variable process.env.MOCK_API and return hard-coded responses to fetch request using fetch-reply-with

What are the steps to run Login scenario in jmeter

I have installed Jmeter. I tested the load for google using www.google.com, it is working fine but when i tried with https://www.google.com it is not working fine. what are the steps to test login scenario in Jmeter. Kindly help me out.
The "classic" login test plan looks as follows:
Thread Group
HTTP Request Defaults (to set host, port, protocol, path, etc. for all HTTP Request samplers in scope)
HTTP Cookie Manager (to maintain session and deal with cookie-based authenticaion)
HTTP Request (GET request to login page)
Regular Expression Extractor or similar (if any dynamic mandatory parameters are required for login request they need to be extracted here)
HTTP Request (POST request to login page with username, password, and dynamic parameters if any)
Response Assertion (to verify that login was successful)
Useful links:
Building a Web Test Plan
Building an Advanced Web Test Plan
ASP.NET Login Testing with JMeter