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

Allow to change URL using requestOptions.url in RequestHooks #2635

Closed
AndreyBelym opened this issue Jul 17, 2018 · 6 comments
Closed

Allow to change URL using requestOptions.url in RequestHooks #2635

AndreyBelym opened this issue Jul 17, 2018 · 6 comments

Comments

@AndreyBelym
Copy link
Contributor

Are you requesting a feature or reporting a bug?

Enhancement

What is the current behavior?

The destination URL of a request can be changed in a RequestHook by modifying parts like hostname, port, protocol of the URL by altering corresponding properties of a requestOptions object. The requestOptions.url property can be changed, but it doesn't lead to change of the request's destination.

What is the expected behavior?

The destination of a request must be changed when the requestOptions.url is changed.

@AndreyBelym AndreyBelym added TYPE: enhancement The accepted proposal for future implementation. AREA: server labels Jul 17, 2018
@AndreyBelym AndreyBelym added this to the Planned milestone Jul 17, 2018
@kennychua
Copy link

any leads for fixing this issue? I'd be interested in picking this up if you think this is easy enough to understand -- I'm new to the testcafe codebase

@miherlosev
Copy link
Collaborator

Hi @kennychua

Thank you for your interest in TestCafe. At present, we don't have a final API design for this enhancement. We will discuss about it and let you know about results.

@gudoy
Copy link

gudoy commented Sep 10, 2018

We faced the same issue. After struggling a couple of hours try to find why this didn't work, I found a reference to this issue.
If you do not intend to fix this for the moment, it would be nice at least to edit the document here to mark the url prop as read-only.

@AndreyBelym AndreyBelym added this to Test API Suggestions in Enhancements processing Mar 1, 2019
@AndreyBelym AndreyBelym added STATE: Stale An outdated issue that will be automatically closed by the Stale bot. FREQUENCY: level 2 and removed STATE: Stale An outdated issue that will be automatically closed by the Stale bot. labels Oct 19, 2020
@miherlosev
Copy link
Collaborator

This feature is implemented.

import { RequestHook } from 'testcafe';

class CustomRequestHook extends RequestHook {
     onRequest (e) {
        e.requestOptions.path = '/another-page';
     }
}

Enhancements processing automation moved this from Test API Suggestions to Closed Feb 25, 2022
@pjweisberg
Copy link

Do you know how many hours I spent today trying to figure out why changing the url in requestOptions wasn't working?

Almost as many as I spent yesterday trying to figure out why modifying the headers in onResponse didn't work. At least there's a README somewhere that mentions that that won't work, even though it's not in the jsdoc on the actual method where I might have seen it.

I was on the verge of concluding that the line in the docs about being able to use onRequest to change request parameters was just a lie.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jun 10, 2022
@Aleksey28
Copy link
Collaborator

Hi @pjweisberg,

We apologize for this misunderstanding. We will update information about how to change a URL in the documentation.

@Aleksey28 Aleksey28 removed the STATE: Need response An issue that requires a response or attention from the team. label Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

No branches or pull requests

6 participants