Using behat/mink, I'm testing the "remember me" functionality. Functionally, when the user visits the main page, javascript/ajax code verifies if the user is "remembered". If yes, then the javascripts redirects to another page. My LoginPage is defined with $path = '/login.html' - after the redirect, I will end up on /main.html.
In my context, I use $loginPage->open() - however this throws exception Expected to be on "https://example.com/login.html" but found "https://example.com/main.html" instead. Naturally, this aborts the execution and results in the test failing - yet this is exactly the behaviour I want.
How can I tell behat/mink to not verify URL or ignore URL mismatch?
If you check the open() method you will see that the check that fails for you is when is checking the url parameters in verify() method.
If you want to avoid this you can override this method to check only for the response and not the url parameters.
In order to do this you need to extend Page and declare a new method like this:
public function verify(array $urlParameters){
$this->verifyResponse();
}
Related
I am performing a search request in jmeter. So my test plan flow is home then login then product catalogue and then search. I tried to make a post request for search but it failing all the time. I used a CSV file so each time the query is changed. But then I used a get request and used the query variable in the search path like this search?query=${search_input}and then it passed but when i checked the html it is not the correct page. In the html response I also see this
{{noSearchResults.query}}'. But if i put the url on the browser it works fine. Can you please help me with this?
Double check that your ${search_input} variable has the anticipated value using Debug Sampler and View Results Tree listener combination
It might be the case that your ${search_input} variable contains special characters which need to be URL-encoded so you might need to wrap the variable into __urlencode() function like:
search?query=${__urlencode(${search_input})}
JMeter automatically treats responses with status code below 400 as successful, if you need to add an extra layer of check for presence of the results or absence of {{noSearchResults.query}} - use Response Assertion
I am using UseStatusCodePages Middleware to show status code pages on my application but it shows plain text on UI without any other information,
I want to show UI with Status Code Information along with some other helpful information like Customer Support Number with more user-friendly page.
I found out we can use two extension methods to do that which is UseStatusCodePagesWithRedirects and UseStatusCodePagesWithReExecute. Only Difference I found out from Microsoft Docs is,
UseStatusCodePagesWithRedirects : Send 302 to Client.
UseStatusCodePagesWithReExecute : Send Original Status Code and Executes handler for redirect URL.
Is that the only difference?
I think that the main difference is that UseStatusCodePagesWithRedirects is redirecting you to error controller action method while UseStatusCodePagesWithReExecute is just rendering page with out redirecting
Example
Controller actions
[Route("error/404")]
public IActionResult Error404(int code)
{
return View("Error404");
}
[Route("error/{code}")]
public IActionResult Error(int code)
{
return StatusCode(code);
}
Startup Cinfigue
app.UseStatusCodePagesWithRedirects("/error/{0}");
or
app.UseStatusCodePagesWithReExecute("/error/{0}");
Case 1 (404 Error)
Url : https://localhost:5001/notexits_page
1) UseStatusCodePagesWithRedirects
Result:
Url is: https://localhost:5001/error/404
We see Error404 page
2) UseStatusCodePagesWithReExecute
Result:
Url is: https://localhost:5001/notexits_page
We see Error404 page
Case2 (401 Error)
Url : https://localhost:5001/admin/users
1) UseStatusCodePagesWithRedirects
Result:
Url is: https://localhost:5001/error/401
We stack in infinity loop
1) UseStatusCodePagesWithRedirects
Result:
Url is: https://localhost:5001/admin/users
We see default browser error page for 401 error
When Using app.UseStatusCodePagesWithRedirects("/Error/{0}") and invalid request(lets say "/abc/xyz") is raised then;
Status Code 404 is issued, app.UseStatusCodePagesWithRedirects("/Error/{0}") intercepts the request and 302 status code is issued(which means URI of the requested resource has been changed temporarily)
As 302 is issued another get request is issued which results in change of the url from
"/abc/xyz" to "/Error/404".
As the request is redirected to the specific error controller the status code for the request is 200 ok in the browser developer tool.
But When Using app.UseStatusCodePagesWithReExecute("/Error/{0}") and invalid request(lets say "/abc/xyz") is raised then;
app.UseStatusCodePagesWithReExecute("/Error/{0}") middleware intercepts the 404 status code and re-executes the pipeline pointing it to the URL
As the middleware is re executing the pipeline the original URL "/abc/xyz" in the address bar is preserved. It does not change from "/abc/xyz" to "/Error/{0}".
Also the original status Code(404 in this case) is preserved in the developer tool.
Here i create a Simple wcf-Rest Service for Update with following methodes
[OperationContract]
[WebInvoke(UriTemplate = "/UpdatexyzData",Method ="POST",RequestFormat = WebMessageFormat.Json,ResponseFormat =WebMessageFormat.Json)]
void Updatexyz(xyz Update);
When I try to Hit that Service from Browser I type Url Like this
http://localhost:9706/EmployeeService.svc/UpdatexyzData
The Browser through an Error as Methode Not allowed Please Help me How to format the Url
you created POST method. you cant access it with browser.
change the Method ="GET" or call it another way. you can use Fiddler4.
this is my first question here and it's quite tricky as i didn't find enough relevant resources on the web. So I really hope, to get some help with this:
I am doing a custom single-sign-on with Liferay 6.2 GA4. Therefore I have developed a custom login-hook, that can handle my URL that looks like:
http://localhost:8080/c/portal/login?q=10C7vCMqv%2BlYThuxjdOmbUIXj1LKz9W3s5IUg%2F8H%2FvqRPUGOuzoC7pRT4hwVp2TpLf%2FnDRaGfpvoubhvSxlhidyX1SAowlvhdeWb95xRyxyCGZmKxE%2FZejk%2BIS5PvVHYIprBmM5Ec1cM%2Fq5dd5OGpEJJislrctRP
From this i decode the q-parameter to get the login parameters and other parameters, that i need to decide on which page I get redirected and i pass the attribute to the request
request.setAttribute("myParam", recordId);
and
return credentials;
I have also a LoginPostAction, that gets called afterwards and here it is, where it gets tricky:
public final void run(final HttpServletRequest request, final HttpServletResponse response)
throws ActionException {
...
final PortletURL redirectURL = PortletURLFactoryUtil.create(
request, "portlet_WAR_myportlet",
>>>> PortalUtil.getPlidFromPortletId(???, "portlet_WAR_myportlet"),
PortletRequest.RENDER_PHASE);
redirectURL.setParameter("myParam", String.valueOf(request.getAttribute("myParam")));
response.sendRedirect(redirectURL.toString());
}
So, I have the portlet name (PortletId) but I cannot get the Plid from this, as i don't have the ThemeDisplay at this time.
First question: How can i create a PortletURL at this time, which i can use in sendRedirect()?
Second: I have also tried to setAttribute and hardcode the sendRedirect("/urlToMyPortlet"), but I cannot use this at this time anymore as it gets lost afterwards (and is null) when i try to get it on the next page.
Any suggestions?
Thanks a lot in advance,
rom12three
I am new to jmeter and am working on putting together a test plan. The hurdle I've encountered is as follows:
First, a POST is made to processForm.aspx
Then, the user is redirected to pleaseWait.aspx
This page either redirects immediately to results.aspx OR loads, with a META REFRESH tag set to refresh in 5 seconds (and this step is repeated).
Now -- I can get this to execute by doing the following:
HTTP Sampler POST to processForm.aspx
Assert Response contains "<something on pleaseWait.aspx>"
While LAST
HTTP Sampler GET to pleaseWait.aspx
Assert Response contains "<something on results.aspx>"
However -- I don't care for this method, because it results in failed assertions (even though things are working as expected). I am sure there must be some other way to do this? Anyone more familiar with JMeter than I?
UPDATE:
Got it going by using Regular Expression Extractor instead of Assertions.
1) Add a User Defined Variables section at Test Plan Root
2) Add a variable to it "LoginWait" and "false"
HTTP Sampler POST to processForm.aspx
RegEx Extract Response Body contains "<something on pleaseWait.aspx>" into LoginWait
While ${LoginWait}
HTTP Sampler GET to pleaseWait.aspx
RegEx Extract Response Body contains "<something on pleaseWait.aspx>" into LoginWait
...
You could try using "follow redirects" on your HTTP Request. It would eliminate the logic you need, and still get you to the page you're going.